Commit | Line | Data |
---|---|---|
2bd72e30 | 1 | /* |
c2489597 SH |
2 | * To change this template, choose Tools | Templates |
3 | * and open the template in the editor. | |
4 | */ | |
5 | M.core_group = { | |
6 | hoveroverlay : null | |
7 | }; | |
8 | ||
9 | M.core_group.init_hover_events = function(Y, events) { | |
10 | // Prepare the overlay if it hasn't already been created | |
11 | this.hoveroverlay = this.hoveroverlay || (function(){ | |
12 | // New Y.Overlay | |
13 | var overlay = new Y.Overlay({ | |
14 | bodyContent : 'Loading', | |
15 | visible : false, | |
16 | zIndex : 2 | |
17 | }); | |
18 | // Render it against the page | |
19 | overlay.render(Y.one('#page')); | |
20 | return overlay; | |
21 | })(); | |
22 | ||
fef51794 AH |
23 | Y.all('.group_hoverdescription').each(function() { |
24 | var node = this.ancestor(); | |
25 | var id = this.getAttribute('data-groupid'); | |
26 | ||
27 | node.on('mouseenter', function(){ | |
28 | M.core_group.hoveroverlay.set('xy', [this.getX()+(this.get('offsetWidth')/2),this.getY()+this.get('offsetHeight')-5]); | |
29 | M.core_group.hoveroverlay.set("bodyContent", events[id]); | |
30 | M.core_group.hoveroverlay.show(); | |
31 | M.core_group.hoveroverlay.get('boundingBox').setStyle('visibility', 'visible'); | |
32 | }); | |
33 | node.on('mouseleave', function(){ | |
34 | M.core_group.hoveroverlay.hide(); | |
35 | M.core_group.hoveroverlay.get('boundingBox').setStyle('visibility', 'hidden'); | |
36 | }); | |
37 | }); | |
2bd72e30 | 38 | }; |
c2489597 | 39 | |
80db8e8d DC |
40 | M.core_group.init_index = function(Y, wwwroot, courseid) { |
41 | M.core_group.groupsCombo = new UpdatableGroupsCombo(wwwroot, courseid); | |
42 | M.core_group.membersCombo = new UpdatableMembersCombo(wwwroot, courseid); | |
2bd72e30 | 43 | }; |
74b714df ARN |
44 | |
45 | M.core_group.groupslist = function(Y, preventgroupremoval) { | |
46 | var actions = { | |
47 | init : function() { | |
48 | // We need to add check_deletable both on change for the groups, and then call it the first time the page loads | |
49 | Y.one('#groups').on('change', this.check_deletable, this); | |
50 | this.check_deletable(); | |
51 | }, | |
52 | check_deletable : function() { | |
53 | // Ensure that if the 'preventremoval' attribute is set, the delete button is greyed out | |
54 | var candelete = true; | |
55 | var optionselected = false; | |
56 | Y.one('#groups').get('options').each(function(option) { | |
57 | if (option.get('selected')) { | |
58 | optionselected = true; | |
59 | if (option.getAttribute('value') in preventgroupremoval) { | |
60 | candelete = false; | |
61 | } | |
62 | } | |
63 | }, this); | |
64 | var deletebutton = Y.one('#deletegroup'); | |
65 | if (candelete && optionselected) { | |
66 | deletebutton.removeAttribute('disabled'); | |
67 | } else { | |
68 | deletebutton.setAttribute('disabled', 'disabled'); | |
69 | } | |
70 | } | |
71 | } | |
72 | actions.init(); | |
73 | }; |