Created
February 19, 2012 00:31
-
-
Save talfco/1861450 to your computer and use it in GitHub Desktop.
BP1: Javascript Code Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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