Merge pull request #331 from marcosgdf/coding-style
jQuerified events' javascript
This commit is contained in:
commit
945deb95a2
@ -58,29 +58,51 @@ class FormActions
|
|||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
$listofstatus=array('-1'=>$langs->trans("ActionNotApplicable"),
|
$listofstatus = array(
|
||||||
'0'=>$langs->trans("ActionRunningNotStarted"),
|
'-1' => $langs->trans("ActionNotApplicable"),
|
||||||
'50'=>$langs->trans("ActionRunningShort"),
|
'0' => $langs->trans("ActionRunningNotStarted"),
|
||||||
'100'=>$langs->trans("ActionDoneShort"));
|
'50' => $langs->trans("ActionRunningShort"),
|
||||||
|
'100' => $langs->trans("ActionDoneShort")
|
||||||
|
);
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
print "\n";
|
print "\n";
|
||||||
print '<script type="text/javascript">'."\n";
|
print "<script type=\"text/javascript\">
|
||||||
print 'jQuery(document).ready(function () {'."\n";
|
var htmlname = '".$htmlname."';
|
||||||
print 'jQuery("#select'.$htmlname.'").change(function() { select_status(document.'.$formname.'.status.value); });'."\n";
|
|
||||||
print 'jQuery("#val'.$htmlname.'").change(function() { select_status(jQuery("#val'.$htmlname.'").val()); });'."\n";
|
jQuery(document).ready(function () {
|
||||||
print 'select_status(document.'.$formname.'.status.value);'."\n";
|
jQuery('#select'+htmlname).change(function() {
|
||||||
print '});'."\n";
|
select_status();
|
||||||
print 'function select_status(mypercentage) {'."\n";
|
});
|
||||||
print 'document.'.$formname.'.percentageshown.value=(mypercentage>=0?mypercentage:\'\');'."\n";
|
jQuery('#val'+htmlname).change(function() {
|
||||||
print 'document.'.$formname.'.percentage.value=mypercentage;'."\n";
|
select_status();
|
||||||
print 'if (mypercentage == -1) { document.'.$formname.'.percentageshown.disabled=true; jQuery(".hideifna").hide(); }'."\n";
|
});
|
||||||
print 'else if (mypercentage == 0) { document.'.$formname.'.percentageshown.disabled=true; jQuery(".hideifna").show();}'."\n";
|
|
||||||
print 'else if (mypercentage == 100) { document.'.$formname.'.percentageshown.disabled=true; jQuery(".hideifna").show();}'."\n";
|
select_status();
|
||||||
print 'else { document.'.$formname.'.percentageshown.disabled=false; }'."\n";
|
});
|
||||||
print '}'."\n";
|
|
||||||
print '</script>'."\n";
|
function select_status() {
|
||||||
|
mypercentage = jQuery('#val'+htmlname).val();
|
||||||
|
jQuery('input[name=percentageshown]').val((mypercentage>=0?mypercentage:''));
|
||||||
|
jQuery('input[name=percentage]').val(mypercentage);
|
||||||
|
if (mypercentage == -1) {
|
||||||
|
jQuery('input[name=percentageshown]').attr('disabled', 'disabled');
|
||||||
|
jQuery('.hideifna').hide();
|
||||||
|
}
|
||||||
|
else if (mypercentage == 0) {
|
||||||
|
jQuery('input[name=percentageshown]').attr('disabled', 'disabled');
|
||||||
|
jQuery('.hideifna').show();
|
||||||
|
}
|
||||||
|
else if (mypercentage == 100) {
|
||||||
|
jQuery('input[name=percentageshown]').attr('disabled', 'disabled');
|
||||||
|
jQuery('.hideifna').show();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
jQuery('input[name=percentageshown]').removeAttr('disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>\n";
|
||||||
print '<select '.($canedit?'':'disabled="disabled" ').'name="status" id="select'.$htmlname.'" class="flat">';
|
print '<select '.($canedit?'':'disabled="disabled" ').'name="status" id="select'.$htmlname.'" class="flat">';
|
||||||
foreach($listofstatus as $key => $val)
|
foreach($listofstatus as $key => $val)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user