|
|
@@ -26,7 +26,6 @@ function EventManager(options) { // assumed to be a calendar
|
|
|
t.mutateEvent = mutateEvent;
|
|
|
t.normalizeEventDates = normalizeEventDates;
|
|
|
t.normalizeEventTimes = normalizeEventTimes;
|
|
|
- t.eventToRange = eventToRange;
|
|
|
|
|
|
|
|
|
// imports
|
|
|
@@ -578,15 +577,6 @@ function EventManager(options) { // assumed to be a calendar
|
|
|
}
|
|
|
|
|
|
|
|
|
- // Generates the unzoned start/end dates an event appears to occupy
|
|
|
- function eventToRange(event) {
|
|
|
- return {
|
|
|
- start: event.start.clone().stripZone(),
|
|
|
- end: t.getEventEnd(event).stripZone()
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
// If the given event is a recurring event, break it down into an array of individual instances.
|
|
|
// If not a recurring event, return an array with the single original event.
|
|
|
// If given a falsy input (probably because of a failed buildEventFromInput call), returns an empty array.
|
|
|
@@ -895,19 +885,13 @@ function EventManager(options) { // assumed to be a calendar
|
|
|
/* Overlapping / Constraining
|
|
|
-----------------------------------------------------------------------------------------*/
|
|
|
|
|
|
- t.isEventLocationAllowed = isEventLocationAllowed;
|
|
|
- t.isExternalLocationAllowed = isExternalLocationAllowed;
|
|
|
- t.isSelectionRangeAllowed = isSelectionRangeAllowed;
|
|
|
-
|
|
|
-
|
|
|
- // Determines if an event location (zoned start/end/allDay) is valid
|
|
|
- function isEventLocationAllowed(eventLocation, event) {
|
|
|
- return isEventRangeAllowed(eventToRange(eventLocation), event);
|
|
|
- }
|
|
|
+ t.isEventSpanAllowed = isEventSpanAllowed;
|
|
|
+ t.isExternalSpanAllowed = isExternalSpanAllowed;
|
|
|
+ t.isSelectionSpanAllowed = isSelectionSpanAllowed;
|
|
|
|
|
|
|
|
|
- // Determines if an event range (unzoned start/end) is valid
|
|
|
- function isEventRangeAllowed(range, event) {
|
|
|
+ // Determines if the given event can be relocated to the given span (unzoned start/end with other misc data)
|
|
|
+ function isEventSpanAllowed(span, event) {
|
|
|
var source = event.source || {};
|
|
|
var constraint = firstDefined(
|
|
|
event.constraint,
|
|
|
@@ -919,12 +903,12 @@ function EventManager(options) { // assumed to be a calendar
|
|
|
source.overlap,
|
|
|
options.eventOverlap
|
|
|
);
|
|
|
- return isRangeAllowed(range, constraint, overlap, event);
|
|
|
+ return isSpanAllowed(span, constraint, overlap, event);
|
|
|
}
|
|
|
|
|
|
|
|
|
- // Determines if an drop location (zoned start/end/allDay) for an external event is valid
|
|
|
- function isExternalLocationAllowed(eventLocation, eventProps) {
|
|
|
+ // Determines if an external event can be relocated to the given span (unzoned start/end with other misc data)
|
|
|
+ function isExternalSpanAllowed(eventSpan, eventLocation, eventProps) {
|
|
|
var eventInput;
|
|
|
var event;
|
|
|
|
|
|
@@ -935,25 +919,25 @@ function EventManager(options) { // assumed to be a calendar
|
|
|
}
|
|
|
|
|
|
if (event) {
|
|
|
- return isEventLocationAllowed(eventLocation, event);
|
|
|
+ return isEventSpanAllowed(eventSpan, event);
|
|
|
}
|
|
|
else { // treat it as a selection
|
|
|
|
|
|
- return isSelectionRangeAllowed(eventToRange(eventLocation));
|
|
|
+ return isSelectionSpanAllowed(eventSpan);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- // Determines if a range (unzoned start/end) is valid
|
|
|
- function isSelectionRangeAllowed(range) {
|
|
|
- return isRangeAllowed(range, options.selectConstraint, options.selectOverlap);
|
|
|
+ // Determines the given span (unzoned start/end with other misc data) can be selected.
|
|
|
+ function isSelectionSpanAllowed(span) {
|
|
|
+ return isSpanAllowed(span, options.selectConstraint, options.selectOverlap);
|
|
|
}
|
|
|
|
|
|
|
|
|
- // Returns true if the given range (caused by an event drop/resize or a selection) is allowed to exist
|
|
|
+ // Returns true if the given span (caused by an event drop/resize or a selection) is allowed to exist
|
|
|
// according to the constraint/overlap settings.
|
|
|
// `event` is not required if checking a selection.
|
|
|
- function isRangeAllowed(range, constraint, overlap, event) {
|
|
|
+ function isSpanAllowed(span, constraint, overlap, event) {
|
|
|
var constraintEvents;
|
|
|
var anyContainment;
|
|
|
var peerEvents;
|
|
|
@@ -969,7 +953,7 @@ function EventManager(options) { // assumed to be a calendar
|
|
|
|
|
|
anyContainment = false;
|
|
|
for (i = 0; i < constraintEvents.length; i++) {
|
|
|
- if (eventContainsRange(constraintEvents[i], range)) {
|
|
|
+ if (eventContainsRange(constraintEvents[i], span)) {
|
|
|
anyContainment = true;
|
|
|
break;
|
|
|
}
|
|
|
@@ -980,13 +964,13 @@ function EventManager(options) { // assumed to be a calendar
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- peerEvents = t.getPeerEvents(event, range);
|
|
|
+ peerEvents = t.getPeerEvents(span, event);
|
|
|
|
|
|
for (i = 0; i < peerEvents.length; i++) {
|
|
|
peerEvent = peerEvents[i];
|
|
|
|
|
|
// there needs to be an actual intersection before disallowing anything
|
|
|
- if (eventIntersectsRange(peerEvent, range)) {
|
|
|
+ if (eventIntersectsRange(peerEvent, span)) {
|
|
|
|
|
|
// evaluate overlap for the given range and short-circuit if necessary
|
|
|
if (overlap === false) {
|
|
|
@@ -1066,8 +1050,8 @@ function EventManager(options) { // assumed to be a calendar
|
|
|
|
|
|
|
|
|
// Returns a list of events that the given event should be compared against when being considered for a move to
|
|
|
-// the specified range. Attached to the Calendar's prototype because EventManager is a mixin for a Calendar.
|
|
|
-Calendar.prototype.getPeerEvents = function(event, range) {
|
|
|
+// the specified span. Attached to the Calendar's prototype because EventManager is a mixin for a Calendar.
|
|
|
+Calendar.prototype.getPeerEvents = function(span, event) {
|
|
|
var cache = this.getEventCache();
|
|
|
var peerEvents = [];
|
|
|
var i, otherEvent;
|