diff options
author | Phil Davis <phil.davis@inf.org> | 2016-03-15 19:02:46 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2016-03-15 19:02:46 +0545 |
commit | 7a2c01319093262a09099def402bf00cab3b5c3c (patch) | |
tree | 7117aff374e98600a2f200fd3e873ca4599176a9 /src/usr/local/www/services_dhcp_edit.php | |
parent | faab522fa51ec83c0284e3f1fc6129580d7360f7 (diff) | |
download | pfsense-7a2c01319093262a09099def402bf00cab3b5c3c.zip pfsense-7a2c01319093262a09099def402bf00cab3b5c3c.tar.gz |
Redmine #5994 Make DHCP static edit advanced buttons
Make the advanced buttons consistent.
Diffstat (limited to 'src/usr/local/www/services_dhcp_edit.php')
-rw-r--r-- | src/usr/local/www/services_dhcp_edit.php | 170 |
1 files changed, 126 insertions, 44 deletions
diff --git a/src/usr/local/www/services_dhcp_edit.php b/src/usr/local/www/services_dhcp_edit.php index 1bf03c6..7cc8b98 100644 --- a/src/usr/local/www/services_dhcp_edit.php +++ b/src/usr/local/www/services_dhcp_edit.php @@ -590,18 +590,18 @@ $section->addInput(new Form_Input( $pconfig['maxtime'] ))->setHelp('This is the maximum lease time for clients that ask for a specific expiration time. The default is 86400 seconds.'); -$btndyndns = new Form_Button( - 'btndyndns', - 'Advanced', +$btnadv = new Form_Button( + 'btnadvdns', + 'Display Advanced', null, 'fa-cog' ); -$btndyndns->addClass('btn-info btn-sm'); +$btnadv->addClass('btn-info btn-sm'); $section->addInput(new Form_StaticText( 'Dynamic DNS', - $btndyndns + $btnadv )); $section->addInput(new Form_Checkbox( @@ -638,18 +638,18 @@ $section->addInput(new Form_Input( $pconfig['ddnsdomainkey'] ))->setHelp('Enter the dynamic DNS domain key secret which will be used to register client names in the DNS server.'); -$btnntp = new Form_Button( - 'btnntp', - 'Advanced', +$btnadv = new Form_Button( + 'btnadvntp', + 'Display Advanced', null, 'fa-cog' ); -$btnntp->addClass('btn-info btn-sm'); +$btnadv->addClass('btn-info btn-sm'); $section->addInput(new Form_StaticText( 'NTP servers', - $btnntp + $btnadv )); $group = new Form_Group('NTP Servers'); @@ -674,18 +674,18 @@ $group->addClass('ntpclass'); $section->add($group); -$btntftp = new Form_Button( - 'btntftp', - 'Advanced', +$btnadv = new Form_Button( + 'btnadvtftp', + 'Display Advanced', null, 'fa-cog' ); -$btntftp->addClass('btn-info btn-sm'); +$btnadv->addClass('btn-info btn-sm'); $section->addInput(new Form_StaticText( 'TFTP servers', - $btntftp + $btnadv )); $section->addInput(new Form_Input( @@ -703,50 +703,132 @@ print($form); //<![CDATA[ events.push(function() { - function hideDDNS(hide) { - hideCheckbox('ddnsupdate', hide); - hideInput('ddnsdomain', hide); - hideInput('ddnsdomainprimary', hide); - hideInput('ddnsdomainkeyname', hide); - hideInput('ddnsdomainkey', hide); + // Show advanced DNS options ====================================================================================== + var showadvdns = false; + + function show_advdns(ispageload) { + var text; + // On page load decide the initial state based on the data. + if (ispageload) { +<?php + if (!$pconfig['ddnsupdate'] && empty($pconfig['ddnsdomain']) && empty($pconfig['ddnsdomainprimary']) && + empty($pconfig['ddnsdomainkeyname']) && empty($pconfig['ddnsdomainkey'])) { + $showadv = false; + } else { + $showadv = true; + } +?> + showadvdns = <?php if ($showadv) {echo 'true';} else {echo 'false';} ?>; + } else { + // It was a click, swap the state. + showadvdns = !showadvdns; + } + + hideCheckbox('ddnsupdate', !showadvdns); + hideInput('ddnsdomain', !showadvdns); + hideInput('ddnsdomainprimary', !showadvdns); + hideInput('ddnsdomainkeyname', !showadvdns); + hideInput('ddnsdomainkey', !showadvdns); + + if (showadvdns) { + text = "<?=gettext('Hide Advanced');?>"; + } else { + text = "<?=gettext('Display Advanced');?>"; + } + $('#btnadvdns').html('<i class="fa fa-cog"></i> ' + text); } - // Make the ‘Copy My MAC’ button a plain button, not a submit button - $("#btnmymac").prop('type','button'); + $('#btnadvdns').prop('type', 'button'); - // On click, copy the hidden 'mymac' text to the 'mac' input - $("#btnmymac").click(function() { - $('#mac').val('<?=$mymac?>'); + $('#btnadvdns').click(function(event) { + show_advdns(); }); - // Make the ‘tftp’ button a plain button, not a submit button - $("#btntftp").prop('type','button'); + // Show advanced NTP options ====================================================================================== + var showadvntp = false; + + function show_advntp(ispageload) { + var text; + // On page load decide the initial state based on the data. + if (ispageload) { +<?php + if (empty($pconfig['ntp1']) && empty($pconfig['ntp2'])) { + $showadv = false; + } else { + $showadv = true; + } +?> + showadvntp = <?php if ($showadv) {echo 'true';} else {echo 'false';} ?>; + } else { + // It was a click, swap the state. + showadvntp = !showadvntp; + } + + hideInput('ntp1', !showadvntp); + hideInput('ntp2', !showadvntp); - // Show tftp controls - $("#btntftp").click(function() { - hideInput('tftp', false); + if (showadvntp) { + text = "<?=gettext('Hide Advanced');?>"; + } else { + text = "<?=gettext('Display Advanced');?>"; + } + $('#btnadvntp').html('<i class="fa fa-cog"></i> ' + text); + } + + $('#btnadvntp').prop('type', 'button'); + + $('#btnadvntp').click(function(event) { + show_advntp(); }); - // Make the ‘ntp’ button a plain button, not a submit button - $("#btnntp").prop('type','button'); + // Show advanced TFTP options ====================================================================================== + var showadvtftp = false; + + function show_advtftp(ispageload) { + var text; + // On page load decide the initial state based on the data. + if (ispageload) { +<?php + if (empty($pconfig['tftp'])) { + $showadv = false; + } else { + $showadv = true; + } +?> + showadvtftp = <?php if ($showadv) {echo 'true';} else {echo 'false';} ?>; + } else { + // It was a click, swap the state. + showadvtftp = !showadvtftp; + } + + hideInput('tftp', !showadvtftp); + + if (showadvtftp) { + text = "<?=gettext('Hide Advanced');?>"; + } else { + text = "<?=gettext('Display Advanced');?>"; + } + $('#btnadvtftp').html('<i class="fa fa-cog"></i> ' + text); + } + + $('#btnadvtftp').prop('type', 'button'); - // Show ntp controls - $("#btnntp").click(function() { - hideClass('ntpclass', false); + $('#btnadvtftp').click(function(event) { + show_advtftp(); }); - // Make the ‘ddns’ button a plain button, not a submit button - $("#btndyndns").prop('type','button'); + // Make the ‘Copy My MAC’ button a plain button, not a submit button + $("#btnmymac").prop('type','button'); - // Show ddns controls - $("#btndyndns").click(function() { - hideDDNS(false); + // On click, copy the hidden 'mymac' text to the 'mac' input + $("#btnmymac").click(function() { + $('#mac').val('<?=$mymac?>'); }); // On initial load - hideDDNS(true); - hideClass('ntpclass', true); - hideInput('tftp', true); + show_advdns(true); + show_advntp(true); + show_advtftp(true); }); //]]> </script> |