From 7a2c01319093262a09099def402bf00cab3b5c3c Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 15 Mar 2016 19:02:46 +0545 Subject: Redmine #5994 Make DHCP static edit advanced buttons Make the advanced buttons consistent. --- src/usr/local/www/services_dhcp_edit.php | 170 +++++++++++++++++++++++-------- 1 file changed, 126 insertions(+), 44 deletions(-) (limited to 'src/usr') 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); // + showadvdns = ; + } 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 = ""; + } else { + text = ""; + } + $('#btnadvdns').html(' ' + 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(''); + $('#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) { + + showadvntp = ; + } 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 = ""; + } else { + text = ""; + } + $('#btnadvntp').html(' ' + 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) { + + showadvtftp = ; + } else { + // It was a click, swap the state. + showadvtftp = !showadvtftp; + } + + hideInput('tftp', !showadvtftp); + + if (showadvtftp) { + text = ""; + } else { + text = ""; + } + $('#btnadvtftp').html(' ' + 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(''); }); // On initial load - hideDDNS(true); - hideClass('ntpclass', true); - hideInput('tftp', true); + show_advdns(true); + show_advntp(true); + show_advtftp(true); }); //]]> -- cgit v1.1