X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsimpletest%2Fsimpletest.es6.js;h=7e65c12f496801a5b9981b1fcb7a51add5f97c09;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=42763b24c51cba7fcbb0361fbaf919db4b7f887e;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/web/core/modules/simpletest/simpletest.es6.js b/web/core/modules/simpletest/simpletest.es6.js index 42763b24c..7e65c12f4 100644 --- a/web/core/modules/simpletest/simpletest.es6.js +++ b/web/core/modules/simpletest/simpletest.es6.js @@ -3,7 +3,7 @@ * Simpletest behaviors. */ -(function ($, Drupal, drupalSettings) { +(function($, Drupal, drupalSettings) { /** * Collapses table rows followed by group rows on the test listing page. * @@ -14,19 +14,20 @@ */ Drupal.behaviors.simpleTestGroupCollapse = { attach(context) { - $(context).find('.simpletest-group').once('simpletest-group-collapse').each(function () { - const $group = $(this); - const $image = $group.find('.simpletest-image'); - $image - .html(drupalSettings.simpleTest.images[0]) - .on('click', () => { + $(context) + .find('.simpletest-group') + .once('simpletest-group-collapse') + .each(function() { + const $group = $(this); + const $image = $group.find('.simpletest-image'); + $image.html(drupalSettings.simpleTest.images[0]).on('click', () => { const $tests = $group.nextUntil('.simpletest-group'); const expand = !$group.hasClass('expanded'); $group.toggleClass('expanded', expand); $tests.toggleClass('js-hide', !expand); $image.html(drupalSettings.simpleTest.images[+expand]); }); - }); + }); }, }; @@ -40,33 +41,42 @@ */ Drupal.behaviors.simpleTestSelectAll = { attach(context) { - $(context).find('.simpletest-group').once('simpletest-group-select-all').each(function () { - const $group = $(this); - const $cell = $group.find('.simpletest-group-select-all'); - const $groupCheckbox = $(``); - const $testCheckboxes = $group.nextUntil('.simpletest-group').find('input[type=checkbox]'); - $cell.append($groupCheckbox); - - // Toggle the test checkboxes when the group checkbox is toggled. - $groupCheckbox.on('change', function () { - const checked = $(this).prop('checked'); - $testCheckboxes.prop('checked', checked); - }); + $(context) + .find('.simpletest-group') + .once('simpletest-group-select-all') + .each(function() { + const $group = $(this); + const $cell = $group.find('.simpletest-group-select-all'); + const $groupCheckbox = $( + ``, + ); + const $testCheckboxes = $group + .nextUntil('.simpletest-group') + .find('input[type=checkbox]'); + $cell.append($groupCheckbox); - // Update the group checkbox when a test checkbox is toggled. - function updateGroupCheckbox() { - let allChecked = true; - $testCheckboxes.each(function () { - if (!$(this).prop('checked')) { - allChecked = false; - return false; - } + // Toggle the test checkboxes when the group checkbox is toggled. + $groupCheckbox.on('change', function() { + const checked = $(this).prop('checked'); + $testCheckboxes.prop('checked', checked); }); - $groupCheckbox.prop('checked', allChecked); - } - $testCheckboxes.on('change', updateGroupCheckbox); - }); + // Update the group checkbox when a test checkbox is toggled. + function updateGroupCheckbox() { + let allChecked = true; + $testCheckboxes.each(function() { + if (!$(this).prop('checked')) { + allChecked = false; + return false; + } + }); + $groupCheckbox.prop('checked', allChecked); + } + + $testCheckboxes.on('change', updateGroupCheckbox); + }); }, }; @@ -90,12 +100,18 @@ let searched = false; function filterTestList(e) { - const query = $(e.target).val().toLowerCase(); + const query = $(e.target) + .val() + .toLowerCase(); function showTestRow(index, row) { const $row = $(row); const $sources = $row.find('.table-filter-text-source'); - const textMatch = $sources.text().toLowerCase().indexOf(query) !== -1; + const textMatch = + $sources + .text() + .toLowerCase() + .indexOf(query) !== -1; $row.closest('tr').toggle(textMatch); } @@ -119,8 +135,10 @@ if ($table.length) { $rows = $table.find('tbody tr'); - $input.trigger('focus').on('keyup', Drupal.debounce(filterTestList, 200)); + $input + .trigger('focus') + .on('keyup', Drupal.debounce(filterTestList, 200)); } }, }; -}(jQuery, Drupal, drupalSettings)); +})(jQuery, Drupal, drupalSettings);