module.js 2.7 KB

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