diff options
-rw-r--r-- | src/usr/local/www/firewall_rules.php | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/usr/local/www/firewall_rules.php b/src/usr/local/www/firewall_rules.php index 1d32e65..1dabf99 100644 --- a/src/usr/local/www/firewall_rules.php +++ b/src/usr/local/www/firewall_rules.php @@ -774,6 +774,7 @@ events.push(function() { cursor: 'grabbing', update: function(event, ui) { $('#order-store').removeAttr('disabled'); + dirty = true; } }); @@ -783,6 +784,9 @@ events.push(function() { // Save the separator bar configuration save_separators(); + + // Suppress the "Do you really want to leave the page" message + saving = true; }); // Separator bar stuff ------------------------------------------------------------------------ @@ -790,6 +794,8 @@ events.push(function() { // Globals gColor = 'bg-info'; newSeperator = false; + saving = false; + dirty = false; $("#addsep").prop('type' ,'button'); @@ -816,6 +822,19 @@ events.push(function() { $("#btnnewsep").prop('type' ,'button'); + // Watch escape and enter keys + $('#newsep').keyup(function(e) { + if(e.which == 27) { + $('#btncncsep').trigger('click'); + } + }); + + $('#newsep').keypress(function(e) { + if(e.which == 13) { + $('#btnnewsep').trigger('click'); + } + }); + handle_colors(); // Remove the temporary separator bar and replace it with the final version containing the @@ -830,6 +849,7 @@ events.push(function() { $('#order-store').removeAttr('disabled'); newSeperator = false; + dirty = true; }); // Cancel button @@ -846,10 +866,11 @@ events.push(function() { e.preventDefault(); $(this).parents('tr').remove(); $('#order-store').removeAttr('disabled'); + dirty = true; }); }); - // Compose an inout array containing the row # and text for each separator + // Compose an inout array containing the row #, color and text for each separator function save_separators() { var seprow = 0; var sepinput; @@ -883,7 +904,7 @@ events.push(function() { $('[id^=sepclr]').prop("type", "button"); $('[id^=sepclr]').click(function () { - var color = $(this).attr('value'); + var color = $(this).attr('value'); // Clear all the color classes $(this).parent('td').prop('class', ''); $(this).parent('td').prev('td').prop('class', ''); @@ -895,6 +916,15 @@ events.push(function() { }); } + // provide a warning message if hte user tries to change page before saving + $(window).bind('beforeunload', function(){ + if ((!saving && dirty) || newSeperator) { + return ("<?=gettext('You have moved one or more rules but have now yet saved')?>"); + } else { + return undefined; + } + }); + //JS equivalent to PHP htmlspecialchars() function escapeHtml(text) { var map = { |