Skip to content

Commit

Permalink
Cleaner HTML code
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Feb 24, 2013
1 parent 3baf8a6 commit a6378ab
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions htdocs/core/lib/ajax.lib.php
Expand Up @@ -364,7 +364,8 @@ function ajax_constantonoff($code, $input=array(), $entity=false)

$entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);

$out= '<script type="text/javascript">
$out= "\n<!-- Ajax code to switch constant ".$code." -->".'
<script type="text/javascript">
$(function() {
var input = '.json_encode($input).';
var url = \''.DOL_URL_ROOT.'/core/ajax/constantonoff.php\';
Expand All @@ -376,11 +377,8 @@ function ajax_constantonoff($code, $input=array(), $entity=false)
// Set constant
$("#set_" + code).click(function() {
if (input.alert && input.alert.set) {
// Posibility to force label of buttons
if (input.alert.set.yesButton)
yesButton = input.alert.set.yesButton;
if (input.alert.set.noButton)
noButton = input.alert.set.noButton;
if (input.alert.set.yesButton) yesButton = input.alert.set.yesButton;
if (input.alert.set.noButton) noButton = input.alert.set.noButton;
confirmConstantAction("set", url, code, input, input.alert.set, entity, yesButton, noButton);
} else {
setConstant(url, code, input, entity);
Expand All @@ -390,22 +388,20 @@ function ajax_constantonoff($code, $input=array(), $entity=false)
// Del constant
$("#del_" + code).click(function() {
if (input.alert && input.alert.del) {
// Posibility to force label of buttons
if (input.alert.del.yesButton)
yesButton = input.alert.del.yesButton;
if (input.alert.del.noButton)
noButton = input.alert.del.noButton;
if (input.alert.del.yesButton) yesButton = input.alert.del.yesButton;
if (input.alert.del.noButton) noButton = input.alert.del.noButton;
confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton);
} else {
delConstant(url, code, input, entity);
}
});
});
</script>';
</script>'."\n";

$out.= '<div id="confirm_'.$code.'" title="" style="display: none;"></div>';
$out.= '<span id="set_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'hideobject':'').'">'.img_picto($langs->trans("Disabled"),'switch_off').'</span>';
$out.= '<span id="del_'.$code.'" class="linkobject '.(! empty($conf->global->$code)?'':'hideobject').'">'.img_picto($langs->trans("Enabled"),'switch_on').'</span>';
$out.="\n";

return $out;
}
Expand Down

0 comments on commit a6378ab

Please sign in to comment.