annotate core/modules/simpletest/simpletest.js @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 /**
Chris@0 2 * DO NOT EDIT THIS FILE.
Chris@0 3 * See the following change record for more information,
Chris@0 4 * https://www.drupal.org/node/2815083
Chris@0 5 * @preserve
Chris@0 6 **/
Chris@0 7
Chris@0 8 (function ($, Drupal, drupalSettings) {
Chris@0 9 Drupal.behaviors.simpleTestGroupCollapse = {
Chris@0 10 attach: function attach(context) {
Chris@0 11 $(context).find('.simpletest-group').once('simpletest-group-collapse').each(function () {
Chris@0 12 var $group = $(this);
Chris@0 13 var $image = $group.find('.simpletest-image');
Chris@0 14 $image.html(drupalSettings.simpleTest.images[0]).on('click', function () {
Chris@0 15 var $tests = $group.nextUntil('.simpletest-group');
Chris@0 16 var expand = !$group.hasClass('expanded');
Chris@0 17 $group.toggleClass('expanded', expand);
Chris@0 18 $tests.toggleClass('js-hide', !expand);
Chris@0 19 $image.html(drupalSettings.simpleTest.images[+expand]);
Chris@0 20 });
Chris@0 21 });
Chris@0 22 }
Chris@0 23 };
Chris@0 24
Chris@0 25 Drupal.behaviors.simpleTestSelectAll = {
Chris@0 26 attach: function attach(context) {
Chris@0 27 $(context).find('.simpletest-group').once('simpletest-group-select-all').each(function () {
Chris@0 28 var $group = $(this);
Chris@0 29 var $cell = $group.find('.simpletest-group-select-all');
Chris@0 30 var $groupCheckbox = $('<input type="checkbox" id="' + $cell.attr('id') + '-group-select-all" class="form-checkbox" />');
Chris@0 31 var $testCheckboxes = $group.nextUntil('.simpletest-group').find('input[type=checkbox]');
Chris@0 32 $cell.append($groupCheckbox);
Chris@0 33
Chris@0 34 $groupCheckbox.on('change', function () {
Chris@0 35 var checked = $(this).prop('checked');
Chris@0 36 $testCheckboxes.prop('checked', checked);
Chris@0 37 });
Chris@0 38
Chris@0 39 function updateGroupCheckbox() {
Chris@0 40 var allChecked = true;
Chris@0 41 $testCheckboxes.each(function () {
Chris@0 42 if (!$(this).prop('checked')) {
Chris@0 43 allChecked = false;
Chris@0 44 return false;
Chris@0 45 }
Chris@0 46 });
Chris@0 47 $groupCheckbox.prop('checked', allChecked);
Chris@0 48 }
Chris@0 49
Chris@0 50 $testCheckboxes.on('change', updateGroupCheckbox);
Chris@0 51 });
Chris@0 52 }
Chris@0 53 };
Chris@0 54
Chris@0 55 Drupal.behaviors.simpletestTableFilterByText = {
Chris@0 56 attach: function attach(context) {
Chris@0 57 var $input = $('input.table-filter-text').once('table-filter-text');
Chris@0 58 var $table = $($input.attr('data-table'));
Chris@0 59 var $rows = void 0;
Chris@0 60 var searched = false;
Chris@0 61
Chris@0 62 function filterTestList(e) {
Chris@0 63 var query = $(e.target).val().toLowerCase();
Chris@0 64
Chris@0 65 function showTestRow(index, row) {
Chris@0 66 var $row = $(row);
Chris@0 67 var $sources = $row.find('.table-filter-text-source');
Chris@0 68 var textMatch = $sources.text().toLowerCase().indexOf(query) !== -1;
Chris@0 69 $row.closest('tr').toggle(textMatch);
Chris@0 70 }
Chris@0 71
Chris@0 72 if (query.length >= 3) {
Chris@0 73 searched = true;
Chris@0 74 $('#simpletest-form-table thead th.select-all input').hide();
Chris@0 75
Chris@0 76 $rows.each(showTestRow);
Chris@0 77 } else if (searched) {
Chris@0 78 searched = false;
Chris@0 79 $('#simpletest-form-table thead th.select-all input').show();
Chris@0 80
Chris@0 81 $rows.css('display', '');
Chris@0 82 }
Chris@0 83 }
Chris@0 84
Chris@0 85 if ($table.length) {
Chris@0 86 $rows = $table.find('tbody tr');
Chris@0 87 $input.trigger('focus').on('keyup', Drupal.debounce(filterTestList, 200));
Chris@0 88 }
Chris@0 89 }
Chris@0 90 };
Chris@0 91 })(jQuery, Drupal, drupalSettings);