Skip to content
Snippets Groups Projects
Commit f2e25f60 authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Issue #1880798 by droplet: Fixed tableselect.js performances.

parent fbfaa3a4
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -11,7 +11,7 @@ Drupal.behaviors.tableSelect = {
Drupal.tableSelect = function () {
// Do not add a "Select all" checkbox if there are no rows with checkboxes in the table
if ($(this).find('td input:checkbox').length === 0) {
if ($(this).find('td input[type="checkbox"]').length === 0) {
return;
}
......@@ -21,7 +21,7 @@ Drupal.tableSelect = function () {
var strings = { 'selectAll': Drupal.t('Select all rows in this table'), 'selectNone': Drupal.t('Deselect all rows in this table') };
var updateSelectAll = function (state) {
// Update table's select-all checkbox (and sticky header's if available).
$table.prev('table.sticky-header').andSelf().find('th.select-all input:checkbox').each(function() {
$table.prev('table.sticky-header').andSelf().find('th.select-all input[type="checkbox"]').each(function() {
$(this).attr('title', state ? strings.selectNone : strings.selectAll);
this.checked = state;
});
......@@ -29,7 +29,7 @@ Drupal.tableSelect = function () {
// Find all <th> with class select-all, and insert the check all checkbox.
$table.find('th.select-all').prepend($('<input type="checkbox" class="form-checkbox" />').attr('title', strings.selectAll)).click(function (event) {
if ($(event.target).is('input:checkbox')) {
if ($(event.target).is('input[type="checkbox"]')) {
// Loop through all checkboxes and set their state to the select all checkbox' state.
checkboxes.each(function () {
this.checked = event.target.checked;
......@@ -42,7 +42,7 @@ Drupal.tableSelect = function () {
});
// For each of the checkboxes within the table that are not disabled.
checkboxes = $table.find('td input:checkbox:enabled').click(function (e) {
checkboxes = $table.find('td input[type="checkbox"]:enabled').click(function (e) {
// Either add or remove the selected class based on the state of the check all checkbox.
$(this).closest('tr').toggleClass('selected', this.checked);
......@@ -75,7 +75,7 @@ Drupal.tableSelectRange = function (from, to, state) {
$i = $(i);
// Either add or remove the selected class based on the state of the target checkbox.
$i.toggleClass('selected', state);
$i.find('input:checkbox').attr('checked', state);
$i.find('input[type="checkbox"]').attr('checked', state);
if (to.nodeType) {
// If we are at the end of the range, stop.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment