1 |
efrain |
1 |
M.gradereport_singleview = {};
|
|
|
2 |
|
|
|
3 |
M.gradereport_singleview.init = function(Y) {
|
|
|
4 |
if (this.initialised) {
|
|
|
5 |
return;
|
|
|
6 |
}
|
|
|
7 |
this.initialised = true;
|
|
|
8 |
|
|
|
9 |
var getColumnIndex = function(cell) {
|
|
|
10 |
var rowNode = cell.ancestor('tr');
|
|
|
11 |
if (!rowNode || !cell) {
|
|
|
12 |
return;
|
|
|
13 |
}
|
|
|
14 |
var cells = rowNode.all('td, th');
|
|
|
15 |
return cells.indexOf(cell);
|
|
|
16 |
},
|
|
|
17 |
getNextCell = function(cell) {
|
|
|
18 |
var n = cell || document.activeElement,
|
|
|
19 |
next = n.next('td.cell, th.cell');
|
|
|
20 |
if (!next) {
|
|
|
21 |
return null;
|
|
|
22 |
}
|
|
|
23 |
// Continue on until we find a navigable cell
|
|
|
24 |
if (!next || !Y.one(next).one('input:not([type="hidden"]):not([disabled="DISABLED"]), select, a')) {
|
|
|
25 |
return getNextCell(next);
|
|
|
26 |
}
|
|
|
27 |
return next;
|
|
|
28 |
},
|
|
|
29 |
getPrevCell = function(cell) {
|
|
|
30 |
var n = cell || document.activeElement,
|
|
|
31 |
next = n.previous('td.cell, th.cell');
|
|
|
32 |
if (!next) {
|
|
|
33 |
return null;
|
|
|
34 |
}
|
|
|
35 |
// Continue on until we find a navigable cell
|
|
|
36 |
if (!Y.one(next).one('input:not([type="hidden"]):not([disabled="DISABLED"]), select, a')) {
|
|
|
37 |
return getPrevCell(next);
|
|
|
38 |
}
|
|
|
39 |
return next;
|
|
|
40 |
},
|
|
|
41 |
getAboveCell = function(cell) {
|
|
|
42 |
var n = cell || document.activeElement,
|
|
|
43 |
tr = n.ancestor('tr').previous('tr'),
|
|
|
44 |
columnIndex = getColumnIndex(n),
|
|
|
45 |
next = null;
|
|
|
46 |
if (tr) {
|
|
|
47 |
next = tr.all('td, th').item(columnIndex);
|
|
|
48 |
} else {
|
|
|
49 |
return null;
|
|
|
50 |
}
|
|
|
51 |
// Continue on until we find a navigable cell
|
|
|
52 |
if (!Y.one(next).one('input:not([type="hidden"]):not([disabled="DISABLED"]), select, a')) {
|
|
|
53 |
return getAboveCell(next);
|
|
|
54 |
}
|
|
|
55 |
return next;
|
|
|
56 |
},
|
|
|
57 |
getBelowCell = function(cell) {
|
|
|
58 |
var n = cell || document.activeElement,
|
|
|
59 |
tr = n.ancestor('tr').next('tr'),
|
|
|
60 |
columnIndex = getColumnIndex(n),
|
|
|
61 |
next = null;
|
|
|
62 |
if (tr) {
|
|
|
63 |
next = tr.all('td, th').item(columnIndex);
|
|
|
64 |
} else {
|
|
|
65 |
return null;
|
|
|
66 |
}
|
|
|
67 |
// Continue on until we find a navigable cell
|
|
|
68 |
if (!Y.one(next).one('input:not([type="hidden"]):not([disabled="DISABLED"]), select, a')) {
|
|
|
69 |
return getBelowCell(next);
|
|
|
70 |
}
|
|
|
71 |
return next;
|
|
|
72 |
};
|
|
|
73 |
|
|
|
74 |
// Add ctrl+arrow controls for navigation
|
|
|
75 |
Y.one(Y.config.doc.body).delegate('key', function(e) {
|
|
|
76 |
e.preventDefault();
|
|
|
77 |
e.stopPropagation();
|
|
|
78 |
var next = null;
|
|
|
79 |
switch (e.keyCode) {
|
|
|
80 |
case 37:
|
|
|
81 |
next = getPrevCell(this.ancestor('td, th'));
|
|
|
82 |
break;
|
|
|
83 |
case 38:
|
|
|
84 |
next = getAboveCell(this.ancestor('td, th'));
|
|
|
85 |
break;
|
|
|
86 |
case 39:
|
|
|
87 |
next = getNextCell(this.ancestor('td, th'));
|
|
|
88 |
break;
|
|
|
89 |
case 40:
|
|
|
90 |
next = getBelowCell(this.ancestor('td, th'));
|
|
|
91 |
break;
|
|
|
92 |
}
|
|
|
93 |
if (next) {
|
|
|
94 |
Y.one(next).one('input:not([type="hidden"]):not([disabled="DISABLED"]), select, a').focus();
|
|
|
95 |
}
|
|
|
96 |
return;
|
|
|
97 |
}, 'down:37,38,39,40+ctrl', 'table input, table select, table a');
|
|
|
98 |
|
|
|
99 |
// Override Toggle.
|
|
|
100 |
Y.all('input[name^=override_]').each(function(input) {
|
|
|
101 |
input.on('change', function() {
|
|
|
102 |
var checked = input.getDOMNode().checked;
|
|
|
103 |
var names = input.getAttribute('name').split("_");
|
|
|
104 |
|
|
|
105 |
var itemid = names[1];
|
|
|
106 |
var userid = names[2];
|
|
|
107 |
|
|
|
108 |
var interest = '_' + itemid + '_' + userid;
|
|
|
109 |
|
|
|
110 |
Y.all('input[name$=' + interest + ']').filter('input[data-uielement=text]').each(function(text) {
|
|
|
111 |
text.getDOMNode().disabled = !checked;
|
|
|
112 |
});
|
|
|
113 |
// deal with scales that are not text... UCSB
|
|
|
114 |
Y.all('select[name$=' + interest + ']').each(function(select) {
|
|
|
115 |
select.getDOMNode().disabled = !checked;
|
|
|
116 |
});
|
|
|
117 |
});
|
|
|
118 |
});
|
|
|
119 |
};
|