From 14041ccde466869afffcdeabe0812f4a8303af9c Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 19 Jan 2016 18:03:42 +0000 Subject: [PATCH] - Fix broken drag to resize - Fix single day was sometimes too wide --- calendar/js/et2_widget_daycol.js | 2 +- calendar/js/et2_widget_event.js | 8 ++++++++ calendar/js/et2_widget_planner.js | 4 ++-- calendar/js/et2_widget_timegrid.js | 23 +++++++++++++---------- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/calendar/js/et2_widget_daycol.js b/calendar/js/et2_widget_daycol.js index a6209380f3..d456068fb8 100644 --- a/calendar/js/et2_widget_daycol.js +++ b/calendar/js/et2_widget_daycol.js @@ -143,7 +143,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea { return this.all_day[0]; } - return this.event_wrapper[0]; + return this.div[0]; } }, diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index 8a707d0dfa..1604068d8e 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -249,6 +249,14 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM], // Get CSS too egw.includeCSS('/phpgwapi/categories.php?app='+event.app); + // Need cleaning? (DnD helper removes content) + if(!this.div.has(this.title).length) + { + this.div + .empty() + .append(this.title) + .append(this.body); + } // DOM nodes this.div // Let timegrid always get the drag diff --git a/calendar/js/et2_widget_planner.js b/calendar/js/et2_widget_planner.js index 70ab202356..8308817b51 100644 --- a/calendar/js/et2_widget_planner.js +++ b/calendar/js/et2_widget_planner.js @@ -175,7 +175,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi e.originalEvent = event; e.data = {duration: 0}; var event_data = planner._get_event_info(this); - var event_widget = planner.getWidgetById('event_'+event_data.id); + var event_widget = planner.getWidgetById(event_data.widget_id); var sT = event_widget.options.value.start_m; if (typeof this.dropEnd != 'undefined') { @@ -1670,7 +1670,7 @@ var et2_calendar_planner = et2_calendar_view.extend([et2_IDetachedDOM, et2_IResi if (this.onevent_change) { var event_data = this._get_event_info(dom_node); - var event_widget = this.getWidgetById('event_'+event_data.id); + var event_widget = this.getWidgetById(event_data.widget_id); et2_calendar_event.recur_prompt(event_data, jQuery.proxy(function(button_id, event_data) { // No need to continue if(button_id === 'cancel') return false; diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index d60520f428..3bcadcab2f 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -235,7 +235,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes e.originalEvent = event; e.data = {duration: 0}; var event_data = timegrid._get_event_info(this); - var event_widget = timegrid.getWidgetById('event_'+event_data.app_id); + var event_widget = timegrid.getWidgetById(event_data.widget_id); var sT = event_widget.options.value.start_m; if (typeof this.dropEnd != 'undefined' && this.dropEnd.length == 1) { @@ -562,9 +562,14 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes // Add the binding for the change handler $j(this.div).on("change.et2_calendar_timegrid", '*:not(.calendar_calEvent)', this, function(e) { - return e.data.change.call(e.data, e, this); - }); + return e.data.change.call(e.data, e, this); + }); + // Catch resize and prevent it from bubbling further, triggering + // etemplate's resize + this.div.on('resize', this, function(e) { + e.stopPropagation(); + }); }, getDOMNode: function(_sender) { @@ -865,9 +870,6 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes } this.day_widgets.splice(delete_index--,1); } - - // Adjust and scroll to start of day - this.resizeTimes(); // Create / update day widgets with dates and data for(var i = 0; i < this.day_widgets.length; i++) @@ -894,6 +896,9 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes } day.set_width(day_width + 'px'); } + + // Adjust and scroll to start of day + this.resizeTimes(); // Don't hold on to value any longer, use the data cache for best info this.value = {}; @@ -1472,7 +1477,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes if (this.onevent_change) { var event_data = this._get_event_info(dom_node); - var event_widget = this.getWidgetById('event_'+event_data.app_id); + var event_widget = this.getWidgetById(event_data.widget_id); et2_calendar_event.recur_prompt(event_data, jQuery.proxy(function(button_id, event_data) { // No need to continue if(button_id === 'cancel') return false; @@ -1697,9 +1702,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes } // Try to resize width, though animations cause problems - var total_width = Math.min(this.div.width(),( $j(this.getInstanceManager().DOMContainer).width() - ( - this.days.innerWidth() ? this.div.innerWidth() - this.days.innerWidth() : 0 - ))); + var total_width = this.days.width(); var day_width = (total_width > 0 ? total_width : $j(this.getInstanceManager().DOMContainer).width())/this.day_widgets.length; // update day widgets for(var i = 0; i < this.day_widgets.length; i++)