From c0994a3a4ec401aea4c3d420a8ece3a49322049b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Hojtsy?= Date: Mon, 19 Nov 2007 12:15:16 +0000 Subject: #177556 by flobruit and momendo: hide 'select all' checkbox when there are no checkboxes to select --- misc/tableselect.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'misc') diff --git a/misc/tableselect.js b/misc/tableselect.js index 41ba04905..65eb7efbc 100644 --- a/misc/tableselect.js +++ b/misc/tableselect.js @@ -5,6 +5,11 @@ Drupal.behaviors.tableSelect = function (context) { }; Drupal.tableSelect = function() { + // Do not add a "Select all" checkbox if there are no rows with checkboxes in the table + if ($('td input:checkbox', this).size() == 0) { + return; + } + // Keep track of the table, which checkbox is checked and alias the settings. var table = this, checkboxes, lastChecked; var strings = { 'selectAll': Drupal.t('Select all rows in this table'), 'selectNone': Drupal.t('Deselect all rows in this table') }; @@ -58,7 +63,9 @@ Drupal.tableSelectRange = function(from, to, state) { // Traverse through the sibling nodes. for (var i = from[mode]; i; i = i[mode]) { // Make sure that we're only dealing with elements. - if (i.nodeType != 1) continue; + if (i.nodeType != 1) { + continue; + } // Either add or remove the selected class based on the state of the target checkbox. $(i)[ state ? 'addClass' : 'removeClass' ]('selected'); @@ -68,10 +75,13 @@ Drupal.tableSelectRange = function(from, to, state) { if (to.nodeType) { // If we are at the end of the range, stop. - if (i == to) break; + if (i == to) { + break; + } } // A faster alternative to doing $(i).filter(to).length. - else if (jQuery.filter(to, [i]).r.length) break; - + else if (jQuery.filter(to, [i]).r.length) { + break; + } } }; -- cgit v1.2.3