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

- Patch #250056 by dmitrig01: if all the checkboxes in a checkbox group are...

- Patch #250056 by dmitrig01: if all the checkboxes in a checkbox group are checked on page load, the check all box isn't checked, which is should be (because all sub-boxes are checked).
parent e19dfc75
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ Drupal.behaviors.simpleTestMenuCollapse = function() { ...@@ -29,7 +29,7 @@ Drupal.behaviors.simpleTestMenuCollapse = function() {
} }
Drupal.behaviors.simpleTestSelectAll = function() { Drupal.behaviors.simpleTestSelectAll = function() {
$('td.simpletest-select-all').each(function() { $('td.simpletest-select-all').each(function() {
var checkboxes = Drupal.settings.simpleTest['simpletest-test-group-'+ $(this).attr('id')].testNames, var checkboxes = Drupal.settings.simpleTest['simpletest-test-group-'+ $(this).attr('id')].testNames, totalCheckboxes = 0,
checkbox = $('<input type="checkbox" class="form-checkbox" id="'+ $(this).attr('id') +'-select-all" />').change(function() { checkbox = $('<input type="checkbox" class="form-checkbox" id="'+ $(this).attr('id') +'-select-all" />').change(function() {
var checked = !!($(this).attr('checked')); var checked = !!($(this).attr('checked'));
for (var i = 0; i < checkboxes.length; i++) { for (var i = 0; i < checkboxes.length; i++) {
...@@ -39,7 +39,7 @@ Drupal.behaviors.simpleTestSelectAll = function() { ...@@ -39,7 +39,7 @@ Drupal.behaviors.simpleTestSelectAll = function() {
}).data('simpletest-checked-tests', 0); }).data('simpletest-checked-tests', 0);
var self = $(this); var self = $(this);
for (var i = 0; i < checkboxes.length; i++) { for (var i = 0; i < checkboxes.length; i++) {
$('#'+ checkboxes[i]).change(function() { if ($('#'+ checkboxes[i]).change(function() {
if (checkbox.attr('checked') == 'checked') { if (checkbox.attr('checked') == 'checked') {
checkbox.attr('checked', ''); checkbox.attr('checked', '');
} }
...@@ -51,7 +51,12 @@ Drupal.behaviors.simpleTestSelectAll = function() { ...@@ -51,7 +51,12 @@ Drupal.behaviors.simpleTestSelectAll = function() {
else { else {
checkbox.attr('checked', ''); checkbox.attr('checked', '');
} }
}); }).attr('checked') == 'checked') {
totalCheckboxes++;
}
}
if (totalCheckboxes == checkboxes.length) {
$(checkbox).attr('checked', 'checked');
} }
$(this).append(checkbox); $(this).append(checkbox);
}); });
......
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