Skip to content

Commit

Permalink
Redmine #5994 standardize firewall rule advanced button
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Davis committed Mar 17, 2016
1 parent 770e3f4 commit c3ed121
Showing 1 changed file with 42 additions and 24 deletions.
66 changes: 42 additions & 24 deletions src/usr/local/www/firewall_rules_edit.php
Expand Up @@ -1366,7 +1366,7 @@ function build_if_list() {
'Display Advanced',
null,
'fa-cog'
))->addClass('btn-info');
))->addClass('btn-info btn-sm');
}

$portValues = ['' => gettext('(other)'), 'any' => gettext('any')];
Expand Down Expand Up @@ -1441,23 +1441,19 @@ function build_if_list() {
$pconfig['descr']
))->setHelp('You may enter a description here for your reference.');

$adv_open = is_aoadv_used($pconfig);

$btnadvanced = new Form_Button(
'toggle-advanced',
'Advanced Options',
$btnadv = new Form_Button(
'btnadvopts',
'Display Advanced',
null,
'fa-cog'
);

$btnadvanced->addClass('btn-info');
$btnadv->addClass('btn-info btn-sm');

if (!$adv_open) {
$section->addInput(new Form_StaticText(
null,
$btnadvanced
));
}
$section->addInput(new Form_StaticText(
'Advanced Options',
$btnadv
));

$form->add($section);

Expand Down Expand Up @@ -1743,9 +1739,40 @@ function build_if_list() {

var portsenabled = 1;
var editenabled = 1;
var optionsvisible = 0;
var srcportsvisible = false;

// Show advanced additional opts options ======================================================
var showadvopts = false;

function show_advopts(ispageload) {
var text;
// On page load decide the initial state based on the data.
if (ispageload) {
showadvopts = <?php if (is_aoadv_used($pconfig)) {echo 'true';} else {echo 'false';} ?>;
} else {
// It was a click, swap the state.
showadvopts = !showadvopts;
}

hideClass('advanced-options', !showadvopts);
if ($('#tcpflags_any').prop('checked')) {
$('.table-flags').addClass('hidden');
}

if (showadvopts) {
text = "<?=gettext('Hide Advanced');?>";
} else {
text = "<?=gettext('Display Advanced');?>";
}
$('#btnadvopts').html('<i class="fa fa-cog"></i> ' + text);
}

$('#btnadvopts').prop('type', 'button');

$('#btnadvopts').click(function(event) {
show_advopts();
});

function ext_change() {

if (($('#srcbeginport').find(":selected").index() == 0) && portsenabled && editenabled) {
Expand Down Expand Up @@ -1927,7 +1954,7 @@ function dst_rep_change() {

typesel_change();

hideClass('advanced-options', ! "<?=$adv_open?>");
show_advopts(true);
hideClass('srcportrange', true);

<?php if ((!empty($pconfig['srcbeginport']) && $pconfig['srcbeginport'] != "any") || (!empty($pconfig['srcendport']) && $pconfig['srcendport'] != "any")): ?>
Expand All @@ -1936,7 +1963,6 @@ function dst_rep_change() {
<?php endif; ?>

// Make it a regular button, not a submit
$('#toggle-advanced').prop('type','button');
$("#btnsrcadv").prop('type','button');

// on click . .
Expand Down Expand Up @@ -1983,14 +2009,6 @@ function dst_rep_change() {
proto_change();
});

$('#toggle-advanced').click(function() {
optionsvisible = 1;
hideClass('advanced-options', false);
if ($('#tcpflags_any').prop('checked')) {
$('.table-flags').addClass('hidden');
}
});

$('#tcpflags_any').click(function () {
if (this.checked) {
$('.table-flags').addClass('hidden');
Expand Down

0 comments on commit c3ed121

Please sign in to comment.