From 0c42353743ad99980e0b976b6be3aa8035381da0 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Thu, 29 Jul 2010 06:14:12 +0000 Subject: [PATCH] calendar MDL-23443 Attemped fix of calendar rendering problems --- calendar/yui/eventmanager/eventmanager.js | 45 ++++++++++++++--------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/calendar/yui/eventmanager/eventmanager.js b/calendar/yui/eventmanager/eventmanager.js index ff313e48dfe44..7ee57043f9888 100644 --- a/calendar/yui/eventmanager/eventmanager.js +++ b/calendar/yui/eventmanager/eventmanager.js @@ -13,34 +13,44 @@ YUI.add('moodle-calendar-eventmanager', function(Y) { EVENT.superclass.constructor.apply(this, arguments); } Y.extend(EVENT, Y.Base, { + initpanelcalled : false, initializer : function(config){ var id = this.get(EVENTID), node = this.get(EVENTNODE); if (!node) { return false; } - var td = node.ancestor('td'), constraint = td.ancestor('div'), panel; + var td = node.ancestor('td'); this.publish('showevent'); this.publish('hideevent'); - panel = new Y.Overlay({ - constrain : constraint, - align : { - node : td, - points:[Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.BC] - }, - headerContent : Y.Node.create('

'+this.get(EVENTTITLE)+'

'), - bodyContent : Y.Node.create('
'+this.get(EVENTCONTENT)+'
'), - visible : false, - id : this.get(EVENTID)+'_panel', - width : Math.floor(constraint.get('offsetWidth')*0.9)+"px" - }); - panel.get('boundingBox').addClass('calendar-event-panel') - panel.render(td); - this.on('showevent', panel.show, panel); - this.on('hideevent', panel.hide, panel); td.on('mouseenter', this.startShow, this); td.on('mouseleave', this.startHide, this); return true; }, + initPanel : function() { + if (!this.initpanelcalled) { + this.initpanelcalled = true; + var node = this.get(EVENTNODE), + td = node.ancestor('td'), + constraint = td.ancestor('div'), + panel; + panel = new Y.Overlay({ + constrain : constraint, + align : { + node : td, + points:[Y.WidgetPositionAlign.TL, Y.WidgetPositionAlign.BC] + }, + headerContent : Y.Node.create('

'+this.get(EVENTTITLE)+'

'), + bodyContent : Y.Node.create('
'+this.get(EVENTCONTENT)+'
'), + visible : false, + id : this.get(EVENTID)+'_panel', + width : Math.floor(constraint.get('offsetWidth')*0.9)+"px" + }); + panel.render(td); + panel.get('boundingBox').addClass('calendar-event-panel'); + this.on('showevent', panel.show, panel); + this.on('hideevent', panel.hide, panel); + } + }, startShow : function() { if (this.get(SHOWTIMEOUT) !== null) { this.cancelShow(); @@ -52,6 +62,7 @@ YUI.add('moodle-calendar-eventmanager', function(Y) { clearTimeout(this.get(SHOWTIMEOUT)); }, show : function() { + this.initPanel(); this.fire('showevent'); }, startHide : function() {