/[drupal]/drupal/modules/simpletest/simpletest.js
ViewVC logotype

Contents of /drupal/modules/simpletest/simpletest.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (show annotations) (download) (as text)
Mon Apr 27 20:19:37 2009 UTC (7 months ago) by webchick
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, DRUPAL-7-0-UNSTABLE-8, DRUPAL-7-0-UNSTABLE-9, DRUPAL-7-0-UNSTABLE-7, HEAD
Changes since 1.10: +11 -11 lines
File MIME type: text/javascript
#444402 follow-up by kkaefer: Fix autocomplete, enforce code style for anonymous JS functions.
1 // $Id: simpletest.js,v 1.10 2009/04/26 19:18:46 webchick Exp $
2 (function ($) {
3
4 /**
5 * Add the cool table collapsing on the testing overview page.
6 */
7 Drupal.behaviors.simpleTestMenuCollapse = {
8 attach: function (context, settings) {
9 var timeout = null;
10 // Adds expand-collapse functionality.
11 $('div.simpletest-image').each(function () {
12 direction = settings.simpleTest[$(this).attr('id')].imageDirection;
13 $(this).html(settings.simpleTest.images[direction]);
14 });
15
16 // Adds group toggling functionality to arrow images.
17 $('div.simpletest-image').click(function () {
18 var trs = $(this).parents('tbody').children('.' + settings.simpleTest[this.id].testClass);
19 var direction = settings.simpleTest[this.id].imageDirection;
20 var row = direction ? trs.size() - 1 : 0;
21
22 // If clicked in the middle of expanding a group, stop so we can switch directions.
23 if (timeout) {
24 clearTimeout(timeout);
25 }
26
27 // Function to toggle an individual row according to the current direction.
28 // We set a timeout of 20 ms until the next row will be shown/hidden to
29 // create a sliding effect.
30 function rowToggle() {
31 if (direction) {
32 if (row >= 0) {
33 $(trs[row]).hide();
34 row--;
35 timeout = setTimeout(rowToggle, 20);
36 }
37 }
38 else {
39 if (row < trs.size()) {
40 $(trs[row]).removeClass('js-hide').show();
41 row++;
42 timeout = setTimeout(rowToggle, 20);
43 }
44 }
45 }
46
47 // Kick-off the toggling upon a new click.
48 rowToggle();
49
50 // Toggle the arrow image next to the test group title.
51 $(this).html(settings.simpleTest.images[(direction ? 0 : 1)]);
52 settings.simpleTest[this.id].imageDirection = !direction;
53
54 });
55 }
56 };
57
58 /**
59 * Select/deselect all the inner checkboxes when the outer checkboxes are
60 * selected/deselected.
61 */
62 Drupal.behaviors.simpleTestSelectAll = {
63 attach: function (context, settings) {
64 $('td.simpletest-select-all').each(function () {
65 var testCheckboxes = settings.simpleTest['simpletest-test-group-' + $(this).attr('id')].testNames;
66 var groupCheckbox = $('<input type="checkbox" class="form-checkbox" id="' + $(this).attr('id') + '-select-all" />');
67
68 // Each time a single-test checkbox is checked or unchecked, make sure
69 // that the associated group checkbox gets the right state too.
70 var updateGroupCheckbox = function () {
71 var checkedTests = 0;
72 for (var i = 0; i < testCheckboxes.length; i++) {
73 $('#' + testCheckboxes[i]).each(function () {
74 if (($(this).attr('checked'))) {
75 checkedTests++;
76 }
77 });
78 }
79 $(groupCheckbox).attr('checked', (checkedTests == testCheckboxes.length));
80 };
81
82 // Have the single-test checkboxes follow the group checkbox.
83 groupCheckbox.change(function () {
84 var checked = !!($(this).attr('checked'));
85 for (var i = 0; i < testCheckboxes.length; i++) {
86 $('#' + testCheckboxes[i]).attr('checked', checked);
87 }
88 });
89
90 // Have the group checkbox follow the single-test checkboxes.
91 for (var i = 0; i < testCheckboxes.length; i++) {
92 $('#' + testCheckboxes[i]).change(function () {
93 updateGroupCheckbox();
94 });
95 }
96
97 // Initialize status for the group checkbox correctly.
98 updateGroupCheckbox();
99 $(this).append(groupCheckbox);
100 });
101 }
102 };
103
104 })(jQuery);

  ViewVC Help
Powered by ViewVC 1.1.2