diff options
Diffstat (limited to 'src/usr/local/www/jquery/pfSenseHelpers.js')
-rw-r--r-- | src/usr/local/www/jquery/pfSenseHelpers.js | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/src/usr/local/www/jquery/pfSenseHelpers.js b/src/usr/local/www/jquery/pfSenseHelpers.js index aac6def..4fbe9f8 100644 --- a/src/usr/local/www/jquery/pfSenseHelpers.js +++ b/src/usr/local/www/jquery/pfSenseHelpers.js @@ -138,7 +138,7 @@ function hideLabel(text, hide) { element.parent('div').removeClass('hidden'); } -// Toggle table row chackboxes and background colors on the pages that use sortable tables: +// Toggle table row checkboxes and background colors on the pages that use sortable tables: // /usr/local/www/firewall_nat.php // /usr/local/www/firewall_nat_1to1.php // /usr/local/www/firewall_nat_out.php @@ -214,13 +214,18 @@ function moveHelpText(id) { var helpSpan; if(!$(this).hasClass('pfIpMask') && !$(this).hasClass('btn')) { - - helpSpan = $('#' + fromId).parent('div').parent('div').find('span:last').clone(); + if($('#' + decrStringInt(fromId)).parent('div').hasClass('input-group')) { + helpSpan = $('#' + fromId).parent('div').parent('div').find('span:last').clone(); + } else { + helpSpan = $('#' + fromId).parent('div').find('span:last').clone(); + } if($(helpSpan).hasClass('help-block')) { - if($('#' + decrStringInt(fromId)).parent('div').hasClass('input-group')) + if($('#' + decrStringInt(fromId)).parent('div').hasClass('input-group')) { $('#' + decrStringInt(fromId)).parent('div').after(helpSpan); - else + } + else { $('#' + decrStringInt(fromId)).after(helpSpan); + } } } }); @@ -288,8 +293,7 @@ function add_row() { var lastRepeatableGroup = $('.repeatable:last'); // Clone it - var newGroup = lastRepeatableGroup.clone(true); - + var newGroup = lastRepeatableGroup.clone(); // Increment the suffix number for each input element in the new group $(newGroup).find('input').each(function() { $(this).prop("id", bumpStringInt(this.id)); @@ -332,9 +336,31 @@ function add_row() { checkLastRow(); - $('[id^=address]').autocomplete({ - source: addressarray + // Autocomplete + if ( typeof addressarray !== 'undefined') { + $('[id^=address]').each(function() { + if(this.id.substring(0, 8) != "address_") { + $(this).autocomplete({ + source: addressarray + }); + } + }); + } + + // Now that we are no longer cloning the event handlers, we need to remove and re-add after a new row + // has been added to the table + $('[id^=delete]').unbind(); + $('[id^=delete]').click(function(event) { + if($('.repeatable').length > 1) { + if((typeof retainhelp) == "undefined") + moveHelpText(event.target.id); + + delete_row(event.target.id); + } + else + alert('You may not delete the last row!'); }); + } // These are action buttons, not submit buttons @@ -401,7 +427,7 @@ $('tbody:empty').html("<tr><td></td></tr>"); $(el).children('i').toggleClass('fa-minus-circle', true); $(el).children('i').toggleClass('fa-plus-circle', false); - if($(el).closest('a').attr('name') != 'widgets-available') { + if($(el).closest('a').attr('id') != 'widgets-available') { updateWidgets(); } }); @@ -410,7 +436,7 @@ $('tbody:empty').html("<tr><td></td></tr>"); $(el).children('i').toggleClass('fa-minus-circle', false); $(el).children('i').toggleClass('fa-plus-circle', true); - if($(el).closest('a').attr('name') != 'widgets-available') { + if($(el).closest('a').attr('id') != 'widgets-available') { updateWidgets(); } }); |