From e7fd0ff52a97ae15f90de986d1a460d0fffc0d29 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 9 Dec 2015 20:54:01 +0000 Subject: [PATCH] Fix some issues in drag and drop CSS with resizing on drop --- calendar/js/app.js | 2 +- calendar/js/et2_widget_daycol.js | 9 +++++++-- calendar/js/et2_widget_timegrid.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index cf5e15d2d7..121f3e2557 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -611,7 +611,7 @@ app.classes.calendar = AppJS.extend( // Re-scroll to start of day template.widgetContainer.iterateOver(function(w) { - w._resizeTimes(); + w.resizeTimes(); },this, et2_calendar_timegrid); window.setTimeout(function() { diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js index 14ec07985c..08fa50fa02 100644 --- a/calendar/js/et2_widget_daycol.js +++ b/calendar/js/et2_widget_daycol.js @@ -686,9 +686,14 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM], { if(!this.all_day.has(columns[c][i].div).length) { + columns[c][i].div.css('top', ''); + columns[c][i].div.css('height',''); + columns[c][i].div.css('left', ''); + columns[c][i].div.css('width', ''); + columns[c][i].body.css('padding-top',''); columns[c][i].div .appendTo(this.all_day); - this._parent._resizeTimes(); + this._parent.resizeTimes(); } continue; } @@ -697,7 +702,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM], if(this.all_day.has(columns[c][i].div).length) { columns[c][i].div.appendTo(this.div); - this._parent._resizeTimes(); + this._parent.resizeTimes(); } top = this._time_to_position(columns[c][i].options.value.start_m,whole_day_counter); height = this._time_to_position(columns[c][i].options.value.end_m,whole_day_counter)-top; diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index c6e9b5b158..8d852841fc 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -175,6 +175,10 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz { window.clearTimeout(this.update_timer); } + if(this.resize_timer) + { + window.clearTimeout(this.resize_timer); + } }, doLoadingFinished: function() { @@ -683,6 +687,26 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz this.scrolling.scrollTop(this._top_time); }, + /** + * As window size and number of all day non-blocking events change, we need + * to re-scale the time grid to make sure the full working day is shown. + * + */ + resizeTimes: function() { + // Wait a bit to see if anything else changes, then re-draw the times + if(this.resize_timer === null) + { + this.resize_timer = window.setTimeout(jQuery.proxy(function() { + if(this._resize_times) + { + this.resize_timer = null; + + this._resizeTimes(); + } + },this),1); + } + }, + _resizeTimes: function() { var wd_start = 60*this.options.day_start; @@ -932,6 +956,11 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz _data.ui.draggable.on('dragend.et2_timegrid'+widget_object.id, function() { _data.ui.draggable.off('drag.et2_timegrid' + widget_object.id); }); + + // Remove formatting for out-of-view events (full day non-blocking) + $j('.calendar_calEventHeader',_data.ui.helper).css('top',''); + $j('.calendar_calEventBody',_data.ui.helper).css('padding-top',''); + if(time.length) { // The out will trigger after the over, so we count