diff options
author | Phil Davis <phil.davis@inf.org> | 2016-03-17 18:47:05 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2016-03-17 18:47:05 +0545 |
commit | 61aa0edbe5c815b5fb43571206cc3761f2497361 (patch) | |
tree | 9c67bcbf1176b32745ba188222a1808c262c303c /src/usr | |
parent | 3e7d2c4f7de14b884d7898daa168aa2d66d7c91c (diff) | |
download | pfsense-61aa0edbe5c815b5fb43571206cc3761f2497361.zip pfsense-61aa0edbe5c815b5fb43571206cc3761f2497361.tar.gz |
Redmine #5994 Standardize NAT Edit Source Advanced
1) Standardize the way the Advanced button works to display and hide the source address/port fields.
2) Remove dstenable boolean - it was always set to 1 (true) and so all the tests that used it were meaningless.
3) Use true and false for portsenabled var rather than 1 and 0 - easier to read/understand.
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/local/www/firewall_nat_edit.php | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/usr/local/www/firewall_nat_edit.php b/src/usr/local/www/firewall_nat_edit.php index 9efa9d4..849f6e3 100644 --- a/src/usr/local/www/firewall_nat_edit.php +++ b/src/usr/local/www/firewall_nat_edit.php @@ -720,13 +720,13 @@ $section->addInput(new Form_Select( ))->setHelp('Choose which protocol this rule should match. In most cases "TCP" is specified.'); $btnsrcadv = new Form_Button( - 'srcadv', - 'Advanced', + 'btnsrcadv', + 'Display Advanced', null, 'fa-cog' ); -$btnsrcadv->addClass('btn-info'); +$btnsrcadv->addClass('btn-info btn-sm'); $section->addInput(new Form_StaticText( 'Source', @@ -1009,9 +1009,8 @@ print($form); <script type="text/javascript"> //<![CDATA[ events.push(function() { - var portsenabled = 1; - var dstenabled = 1; - var showsource = 0; + var portsenabled = true; + var srcenabled = <?= ($pconfig['srcnot'] || ($pconfig['src'] != "any") || ($pconfig['srcbeginport'] != "any") || ($pconfig['srcendport'] != "any"))? 1:0 ?>; var iface_old = ''; // ---------- jQuery functions, lovingly converted from the original javascript------------------------------------------ @@ -1031,14 +1030,14 @@ events.push(function() { disableInput('srcendport_cust', true); } - if (($('#dstbeginport').find(":selected").index() == 0) && portsenabled && dstenabled) { + if (($('#dstbeginport').find(":selected").index() == 0) && portsenabled) { disableInput('dstbeginport_cust', false); } else { $('#dstbeginport_cust').val(''); disableInput('dstbeginport_cust', true); } - if (($('#dstendport').find(":selected").index() == 0) && portsenabled && dstenabled) { + if (($('#dstendport').find(":selected").index() == 0) && portsenabled) { disableInput('dstendport_cust', false); } else { $('#dstendport_cust').val(''); @@ -1062,10 +1061,8 @@ events.push(function() { disableInput('srcbeginport', false); disableInput('srcendport', false); // disableInput('localbeginport_cust', false); - if (dstenabled) { - disableInput('dstbeginport', false); - disableInput('dstendport', false); - } + disableInput('dstbeginport', false); + disableInput('dstendport', false); } } @@ -1134,13 +1131,13 @@ events.push(function() { function proto_change() { if ($('#proto').find(":selected").index() >= 0 && $('#proto').find(":selected").index() <= 2) { - portsenabled = 1; + portsenabled = true; } else { - portsenabled = 0; + portsenabled = false; } if (portsenabled) { - hideClass('srcportrange', showsource == 1); + hideClass('srcportrange', !srcenabled); hideClass('dstportrange', false); hideClass('lclportrange', false); } else { @@ -1175,24 +1172,22 @@ events.push(function() { break; } - if (dstenabled) { - switch ($('#dsttype').find(":selected").index()) { - case 1: // single - disableInput('dst', false); - $('#dstmask').val(''); - disableInput('dstmask', true);; - break; - case 2: // network / - disableInput('dst', false); - disableInput('dstmask', false); - break; - default: - $('#dst').val(''); - disableInput('dst', true); - $('#dstmask').val(''); - disableInput('dstmask', true); - break; - } + switch ($('#dsttype').find(":selected").index()) { + case 1: // single + disableInput('dst', false); + $('#dstmask').val(''); + disableInput('dstmask', true);; + break; + case 2: // network / + disableInput('dst', false); + disableInput('dstmask', false); + break; + default: + $('#dst').val(''); + disableInput('dst', true); + $('#dstmask').val(''); + disableInput('dstmask', true); + break; } } @@ -1211,9 +1206,15 @@ events.push(function() { } function hideSource(hide) { + var text; hideClass('srcadv', hide); hideClass('srcportrange', hide || !portsenabled); - hideInput('srcadv', !hide); + if (hide) { + text = "<?=gettext('Display Advanced');?>"; + } else { + text = "<?=gettext('Hide Advanced');?>"; + } + $('#btnsrcadv').html('<i class="fa fa-cog"></i> ' + text); } // ---------- "onclick" functions --------------------------------------------------------------------------------- @@ -1263,12 +1264,14 @@ events.push(function() { typesel_change(); }); - $("#srcadv").click(function() { - hideSource(false); - }); + $("#btnsrcadv").click(function() { + srcenabled = !srcenabled; + hideSource(!srcenabled); + }); // ---------- On initial page load -------------------------------------------------------------------------------- - $("#srcadv").prop('type', 'button'); + $("#btnsrcadv").prop('type', 'button'); + hideSource(!srcenabled); ext_change(); dst_change($('#interface').val(),'<?=htmlspecialchars($pconfig['interface'])?>','<?=htmlspecialchars($pconfig['dst'])?>'); iface_old = $('#interface').val(); @@ -1276,9 +1279,6 @@ events.push(function() { proto_change(); nordr_change(); - var source_defined = <?= ($pconfig['srcnot'] || ($pconfig['src'] != "any") || ($pconfig['srcbeginport'] != "any") || ($pconfig['srcendport'] != "any"))? 1:0 ?>; - hideSource(!source_defined); - // --------- Autocomplete ----------------------------------------------------------------------------------------- var addressarray = <?= json_encode(get_alias_list(array("host", "network", "openvpn", "urltable"))) ?>; var customarray = <?= json_encode(get_alias_list(array("port", "url_ports", "urltable_ports"))) ?>; |