forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.js
58 lines (50 loc) · 1.55 KB
/
module.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
M.core_user = {};
M.core_user.init_participation = function(Y) {
Y.on('change', function() {
var action = Y.one('#formactionid');
if (action.get('value') == '') {
return;
}
var ok = false;
Y.all('input.usercheckbox').each(function() {
if (this.get('checked')) {
ok = true;
}
});
if (!ok) {
// no checkbox selected
return;
}
Y.one('#participantsform').submit();
}, '#formactionid');
Y.on('click', function(e) {
// Presence of a show all link indicates we should redirect to
// a page with all users listed and checked, otherwise just check
// those already shown.
var showallink = this.getAttribute('data-showallink');
if (showallink) {
window.location = showallink;
}
Y.all('input.usercheckbox').each(function() {
this.set('checked', 'checked');
});
}, '#checkall, #checkallonpage');
Y.on('click', function(e) {
Y.all('input.usercheckbox').each(function() {
this.set('checked', '');
});
}, '#checknone');
};
M.core_user.init_tree = function(Y, expand_all, htmlid) {
Y.use('yui2-treeview', function(Y) {
var tree = new Y.YUI2.widget.TreeView(htmlid);
tree.subscribe("clickEvent", function(node, event) {
// we want normal clicking which redirects to url
return false;
});
if (expand_all) {
tree.expandAll();
}
tree.render();
});
};