Skip to content

Instantly share code, notes, and snippets.

@talfco
Created February 19, 2012 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talfco/1861450 to your computer and use it in GitHub Desktop.
Save talfco/1861450 to your computer and use it in GitHub Desktop.
BP1: Javascript Code Generator
<?php
require_once($_SERVER['DOCUMENT_ROOT'].'/../common/cb.Global.php');
function generateInjectLocalizationScript($inForm) {
global $fields, $busobject;
echo "<script>";
echo "$(document).ready(function() {";
echo "var locfields = {";
foreach ($fields as $key => $value) {
echo '"label_' . $value["name"] . '": "' . $busobject . "." . $value["name"] . '",';
if ($inForm && $value["note"]) {
echo '"note_' . $value["name"] . '": "' . $busobject . ".note." . $value["name"] . '",';
}
}
echo "};";
echo "injectLocalization(locfields);";
echo "});";
echo "</script>";
}
function generateInjectContentDetailEditors() {
global $fields;
echo "<script>";
echo 'function injectContentDetailEditors(id) {';
foreach ($fields as $key => $value) {
$str = '$("#'. $value["name"] . '").eip("/"+getBusinessObjectFromURLPath()+"/fetch.php?action=update&id="+id,{ select_text: true';
if (!IsNullOrEmptyString($value["editfield_class"])) {
$str = $str . ',editfield_class : "' . $value["editfield_class"] . '"';
}
$str= $str . '});';
echo $str;
$str = "";
}
echo "}";
echo "</script>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment