From 6823f382e037867f3032d651262d395dab20ef4a Mon Sep 17 00:00:00 2001 From: Adam Shaw Date: Tue, 15 Feb 2011 21:45:34 -0800 Subject: [PATCH] fixed bug when dragging non-start event segment from all-day slot to timed-slot in agenda view --- src/agenda/AgendaEventRenderer.js | 53 ++++++++++++++++++------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/src/agenda/AgendaEventRenderer.js b/src/agenda/AgendaEventRenderer.js index 6ecd663..72e233d 100644 --- a/src/agenda/AgendaEventRenderer.js +++ b/src/agenda/AgendaEventRenderer.js @@ -354,6 +354,7 @@ function AgendaEventRenderer() { function draggableDayEvent(event, eventElement, isStart) { if (!opt('disableDragging') && eventElement.draggable) { var origWidth; + var revert; var allDay=true; var dayDelta; var dis = opt('isRTL') ? -1 : 1; @@ -370,9 +371,9 @@ function AgendaEventRenderer() { hideEvents(event, eventElement); origWidth = eventElement.width(); hoverListener.start(function(cell, origCell, rowDelta, colDelta) { - eventElement.draggable('option', 'revert', !cell || !rowDelta && !colDelta); clearOverlays(); if (cell) { + revert = false; dayDelta = colDelta * dis; if (!cell.row) { // on full-days @@ -383,28 +384,43 @@ function AgendaEventRenderer() { resetElement(); }else{ // mouse is over bottom slots - if (isStart && allDay) { - // convert event to temporary slot-event - eventElement.width(colWidth - 10); // don't use entire width - setOuterHeight( - eventElement, - slotHeight * Math.round( - (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) - / opt('slotMinutes') - ) - ); - eventElement.draggable('option', 'grid', [colWidth, 1]); - allDay = false; + if (isStart) { + if (allDay) { + // convert event to temporary slot-event + eventElement.width(colWidth - 10); // don't use entire width + setOuterHeight( + eventElement, + slotHeight * Math.round( + (event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) + / opt('slotMinutes') + ) + ); + eventElement.draggable('option', 'grid', [colWidth, 1]); + allDay = false; + } + }else{ + revert = true; } } + revert = revert || (allDay && !dayDelta); + }else{ + revert = true; } + eventElement.draggable('option', 'revert', revert); }, ev, 'drag'); }, stop: function(ev, ui) { - var cell = hoverListener.stop(); + hoverListener.stop(); clearOverlays(); trigger('eventDragStop', eventElement, event, ev, ui); - if (cell && (!allDay || dayDelta)) { + if (revert) { + // hasn't moved or is out of bounds (draggable has already reverted) + resetElement(); + if ($.browser.msie) { + eventElement.css('filter', ''); // clear IE opacity side-effects + } + showEvents(event, eventElement); + }else{ // changed! eventElement.find('a').removeAttr('href'); // prevents safari from visiting the link var minuteDelta = 0; @@ -415,13 +431,6 @@ function AgendaEventRenderer() { - (event.start.getHours() * 60 + event.start.getMinutes()); } eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui); - }else{ - // hasn't moved or is out of bounds (draggable has already reverted) - resetElement(); - if ($.browser.msie) { - eventElement.css('filter', ''); // clear IE opacity side-effects - } - showEvents(event, eventElement); } } });