From 0a129c0214c56a8821c053c97e72daa9231bc6f7 Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 4 Jul 2016 10:26:38 -0600 Subject: [PATCH] Fix some bugs in drag to create event - Firefox tried to do drag to create & drag to resize when resizing an event - Speed improvement for mouseover --- calendar/js/et2_widget_timegrid.js | 51 ++++++++++++++++-------------- calendar/js/et2_widget_view.js | 2 +- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/calendar/js/et2_widget_timegrid.js b/calendar/js/et2_widget_timegrid.js index 974c14b171..204fa1b87f 100644 --- a/calendar/js/et2_widget_timegrid.js +++ b/calendar/js/et2_widget_timegrid.js @@ -327,27 +327,6 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. }) .on('mousemove', function(event) { timegrid._get_time_from_position(event.clientX, event.clientY); - - if(timegrid.drag_create.event && timegrid.drag_create.parent && timegrid.drag_create.end) - { - var end = jQuery.extend({}, timegrid.gridHover[0].dataset); - if(end.date) - { - timegrid.date_helper.set_year(end.date.substring(0,4)); - timegrid.date_helper.set_month(end.date.substring(4,6)); - timegrid.date_helper.set_date(end.date.substring(6,8)); - if(end.hour) - { - timegrid.date_helper.set_hours(end.hour); - } - if(end.minute) - { - timegrid.date_helper.set_minutes(end.minute); - } - timegrid.drag_create.end.date = timegrid.date_helper.get_value(); - } - timegrid._drag_update_event(); - } }) .on('mouseout', function(event) { if(timegrid.div.has(event.relatedTarget).length === 0) @@ -1919,8 +1898,33 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. } start.date = this.date_helper.get_value(); - this.gridHover.css('cursor', 'ns-resize'); + + // Start update + var timegrid = this; + this.div.on('mousemove.dragcreate', function() + { + if(timegrid.drag_create.event && timegrid.drag_create.parent && timegrid.drag_create.end) + { + var end = jQuery.extend({}, timegrid.gridHover[0].dataset); + if(end.date) + { + timegrid.date_helper.set_year(end.date.substring(0,4)); + timegrid.date_helper.set_month(end.date.substring(4,6)); + timegrid.date_helper.set_date(end.date.substring(6,8)); + if(end.hour) + { + timegrid.date_helper.set_hours(end.hour); + } + if(end.minute) + { + timegrid.date_helper.set_minutes(end.minute); + } + timegrid.drag_create.end.date = timegrid.date_helper.get_value(); + } + timegrid._drag_update_event(); + } + }); } return this._drag_create_start(start); }, @@ -1948,10 +1952,9 @@ var et2_calendar_timegrid = (function(){ "use strict"; return et2_calendar_view. } end.date = this.date_helper.get_value(); } - + this.div.off('mousemove.dragcreate'); this.gridHover.css('cursor', ''); - event.preventDefault(); return this._drag_create_end(end); }, diff --git a/calendar/js/et2_widget_view.js b/calendar/js/et2_widget_view.js index cb662e8f46..b8001ed90d 100644 --- a/calendar/js/et2_widget_view.js +++ b/calendar/js/et2_widget_view.js @@ -552,7 +552,7 @@ var et2_calendar_view = (function(){ "use strict"; return et2_valueWidget.extend this.drag_create.event.destroy(); this.drag_create.event = null; } - return false; + return true; } });}).call(this);