Worked on this and decided the duration shown on fullCalendar like this:
- The presence of a custom function "setOptions" for fullCalendar.
- Having a fullCalendar property called "dragMinutes" that can be set during the $ (this) .draggable ({start: ...}) elements.
Here is the code for custom setOptions:
... function Calendar(element, options, eventSources) { var t = this; // hack for setting options that updates function setOptions(new_options, refresh) { $.extend(options, new_options); if (refresh) { var viewName = currentView.name; changeView(viewName, true); } } // exports ... t.setOptions = setOptions; ...
Here is the code for handling the dragMinutes option in fullCalendar:
function dragStart(_dragElement, ev, ui) { hoverListener.start(function (cell) { clearOverlays(); if (cell) { if (cellIsAllDay(cell)) { renderCellOverlay(cell.row, cell.col, cell.row, cell.col); } else { var d1 = cellDate(cell); if (opt('dragMinutes')) var d2 = addMinutes(cloneDate(d1), opt('dragMinutes')); else var d2 = addMinutes(cloneDate(d1), opt('defaultEventMinutes')); renderSlotOverlay(d1, d2); } } }, ev); }
And here is how I can drag the event and update "dragMinutes":
// make the event draggable using jQuery UI $(this).draggable({ containment: 'document', // return a custom styled elemnt being dragged helper: function (event) { return $('<div class="uv-planning-dragging"></div>').html($(this).html()); }, opacity: 0.70, zIndex: 10000, appendTo: 'body', cursor: 'move', revertDuration: 0, revert: true, start: function (e, ui) { // set the "dragMinutes" option in fullCalendar so shown interval about to be added is correct. var data = $(this).data('eventObject'); if (data) { var min = data.jsonProps.durationMsec / 1000 / 60; if (macroCalendar.calendar) { macroCalendar.calendar.fullCalendar('setOptions', { dragMinutes: Math.round(min) }, false); } } }, stop: function (e, ui) { // further process } });
Hope this helps.