simpletest.js 3.1 KB

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