summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorGábor Hojtsy <gabor@hojtsy.hu>2007-11-19 12:15:16 +0000
committerGábor Hojtsy <gabor@hojtsy.hu>2007-11-19 12:15:16 +0000
commitc0994a3a4ec401aea4c3d420a8ece3a49322049b (patch)
tree88048acf3f26c377e11a0a90fe1468bd5b92efeb /misc
parentb0676c8f27d75d4b4887de37c92a152386a3a740 (diff)
downloadbrdo-c0994a3a4ec401aea4c3d420a8ece3a49322049b.tar.gz
brdo-c0994a3a4ec401aea4c3d420a8ece3a49322049b.tar.bz2
#177556 by flobruit and momendo: hide 'select all' checkbox when there are no checkboxes to select
Diffstat (limited to 'misc')
-rw-r--r--misc/tableselect.js18
1 files changed, 14 insertions, 4 deletions
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;
+ }
}
};