/[drupal]/contributions/modules/uts/uts.js
ViewVC logotype

Contents of /contributions/modules/uts/uts.js

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


Revision 1.3 - (show annotations) (download) (as text)
Thu Jan 15 07:21:55 2009 UTC (10 months, 1 week ago) by boombatower
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-RC1, DRUPAL-6--1-0, HEAD
Changes since 1.2: +5 -6 lines
File MIME type: text/javascript
#358634: Improve Link to Graphs on Study dashboard.
1 // $Id: uts.js,v 1.2 2008/12/28 07:02:42 boombatower Exp $
2
3 /**
4 * Add collapse/expand triggers to the dashboard rows.
5 *
6 * @see Modified from Drupal 7 core simpletest.js.
7 */
8 Drupal.behaviors.utsMenuCollapse = function() {
9 var timeout = null;
10
11 // Adds expand-collapse functionality.
12 $('div.uts-image').each(function() {
13 direction = Drupal.settings.uts[$(this).attr('id')].imageDirection;
14 $(this).html(Drupal.settings.uts.images[direction]);
15 });
16
17 // Adds group toggling functionality to arrow images.
18 $('div.uts-image').click(function() {
19 var trs = $(this).parents('tbody').children('.' + this.id + '-task');
20 var direction = Drupal.settings.uts[this.id].imageDirection;
21 var row = direction ? trs.size() - 1 : 0;
22
23 // If clicked in the middle of expanding a group, stop so we can switch directions.
24 if (timeout) {
25 clearTimeout(timeout);
26 }
27
28 // Function to toggle an individual row according to the current direction.
29 // We set a timeout of 20 ms until the next row will be shown/hidden to
30 // create a sliding effect.
31 function rowToggle() {
32 if (direction) {
33 if (row >= 0) {
34 $(trs[row]).hide();
35 row--;
36 timeout = setTimeout(rowToggle, 20);
37 }
38 }
39 else {
40 if (row < trs.size()) {
41 $(trs[row]).removeClass('js-hide').show();
42 row++;
43 timeout = setTimeout(rowToggle, 20);
44 }
45 }
46 }
47
48 // Kick-off the toggling upon a new click.
49 rowToggle();
50
51 // Toggle the arrow image next to the test group title.
52 $(this).html(Drupal.settings.uts.images[(direction ? 0 : 1)]);
53 Drupal.settings.uts[this.id].imageDirection = !direction;
54 });
55 };
56
57 /**
58 * Expand/Collapse the task details on the analysis page.
59 */
60 Drupal.behaviors.utsTaskAccordion = function() {
61 $('div.uts-task-open').each(function() {
62 $(this).children('span').html(Drupal.settings.uts.images[0]);
63 });
64
65 $('div.uts-task-open').click(function() {
66 var task = $(this).attr('id').replace('uts-task-open-', '');
67 if ($(this).children('span').children('img:first').attr('title') == $(Drupal.settings.uts.images[0]).attr('title')) {
68 // Expand details.
69 $(this).children('span').html(Drupal.settings.uts.images[1]);
70 $('div#uts-task-' + task).parent().parent().css('display', '');
71 $('div#uts-task-' + task).show('fast');
72 }
73 else {
74 // Collapse details.
75 $(this).children('span').html(Drupal.settings.uts.images[0]);
76 $('div#uts-task-' + task).hide('fast', function() { $('div#uts-task-' + task).parent().parent().css('display', 'none'); });
77 }
78 });
79 };
80
81 /**
82 * Show/Hide the participant comments.
83 */
84 Drupal.behaviors.utsLiveFeedback = function() {
85 $('div.uts-live-feedback-participant').click(function() {
86 // Fade other participant buttons.
87 $(this).parent().children('div.uts-live-feedback-participant').fadeTo('fast', 0.40);
88
89 // Focus current participant button.
90 $(this).fadeTo('fast', 1.0);
91
92 $parent = $(this).parent().parent();
93
94 // Hide all other comments.
95 $parent.children('div.uts-live-feedback-comments').hide('fast');
96
97 // Show the comments that relate to the specified participant.
98 $parent.children('div#uts-comments-' + $(this).text()).show('fast');
99
100 // Create accordion if the comments are being viewed for the first time.
101 $ul = $parent.children('div#uts-comments-' + $(this).text()).find('ul');
102 if (!$ul.hasClass('ui-accordion')) {
103 $parent.children('div#uts-comments-' + $(this).text()).find('ul').accordion();
104 }
105 });
106 };

  ViewVC Help
Powered by ViewVC 1.1.2