? simpletestBehaviorFix.patch Index: simpletest.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/Attic/simpletest.js,v retrieving revision 1.2.4.5 diff -u -p -r1.2.4.5 simpletest.js --- simpletest.js 5 Sep 2009 13:34:10 -0000 1.2.4.5 +++ simpletest.js 25 Nov 2009 17:15:01 -0000 @@ -10,55 +10,57 @@ Drupal.behaviors.simpleTestMenuCollapse = function() { var timeout = null; // Adds expand-collapse functionality. - $('div.simpletest-image').each(function () { + $('div.simpletest-image:not(.simpletest-processed)').each(function () { + $(this).addClass('simpletest-processed'); + // direction = settings.simpleTest[$(this).attr('id')].imageDirection; // $(this).html(settings.simpleTest.images[direction]); direction = Drupal.settings.simpleTest[$(this).attr('id')].imageDirection; $(this).html(Drupal.settings.simpleTest.images[direction]); - }); - // Adds group toggling functionality to arrow images. - $('div.simpletest-image').click(function () { -// var trs = $(this).parents('tbody').children('.' + settings.simpleTest[this.id].testClass); -// var direction = settings.simpleTest[this.id].imageDirection; - var trs = $(this).parents('tbody').children('.' + Drupal.settings.simpleTest[this.id].testClass); - var direction = Drupal.settings.simpleTest[this.id].imageDirection; - var row = direction ? trs.size() - 1 : 0; - - // If clicked in the middle of expanding a group, stop so we can switch directions. - if (timeout) { - clearTimeout(timeout); - } + // Adds group toggling functionality to arrow images. + $(this).click(function () { + // var trs = $(this).parents('tbody').children('.' + settings.simpleTest[this.id].testClass); + // var direction = settings.simpleTest[this.id].imageDirection; + var trs = $(this).parents('tbody').children('.' + Drupal.settings.simpleTest[this.id].testClass); + var direction = Drupal.settings.simpleTest[this.id].imageDirection; + var row = direction ? trs.size() - 1 : 0; + + // If clicked in the middle of expanding a group, stop so we can switch directions. + if (timeout) { + clearTimeout(timeout); + } - // Function to toggle an individual row according to the current direction. - // We set a timeout of 20 ms until the next row will be shown/hidden to - // create a sliding effect. - function rowToggle() { - if (direction) { - if (row >= 0) { - $(trs[row]).hide(); - row--; - timeout = setTimeout(rowToggle, 20); + // Function to toggle an individual row according to the current direction. + // We set a timeout of 20 ms until the next row will be shown/hidden to + // create a sliding effect. + function rowToggle() { + if (direction) { + if (row >= 0) { + $(trs[row]).hide(); + row--; + timeout = setTimeout(rowToggle, 20); + } } - } - else { - if (row < trs.size()) { - $(trs[row]).removeClass('js-hide').show(); - row++; - timeout = setTimeout(rowToggle, 20); + else { + if (row < trs.size()) { + $(trs[row]).removeClass('js-hide').show(); + row++; + timeout = setTimeout(rowToggle, 20); + } } } - } - // Kick-off the toggling upon a new click. - rowToggle(); + // Kick-off the toggling upon a new click. + rowToggle(); - // Toggle the arrow image next to the test group title. -// $(this).html(settings.simpleTest.images[(direction ? 0 : 1)]); -// settings.simpleTest[this.id].imageDirection = !direction; - $(this).html(Drupal.settings.simpleTest.images[(direction ? 0 : 1)]); - Drupal.settings.simpleTest[this.id].imageDirection = !direction; + // Toggle the arrow image next to the test group title. + // $(this).html(settings.simpleTest.images[(direction ? 0 : 1)]); + // settings.simpleTest[this.id].imageDirection = !direction; + $(this).html(Drupal.settings.simpleTest.images[(direction ? 0 : 1)]); + Drupal.settings.simpleTest[this.id].imageDirection = !direction; + }); }); // } }; @@ -70,7 +72,8 @@ Drupal.behaviors.simpleTestMenuCollapse //Drupal.behaviors.simpleTestSelectAll = { // attach: function (context, settings) { Drupal.behaviors.simpleTestSelectAll = function() { - $('td.simpletest-select-all').each(function () { + $('td.simpletest-select-all:not(.simpletest-processed)').each(function () { + $(this).addClass('simpletest-processed'); // var testCheckboxes = settings.simpleTest['simpletest-test-group-' + $(this).attr('id')].testNames; var testCheckboxes = Drupal.settings.simpleTest['simpletest-test-group-' + $(this).attr('id')].testNames; var groupCheckbox = $('');