From 0bc61baaa862ad58171fcfde07be91db9245145c Mon Sep 17 00:00:00 2001 From: Stephen Beaver Date: Tue, 27 Oct 2015 10:16:31 -0400 Subject: Javascript refine to hide Delete row button if there is only one row --- src/usr/local/www/firewall_aliases_edit.php | 3 +++ src/usr/local/www/jquery/pfSenseHelpers.js | 11 +++++++++++ src/usr/local/www/pkg_edit.php | 5 ++++- src/usr/local/www/services_dhcp.php | 3 +++ src/usr/local/www/services_ntpd.php | 3 +++ src/usr/local/www/services_router_advertisements.php | 2 ++ src/usr/local/www/services_unbound_acls.php | 9 +++++++++ src/usr/local/www/system_certmanager.php | 3 +++ src/usr/local/www/vpn_pppoe_edit.php | 3 +++ src/usr/local/www/widgets/widgets/wake_on_lan.widget.php | 8 ++++---- 10 files changed, 45 insertions(+), 5 deletions(-) (limited to 'src/usr') diff --git a/src/usr/local/www/firewall_aliases_edit.php b/src/usr/local/www/firewall_aliases_edit.php index 3b9cfaf..8f3198b 100755 --- a/src/usr/local/www/firewall_aliases_edit.php +++ b/src/usr/local/www/firewall_aliases_edit.php @@ -810,6 +810,9 @@ events.push(function(){ // On load . . typechange(); + + // Suppress "Delete row" button if there are fewer than two rows + checkLastRow(); // Autocomplete var addressarray = ; diff --git a/src/usr/local/www/jquery/pfSenseHelpers.js b/src/usr/local/www/jquery/pfSenseHelpers.js index 0668489..2a1d123 100644 --- a/src/usr/local/www/jquery/pfSenseHelpers.js +++ b/src/usr/local/www/jquery/pfSenseHelpers.js @@ -240,6 +240,15 @@ function renumber() { function delete_row(row) { $('#' + row).parent('div').parent('div').remove(); renumber(); + checkLastRow(); +} + +function checkLastRow() { + if($('.repeatable').length <= 1) { + $('#deleterow0').hide(); + } else { + $('[id^=deleterow]').show(); + } } function add_row() { @@ -289,6 +298,8 @@ function add_row() { setMasks(); + checkLastRow(); + $('[id^=address]').autocomplete({ source: addressarray }); diff --git a/src/usr/local/www/pkg_edit.php b/src/usr/local/www/pkg_edit.php index ea04094..68886d7 100644 --- a/src/usr/local/www/pkg_edit.php +++ b/src/usr/local/www/pkg_edit.php @@ -1423,7 +1423,10 @@ if ($pkg['fields']['field'] != "") { ?> // Hide on page load $('.advancedoptions').hide(); - // But show it if you click the showadv button + // Suppress "Delete row" button if there are fewer than two rows + checkLastRow(); + + // Show advanced section if you click the showadv button $('#showadv').prop('type', 'button'); $("#showadv").click(function() { diff --git a/src/usr/local/www/services_dhcp.php b/src/usr/local/www/services_dhcp.php index ca60cb4..a7446a8 100644 --- a/src/usr/local/www/services_dhcp.php +++ b/src/usr/local/www/services_dhcp.php @@ -1528,6 +1528,9 @@ events.push(function(){ show_advldap(); show_advboot(); show_advopts(); + + // Suppress "Delete row" button if there are fewer than two rows + checkLastRow(); }); //]]> diff --git a/src/usr/local/www/services_ntpd.php b/src/usr/local/www/services_ntpd.php index 36af8b7..6b368a4 100644 --- a/src/usr/local/www/services_ntpd.php +++ b/src/usr/local/www/services_ntpd.php @@ -554,6 +554,9 @@ events.push(function(){ hideCheckbox('notrap', true); hideInput('leaptext', true); hideInput('leapfile', true); + + // Suppress "Delete row" button if there are fewer than two rows + checkLastRow(); }); //]]> diff --git a/src/usr/local/www/services_router_advertisements.php b/src/usr/local/www/services_router_advertisements.php index 8c001f9..05155a0 100644 --- a/src/usr/local/www/services_router_advertisements.php +++ b/src/usr/local/www/services_router_advertisements.php @@ -409,6 +409,8 @@ print($form); diff --git a/src/usr/local/www/vpn_pppoe_edit.php b/src/usr/local/www/vpn_pppoe_edit.php index d6540a5..1f146e6 100644 --- a/src/usr/local/www/vpn_pppoe_edit.php +++ b/src/usr/local/www/vpn_pppoe_edit.php @@ -625,6 +625,9 @@ events.push(function(){ hide_radius2(!$('#radiussecenable').prop('checked')); hide_radius(!$('#radiusenable').prop('checked')); + // Suppress "Delete row" button if there are fewer than two rows + checkLastRow(); + }); //]]> diff --git a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php index 94698f3..60d6eaf 100644 --- a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php +++ b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php @@ -88,17 +88,17 @@ if (count($wolcomputers) > 0) { $status = exec("/usr/sbin/arp -an | /usr/bin/awk '$4 == \"{$wolent['mac']}\" { print $7 }'"); if ($status == 'expires') { echo '' . "\n"; - echo " " . gettext("Online") . "\n"; + echo ' ' . gettext("Online") . "\n"; } else if ($status == 'permanent') { echo '' . "\n"; - echo " " . gettext("Static ARP") . "\n"; + echo ' ' . gettext("Static ARP") . "\n"; } else { echo '' . "\n"; - echo " " . gettext("Offline") . "\n"; + echo ' ' . gettext("Offline") . "\n"; } echo ''; echo " "; - echo "\n"; + echo '' . "\n"; echo "\n"; } } else { -- cgit v1.1