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

Contents of /contributions/modules/code_coverage/code_coverage.js

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


Revision 1.3 - (show annotations) (download) (as text)
Sat Jun 28 23:33:49 2008 UTC (16 months, 4 weeks ago) by cwgordon7
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +19 -2 lines
File MIME type: text/javascript
Various updates to awesomify the module.
1 // $Id: code_coverage.js,v 1.2 2008/06/27 23:22:19 cwgordon7 Exp $
2
3 Drupal.behaviors.codeCoverageTableSort = function() {
4 $('table > thead > tr > th').click(function() {
5 var th = this;
6 var i = 0;
7 while (th = th.previousSibling) {
8 i++;
9 }
10 var tableSort = function(a, b) {
11 var i = Drupal.settings.codeCoverageTableSortIndex;
12 var direction = Drupal.settings.codeCoverageTableSortDirection;
13 a = $(a).find('td:nth-child(' + (i + 1) + ')').text();
14 b = $(b).find('td:nth-child(' + (i + 1) + ')').text();
15 if (i == 0) {
16 var array = [a, b];
17 array.sort();
18 if (direction[i]) {
19 return array[0] == a;
20 }
21 else {
22 return array[0] != a;
23 }
24 }
25 else {
26 if (i == 3) {
27 a = a.substr(0, a.length - 1);
28 b = b.substr(0, b.length - 1);
29 }
30 if (direction[i]) {
31 return a - b;
32 }
33 else {
34 return b - a;
35 }
36 }
37 };
38 Drupal.settings.codeCoverageTableSortIndex = i;
39 Drupal.settings.codeCoverageTableSortDirection[i] = Drupal.settings.codeCoverageTableSortDirection[i] ? false : true;
40 var sorted = $('table > tbody > tr:not(.code-coverage-overview)').get().sort(tableSort);
41 $('th > img').remove();
42 $(this).append('<img src="' + Drupal.settings.basePath + 'misc/arrow-' + (Drupal.settings.codeCoverageTableSortDirection[i] ? 'asc' : 'desc') + '.png />');
43 var tr;
44 var text = '';
45 var even = true;
46 for (tr in sorted) {
47 text = text + '<tr class="' + (even ? 'even' : 'odd') + ' ' + sorted[tr].className.replace(/even/, '').replace(/odd/, '') + '">' + sorted[tr].innerHTML + '</tr>';
48 even = !even;
49 }
50 $('table > tbody > tr:not(.code-coverage-overview)').remove();
51 $('table > tbody').append(text);
52 });
53 };
54
55 Drupal.behaviors.codeCoverageToggleDisabled = function() {
56 if ($('#edit-code-coverage-all').is(':checked')) {
57 $('#edit-code-coverage-files-wrapper').hide();
58 }
59 else {
60 $('#edit-code-coverage-files-wrapper').show();
61 }
62 $('#edit-code-coverage-all').change(function() {
63 if ($('#edit-code-coverage-all').is(':checked')) {
64 $('#edit-code-coverage-files-wrapper').slideUp();
65 }
66 else {
67 $('#edit-code-coverage-files-wrapper').slideDown();
68 }
69 });
70 };
71
72 Drupal.settings.codeCoverageTableSortDirection = [];

  ViewVC Help
Powered by ViewVC 1.1.2