123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- (function ($) {
- Drupal.behaviors.simpleTestMenuCollapse = {
- attach: function (context, settings) {
- var timeout = null;
-
- $('div.simpletest-image').once('simpletest-image', function () {
- var $this = $(this);
- var direction = settings.simpleTest[this.id].imageDirection;
- $this.html(settings.simpleTest.images[direction]);
-
- $this.click(function () {
- var trs = $this.closest('tbody').children('.' + settings.simpleTest[this.id].testClass);
- var direction = settings.simpleTest[this.id].imageDirection;
- var row = direction ? trs.length - 1 : 0;
-
- if (timeout) {
- clearTimeout(timeout);
- }
-
-
-
- function rowToggle() {
- if (direction) {
- if (row >= 0) {
- $(trs[row]).hide();
- row--;
- timeout = setTimeout(rowToggle, 20);
- }
- }
- else {
- if (row < trs.length) {
- $(trs[row]).removeClass('js-hide').show();
- row++;
- timeout = setTimeout(rowToggle, 20);
- }
- }
- }
-
- rowToggle();
-
- $this.html(settings.simpleTest.images[(direction ? 0 : 1)]);
- settings.simpleTest[this.id].imageDirection = !direction;
- });
- });
- }
- };
- Drupal.behaviors.simpleTestSelectAll = {
- attach: function (context, settings) {
- $('td.simpletest-select-all').once('simpletest-select-all', function () {
- var testCheckboxes = settings.simpleTest['simpletest-test-group-' + $(this).attr('id')].testNames;
- var groupCheckbox = $('<input type="checkbox" class="form-checkbox" id="' + $(this).attr('id') + '-select-all" />');
-
-
- var updateGroupCheckbox = function () {
- var checkedTests = 0;
- for (var i = 0; i < testCheckboxes.length; i++) {
- $('#' + testCheckboxes[i]).each(function () {
- if (($(this).attr('checked'))) {
- checkedTests++;
- }
- });
- }
- $(groupCheckbox).attr('checked', (checkedTests == testCheckboxes.length));
- };
-
- groupCheckbox.change(function () {
- var checked = !!($(this).attr('checked'));
- for (var i = 0; i < testCheckboxes.length; i++) {
- $('#' + testCheckboxes[i]).attr('checked', checked);
- }
- });
-
- for (var i = 0; i < testCheckboxes.length; i++) {
- $('#' + testCheckboxes[i]).change(function () {
- updateGroupCheckbox();
- });
- }
-
- updateGroupCheckbox();
- $(this).append(groupCheckbox);
- });
- }
- };
- })(jQuery);
|