aboutsummaryrefslogtreecommitdiffstats
path: root/library/fullcalendar/packages/interaction/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'library/fullcalendar/packages/interaction/main.js')
-rw-r--r--library/fullcalendar/packages/interaction/main.js153
1 files changed, 75 insertions, 78 deletions
diff --git a/library/fullcalendar/packages/interaction/main.js b/library/fullcalendar/packages/interaction/main.js
index 8dbb47bde..4420650fb 100644
--- a/library/fullcalendar/packages/interaction/main.js
+++ b/library/fullcalendar/packages/interaction/main.js
@@ -1,8 +1,9 @@
/*!
-FullCalendar Interaction Plugin v4.0.2
+FullCalendar Interaction Plugin v4.4.2
Docs & License: https://fullcalendar.io/
(c) 2019 Adam Shaw
*/
+
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
@@ -10,18 +11,18 @@ Docs & License: https://fullcalendar.io/
}(this, function (exports, core) { 'use strict';
/*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
+ Copyright (c) Microsoft Corporation.
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted.
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
@@ -842,7 +843,7 @@ Docs & License: https://fullcalendar.io/
this.delayTimeoutId = setTimeout(function () {
_this.delayTimeoutId = null;
_this.handleDelayEnd(ev);
- }, this.delay);
+ }, this.delay); // not assignable to number!
}
else {
this.handleDelayEnd(ev);
@@ -1053,6 +1054,7 @@ Docs & License: https://fullcalendar.io/
};
HitDragging.prototype.prepareHits = function () {
this.offsetTrackers = core.mapHash(this.droppableStore, function (interactionSettings) {
+ interactionSettings.component.buildPositionCaches();
return new OffsetTracker(interactionSettings.el);
});
};
@@ -1128,11 +1130,12 @@ Docs & License: https://fullcalendar.io/
// won't even fire if moving was ignored
_this.handleDragEnd = function (ev) {
var component = _this.component;
+ var _a = component.context, calendar = _a.calendar, view = _a.view;
var pointer = _this.dragging.pointer;
if (!pointer.wasTouchScroll) {
- var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
+ var _b = _this.hitDragging, initialHit = _b.initialHit, finalHit = _b.finalHit;
if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
- component.calendar.triggerDateClick(initialHit.dateSpan, initialHit.dayEl, component.view, ev.origEvent);
+ calendar.triggerDateClick(initialHit.dateSpan, initialHit.dayEl, view, ev.origEvent);
}
}
};
@@ -1162,7 +1165,8 @@ Docs & License: https://fullcalendar.io/
_this.dragSelection = null;
_this.handlePointerDown = function (ev) {
var _a = _this, component = _a.component, dragging = _a.dragging;
- var canSelect = component.opt('selectable') &&
+ var options = component.context.options;
+ var canSelect = options.selectable &&
component.isValidDateDownEl(ev.origEvent.target);
// don't bother to watch expensive moves if component won't do selection
dragging.setIgnoreMove(!canSelect);
@@ -1170,10 +1174,10 @@ Docs & License: https://fullcalendar.io/
dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null;
};
_this.handleDragStart = function (ev) {
- _this.component.calendar.unselect(ev); // unselect previous selections
+ _this.component.context.calendar.unselect(ev); // unselect previous selections
};
_this.handleHitUpdate = function (hit, isFinal) {
- var calendar = _this.component.calendar;
+ var calendar = _this.component.context.calendar;
var dragSelection = null;
var isInvalid = false;
if (hit) {
@@ -1202,15 +1206,16 @@ Docs & License: https://fullcalendar.io/
_this.handlePointerUp = function (pev) {
if (_this.dragSelection) {
// selection is already rendered, so just need to report selection
- _this.component.calendar.triggerDateSelect(_this.dragSelection, pev);
+ _this.component.context.calendar.triggerDateSelect(_this.dragSelection, pev);
_this.dragSelection = null;
}
};
var component = settings.component;
+ var options = component.context.options;
var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
dragging.touchScrollAllowed = false;
- dragging.minDistance = component.opt('selectMinDistance') || 0;
- dragging.autoScroller.isEnabled = component.opt('dragScroll');
+ dragging.minDistance = options.selectMinDistance || 0;
+ dragging.autoScroller.isEnabled = options.dragScroll;
var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
hitDragging.emitter.on('dragstart', _this.handleDragStart);
@@ -1224,9 +1229,10 @@ Docs & License: https://fullcalendar.io/
return DateSelecting;
}(core.Interaction));
function getComponentTouchDelay(component) {
- var delay = component.opt('selectLongPressDelay');
+ var options = component.context.options;
+ var delay = options.selectLongPressDelay;
if (delay == null) {
- delay = component.opt('longPressDelay');
+ delay = options.longPressDelay;
}
return delay;
}
@@ -1272,21 +1278,22 @@ Docs & License: https://fullcalendar.io/
var origTarget = ev.origEvent.target;
var _a = _this, component = _a.component, dragging = _a.dragging;
var mirror = dragging.mirror;
- var initialCalendar = component.calendar;
+ var options = component.context.options;
+ var initialCalendar = component.context.calendar;
var subjectSeg = _this.subjectSeg = core.getElSeg(ev.subjectEl);
var eventRange = _this.eventRange = subjectSeg.eventRange;
var eventInstanceId = eventRange.instance.instanceId;
_this.relevantEvents = core.getRelevantEvents(initialCalendar.state.eventStore, eventInstanceId);
- dragging.minDistance = ev.isTouch ? 0 : component.opt('eventDragMinDistance');
+ dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
dragging.delay =
// only do a touch delay if touch and this event hasn't been selected yet
(ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
getComponentTouchDelay$1(component) :
null;
mirror.parentNode = initialCalendar.el;
- mirror.revertDuration = component.opt('dragRevertDuration');
+ mirror.revertDuration = options.dragRevertDuration;
var isValid = component.isValidSegDownEl(origTarget) &&
- !core.elementClosest(origTarget, '.fc-resizer');
+ !core.elementClosest(origTarget, '.fc-resizer'); // NOT on a resizer
dragging.setIgnoreMove(!isValid);
// disable dragging for elements that are resizable (ie, selectable)
// but are not draggable
@@ -1294,7 +1301,8 @@ Docs & License: https://fullcalendar.io/
ev.subjectEl.classList.contains('fc-draggable');
};
_this.handleDragStart = function (ev) {
- var initialCalendar = _this.component.calendar;
+ var context = _this.component.context;
+ var initialCalendar = context.calendar;
var eventRange = _this.eventRange;
var eventInstanceId = eventRange.instance.instanceId;
if (ev.isTouch) {
@@ -1314,7 +1322,7 @@ Docs & License: https://fullcalendar.io/
el: _this.subjectSeg.el,
event: new core.EventApi(initialCalendar, eventRange.def, eventRange.instance),
jsEvent: ev.origEvent,
- view: _this.component.view
+ view: context.view
}
]);
}
@@ -1325,7 +1333,7 @@ Docs & License: https://fullcalendar.io/
}
var relevantEvents = _this.relevantEvents;
var initialHit = _this.hitDragging.initialHit;
- var initialCalendar = _this.component.calendar;
+ var initialCalendar = _this.component.context.calendar;
// states based on new hit
var receivingCalendar = null;
var mutation = null;
@@ -1339,9 +1347,10 @@ Docs & License: https://fullcalendar.io/
};
if (hit) {
var receivingComponent = hit.component;
- receivingCalendar = receivingComponent.calendar;
+ receivingCalendar = receivingComponent.context.calendar;
+ var receivingOptions = receivingComponent.context.options;
if (initialCalendar === receivingCalendar ||
- receivingComponent.opt('editable') && receivingComponent.opt('droppable')) {
+ receivingOptions.editable && receivingOptions.droppable) {
mutation = computeEventMutation(initialHit, hit, receivingCalendar.pluginSystem.hooks.eventDragMutationMassagers);
if (mutation) {
mutatedRelevantEvents = core.applyMutationToEventStore(relevantEvents, receivingCalendar.eventUiBases, mutation, receivingCalendar);
@@ -1387,9 +1396,10 @@ Docs & License: https://fullcalendar.io/
};
_this.handleDragEnd = function (ev) {
if (_this.isDragging) {
- var initialCalendar_1 = _this.component.calendar;
- var initialView = _this.component.view;
- var receivingCalendar = _this.receivingCalendar;
+ var context = _this.component.context;
+ var initialCalendar_1 = context.calendar;
+ var initialView = context.view;
+ var _a = _this, receivingCalendar = _a.receivingCalendar, validMutation = _a.validMutation;
var eventDef = _this.eventRange.def;
var eventInstance = _this.eventRange.instance;
var eventApi = new core.EventApi(initialCalendar_1, eventDef, eventInstance);
@@ -1405,33 +1415,25 @@ Docs & License: https://fullcalendar.io/
view: initialView
}
]);
- if (_this.validMutation) {
+ if (validMutation) {
// dropped within same calendar
if (receivingCalendar === initialCalendar_1) {
initialCalendar_1.dispatch({
type: 'MERGE_EVENTS',
eventStore: mutatedRelevantEvents
});
- var eventDropArg = {};
- for (var _i = 0, _a = initialCalendar_1.pluginSystem.hooks.eventDropTransformers; _i < _a.length; _i++) {
- var transformer = _a[_i];
- __assign(eventDropArg, transformer(_this.validMutation, initialCalendar_1));
+ var transformed = {};
+ for (var _i = 0, _b = initialCalendar_1.pluginSystem.hooks.eventDropTransformers; _i < _b.length; _i++) {
+ var transformer = _b[_i];
+ __assign(transformed, transformer(validMutation, initialCalendar_1));
}
- __assign(eventDropArg, {
- el: ev.subjectEl,
- delta: _this.validMutation.startDelta,
- oldEvent: eventApi,
- event: new core.EventApi(// the data AFTER the mutation
- initialCalendar_1, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null),
- revert: function () {
+ var eventDropArg = __assign({}, transformed, { el: ev.subjectEl, delta: validMutation.datesDelta, oldEvent: eventApi, event: new core.EventApi(// the data AFTER the mutation
+ initialCalendar_1, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null), revert: function () {
initialCalendar_1.dispatch({
type: 'MERGE_EVENTS',
eventStore: relevantEvents_1
});
- },
- jsEvent: ev.origEvent,
- view: initialView
- });
+ }, jsEvent: ev.origEvent, view: initialView });
initialCalendar_1.publiclyTrigger('eventDrop', [eventDropArg]);
// dropped in different calendar
}
@@ -1457,17 +1459,15 @@ Docs & License: https://fullcalendar.io/
eventInstanceId: eventInstance.instanceId
});
}
- var dropArg = receivingCalendar.buildDatePointApi(finalHit.dateSpan);
- dropArg.draggedEl = ev.subjectEl;
- dropArg.jsEvent = ev.origEvent;
- dropArg.view = finalHit.component; // ?
+ var dropArg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.component // should this be finalHit.component.view? See #4644
+ });
receivingCalendar.publiclyTrigger('drop', [dropArg]);
receivingCalendar.publiclyTrigger('eventReceive', [
{
draggedEl: ev.subjectEl,
event: new core.EventApi(// the data AFTER the mutation
receivingCalendar, mutatedRelevantEvents.defs[eventDef.defId], mutatedRelevantEvents.instances[eventInstance.instanceId]),
- view: finalHit.component
+ view: finalHit.component // should this be finalHit.component.view? See #4644
}
]);
}
@@ -1479,10 +1479,11 @@ Docs & License: https://fullcalendar.io/
_this.cleanup();
};
var component = _this.component;
+ var options = component.context.options;
var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
dragging.pointer.selector = EventDragging.SELECTOR;
dragging.touchScrollAllowed = false;
- dragging.autoScroller.isEnabled = component.opt('dragScroll');
+ dragging.autoScroller.isEnabled = options.dragScroll;
var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsStore);
hitDragging.useSubjectCenter = settings.useEventCenter;
hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
@@ -1497,7 +1498,7 @@ Docs & License: https://fullcalendar.io/
};
// render a drag state on the next receivingCalendar
EventDragging.prototype.displayDrag = function (nextCalendar, state) {
- var initialCalendar = this.component.calendar;
+ var initialCalendar = this.component.context.calendar;
var prevCalendar = this.receivingCalendar;
// does the previous calendar need to be cleared?
if (prevCalendar && prevCalendar !== nextCalendar) {
@@ -1524,7 +1525,7 @@ Docs & License: https://fullcalendar.io/
}
};
EventDragging.prototype.clearDrag = function () {
- var initialCalendar = this.component.calendar;
+ var initialCalendar = this.component.context.calendar;
var receivingCalendar = this.receivingCalendar;
if (receivingCalendar) {
receivingCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
@@ -1554,22 +1555,21 @@ Docs & License: https://fullcalendar.io/
var standardProps = {};
if (dateSpan0.allDay !== dateSpan1.allDay) {
standardProps.allDay = dateSpan1.allDay;
- standardProps.hasEnd = hit1.component.opt('allDayMaintainDuration');
+ standardProps.hasEnd = hit1.component.context.options.allDayMaintainDuration;
if (dateSpan1.allDay) {
// means date1 is already start-of-day,
// but date0 needs to be converted
date0 = core.startOfDay(date0);
}
}
- var delta = core.diffDates(date0, date1, hit0.component.dateEnv, hit0.component === hit1.component ?
+ var delta = core.diffDates(date0, date1, hit0.component.context.dateEnv, hit0.component === hit1.component ?
hit0.component.largeUnit :
null);
if (delta.milliseconds) { // has hours/minutes/seconds
standardProps.allDay = false;
}
var mutation = {
- startDelta: delta,
- endDelta: delta,
+ datesDelta: delta,
standardProps: standardProps
};
for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
@@ -1579,9 +1579,10 @@ Docs & License: https://fullcalendar.io/
return mutation;
}
function getComponentTouchDelay$1(component) {
- var delay = component.opt('eventLongPressDelay');
+ var options = component.context.options;
+ var delay = options.eventLongPressDelay;
if (delay == null) {
- delay = component.opt('longPressDelay');
+ delay = options.longPressDelay;
}
return delay;
}
@@ -1600,13 +1601,13 @@ Docs & License: https://fullcalendar.io/
var component = _this.component;
var seg = _this.querySeg(ev);
var eventRange = _this.eventRange = seg.eventRange;
- _this.dragging.minDistance = component.opt('eventDragMinDistance');
+ _this.dragging.minDistance = component.context.options.eventDragMinDistance;
// if touch, need to be working with a selected event
_this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
(ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
};
_this.handleDragStart = function (ev) {
- var calendar = _this.component.calendar;
+ var _a = _this.component.context, calendar = _a.calendar, view = _a.view;
var eventRange = _this.eventRange;
_this.relevantEvents = core.getRelevantEvents(calendar.state.eventStore, _this.eventRange.instance.instanceId);
_this.draggingSeg = _this.querySeg(ev);
@@ -1616,12 +1617,12 @@ Docs & License: https://fullcalendar.io/
el: _this.draggingSeg.el,
event: new core.EventApi(calendar, eventRange.def, eventRange.instance),
jsEvent: ev.origEvent,
- view: _this.component.view
+ view: view
}
]);
};
_this.handleHitUpdate = function (hit, isFinal, ev) {
- var calendar = _this.component.calendar;
+ var calendar = _this.component.context.calendar;
var relevantEvents = _this.relevantEvents;
var initialHit = _this.hitDragging.initialHit;
var eventInstance = _this.eventRange.instance;
@@ -1671,8 +1672,7 @@ Docs & License: https://fullcalendar.io/
}
};
_this.handleDragEnd = function (ev) {
- var calendar = _this.component.calendar;
- var view = _this.component.view;
+ var _a = _this.component.context, calendar = _a.calendar, view = _a.view;
var eventDef = _this.eventRange.def;
var eventInstance = _this.eventRange.instance;
var eventApi = new core.EventApi(calendar, eventDef, eventInstance);
@@ -1723,7 +1723,7 @@ Docs & License: https://fullcalendar.io/
var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
dragging.pointer.selector = '.fc-resizer';
dragging.touchScrollAllowed = false;
- dragging.autoScroller.isEnabled = component.opt('dragScroll');
+ dragging.autoScroller.isEnabled = component.context.options.dragScroll;
var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
hitDragging.emitter.on('dragstart', _this.handleDragStart);
@@ -1740,7 +1740,7 @@ Docs & License: https://fullcalendar.io/
return EventDragging;
}(core.Interaction));
function computeMutation(hit0, hit1, isFromStart, instanceRange, transforms) {
- var dateEnv = hit0.component.dateEnv;
+ var dateEnv = hit0.component.context.dateEnv;
var date0 = hit0.dateSpan.range.start;
var date1 = hit1.dateSpan.range.start;
var delta = core.diffDates(date0, date1, dateEnv, hit0.component.largeUnit);
@@ -1845,7 +1845,7 @@ Docs & License: https://fullcalendar.io/
origSeg: null
};
if (hit) {
- receivingCalendar = hit.component.calendar;
+ receivingCalendar = hit.component.context.calendar;
if (_this.canDropElOnCalendar(ev.subjectEl, receivingCalendar)) {
droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingCalendar);
interaction.mutatedEvents = core.eventTupleToStore(droppableEvent);
@@ -1877,12 +1877,9 @@ Docs & License: https://fullcalendar.io/
_this.clearDrag();
if (receivingCalendar && droppableEvent) {
var finalHit = _this.hitDragging.finalHit;
- var finalView = finalHit.component.view;
+ var finalView = finalHit.component.context.view;
var dragMeta = _this.dragMeta;
- var arg = receivingCalendar.buildDatePointApi(finalHit.dateSpan);
- arg.draggedEl = pev.subjectEl;
- arg.jsEvent = pev.origEvent;
- arg.view = finalView;
+ var arg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView });
receivingCalendar.publiclyTrigger('drop', [arg]);
if (dragMeta.create) {
receivingCalendar.dispatch({