Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
940b0590
Commit
940b0590
authored
17 years ago
by
Gábor Hojtsy
Browse files
Options
Downloads
Patches
Plain Diff
#154593
by asimmonds and quicksketch:fix select all checkbox in moving table headers
parent
d4833a4f
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc/tableselect.js
+19
-16
19 additions, 16 deletions
misc/tableselect.js
with
19 additions
and
16 deletions
misc/tableselect.js
+
19
−
16
View file @
940b0590
...
@@ -6,23 +6,28 @@ Drupal.behaviors.tableSelect = function (context) {
...
@@ -6,23 +6,28 @@ Drupal.behaviors.tableSelect = function (context) {
Drupal
.
tableSelect
=
function
()
{
Drupal
.
tableSelect
=
function
()
{
// Keep track of the table, which checkbox is checked and alias the settings.
// Keep track of the table, which checkbox is checked and alias the settings.
var
table
=
this
,
selectAll
,
checkboxes
,
lastChecked
;
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
'
)
};
var
strings
=
{
'
selectAll
'
:
Drupal
.
t
(
'
Select all rows in this table
'
),
'
selectNone
'
:
Drupal
.
t
(
'
Deselect all rows in this table
'
)
};
var
updateSelectAll
=
function
(
state
)
{
// Store the select all checkbox in a variable as we need it quite often.
$
(
'
th.select-all input:checkbox
'
,
table
).
each
(
function
()
{
selectAll
=
$
(
'
<input type="checkbox" class="form-checkbox" />
'
).
attr
(
'
title
'
,
strings
.
selectAll
).
click
(
function
()
{
$
(
this
).
attr
(
'
title
'
,
state
?
strings
.
selectNone
:
strings
.
selectAll
);
// Loop through all checkboxes and set their state to the select all checkbox' state.
this
.
checked
=
state
;
checkboxes
.
each
(
function
()
{
this
.
checked
=
selectAll
[
0
].
checked
;
// Either add or remove the selected class based on the state of the check all checkbox.
$
(
this
).
parents
(
'
tr:first
'
)[
this
.
checked
?
'
addClass
'
:
'
removeClass
'
](
'
selected
'
);
});
});
// Update the title and the state of the check all box.
};
selectAll
.
attr
(
'
title
'
,
selectAll
[
0
].
checked
?
strings
.
selectNone
:
strings
.
selectAll
);
});
// Find all <th> with class select-all, and insert the check all checkbox.
// Find all <th> with class select-all, and insert the check all checkbox.
$
(
'
th.select-all
'
,
table
).
prepend
(
selectAll
);
$
(
'
th.select-all
'
,
table
).
prepend
(
$
(
'
<input type="checkbox" class="form-checkbox" />
'
).
attr
(
'
title
'
,
strings
.
selectAll
)).
click
(
function
(
event
)
{
if
(
$
(
event
.
target
).
is
(
'
input:checkbox
'
))
{
// Loop through all checkboxes and set their state to the select all checkbox' state.
checkboxes
.
each
(
function
()
{
this
.
checked
=
event
.
target
.
checked
;
// Either add or remove the selected class based on the state of the check all checkbox.
$
(
this
).
parents
(
'
tr:first
'
)[
this
.
checked
?
'
addClass
'
:
'
removeClass
'
](
'
selected
'
);
});
// Update the title and the state of the check all box.
updateSelectAll
(
event
.
target
.
checked
);
}
});
// For each of the checkboxes within the table.
// For each of the checkboxes within the table.
checkboxes
=
$
(
'
td input:checkbox
'
,
table
).
click
(
function
(
e
)
{
checkboxes
=
$
(
'
td input:checkbox
'
,
table
).
click
(
function
(
e
)
{
...
@@ -38,9 +43,7 @@ Drupal.tableSelect = function() {
...
@@ -38,9 +43,7 @@ Drupal.tableSelect = function() {
}
}
// If all checkboxes are checked, make sure the select-all one is checked too, otherwise keep unchecked.
// If all checkboxes are checked, make sure the select-all one is checked too, otherwise keep unchecked.
selectAll
[
0
].
checked
=
(
checkboxes
.
length
==
$
(
checkboxes
).
filter
(
'
:checked
'
).
length
);
updateSelectAll
((
checkboxes
.
length
==
$
(
checkboxes
).
filter
(
'
:checked
'
).
length
));
// Set the title to the current action.
selectAll
.
attr
(
'
title
'
,
selectAll
[
0
].
checked
?
strings
.
selectNone
:
strings
.
selectAll
);
// Keep track of the last checked checkbox.
// Keep track of the last checked checkbox.
lastChecked
=
e
.
target
;
lastChecked
=
e
.
target
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment