Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
c0994a3a
Commit
c0994a3a
authored
Nov 19, 2007
by
Gábor Hojtsy
Browse files
#177556
by flobruit and momendo: hide 'select all' checkbox when there are no checkboxes to select
parent
b0676c8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
misc/tableselect.js
View file @
c0994a3a
...
...
@@ -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
;
}
}
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment