[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 var ENAME = 'Calendar event', 2 EVENTID = 'eventId', 3 EVENTNODE = 'node', 4 EVENTTITLE = 'title', 5 EVENTCONTENT = 'content', 6 EVENTDELAY = 'delay', 7 SHOWTIMEOUT = 'showTimeout', 8 HIDETIMEOUT = 'hideTimeout', 9 10 EVENT = function() { 11 EVENT.superclass.constructor.apply(this, arguments); 12 }, 13 EVENTMANAGER; 14 15 Y.extend(EVENT, Y.Base, { 16 initpanelcalled : false, 17 initializer : function(){ 18 this.get(EVENTID); 19 var node = this.get(EVENTNODE), 20 td; 21 if (!node) { 22 return false; 23 } 24 td = node.ancestor('td'); 25 this.publish('showevent'); 26 this.publish('hideevent'); 27 td.on('mouseenter', this.startShow, this); 28 td.on('mouseleave', this.startHide, this); 29 td.on('focus', this.startShow, this); 30 td.on('blur', this.startHide, this); 31 return true; 32 }, 33 initPanel : function() { 34 if (!this.initpanelcalled) { 35 this.initpanelcalled = true; 36 var node = this.get(EVENTNODE), 37 td = node.ancestor('td'), 38 constraint = td.ancestor('div'), 39 panel; 40 panel = new Y.Overlay({ 41 constrain : constraint, 42 align : { 43 node : td, 44 points:[Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.BC] 45 }, 46 headerContent : Y.Node.create('<h2 class="eventtitle">'+this.get(EVENTTITLE)+'</h2>'), 47 bodyContent : Y.Node.create('<div class="eventcontent">'+this.get(EVENTCONTENT)+'</div>'), 48 visible : false, 49 id : this.get(EVENTID)+'_panel', 50 width : Math.floor(constraint.get('offsetWidth')*0.9)+"px" 51 }); 52 panel.render(td); 53 node.setAttribute('aria-controls', panel.get('id')); 54 panel.get('boundingBox').addClass('calendar-event-panel'); 55 panel.get('boundingBox').setAttribute('aria-live', 'off'); 56 this.on('showevent', panel.show, panel); 57 this.on('showevent', this.setAriashow, panel); 58 this.on('hideevent', this.setAriahide, panel); 59 this.on('hideevent', panel.hide, panel); 60 } 61 }, 62 startShow : function() { 63 this.cancelHide(); 64 if (this.get(SHOWTIMEOUT) !== null) { 65 this.cancelShow(); 66 } 67 var self = this; 68 this.set(SHOWTIMEOUT, setTimeout(function(){self.show();}, this.get(EVENTDELAY))); 69 }, 70 cancelShow : function() { 71 clearTimeout(this.get(SHOWTIMEOUT)); 72 }, 73 setAriashow : function() { 74 this.get('boundingBox').setAttribute('aria-live', 'assertive'); 75 }, 76 setAriahide : function() { 77 this.get('boundingBox').setAttribute('aria-live', 'off'); 78 }, 79 show : function() { 80 this.initPanel(); 81 this.fire('showevent'); 82 }, 83 startHide : function() { 84 this.cancelShow(); 85 if (this.get(HIDETIMEOUT) !== null) { 86 this.cancelHide(); 87 } 88 var self = this; 89 this.set(HIDETIMEOUT, setTimeout(function(){self.hide();}, this.get(EVENTDELAY))); 90 }, 91 hide : function() { 92 this.fire('hideevent'); 93 }, 94 cancelHide : function() { 95 clearTimeout(this.get(HIDETIMEOUT)); 96 } 97 }, { 98 NAME : ENAME, 99 ATTRS : { 100 eventId : { 101 setter : function(nodeid) { 102 this.set(EVENTNODE, Y.one('#'+nodeid)); 103 return nodeid; 104 }, 105 validator : Y.Lang.isString 106 }, 107 node : { 108 setter : function(node) { 109 if (typeof(node) === 'string') { 110 node = Y.one('#'+node); 111 } 112 return node; 113 } 114 }, 115 title : { 116 validator : Y.Lang.isString 117 }, 118 content : { 119 validator : Y.Lang.isString 120 }, 121 delay : { 122 value : 300, 123 validator : Y.Lang.isNumber 124 }, 125 showTimeout : { 126 value : null 127 }, 128 hideTimeout : { 129 value : null 130 } 131 } 132 }); 133 Y.augment(EVENT, Y.EventTarget); 134 135 EVENTMANAGER = { 136 add_event : function(config) { 137 new EVENT(config); 138 } 139 }; 140 141 M.core_calendar = M.core_calendar || {}; 142 Y.mix(M.core_calendar, EVENTMANAGER);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |