@fullcalendar/interaction 5.11.3 → 6.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/main.global.js DELETED
@@ -1,2212 +0,0 @@
1
- /*!
2
- FullCalendar v5.11.3
3
- Docs & License: https://fullcalendar.io/
4
- (c) 2022 Adam Shaw
5
- */
6
- var FullCalendarInteraction = (function (exports, common) {
7
- 'use strict';
8
-
9
- /*! *****************************************************************************
10
- Copyright (c) Microsoft Corporation.
11
-
12
- Permission to use, copy, modify, and/or distribute this software for any
13
- purpose with or without fee is hereby granted.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
- PERFORMANCE OF THIS SOFTWARE.
22
- ***************************************************************************** */
23
- /* global Reflect, Promise */
24
-
25
- var extendStatics = function(d, b) {
26
- extendStatics = Object.setPrototypeOf ||
27
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
29
- return extendStatics(d, b);
30
- };
31
-
32
- function __extends(d, b) {
33
- if (typeof b !== "function" && b !== null)
34
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
35
- extendStatics(d, b);
36
- function __() { this.constructor = d; }
37
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
38
- }
39
-
40
- var __assign = function() {
41
- __assign = Object.assign || function __assign(t) {
42
- for (var s, i = 1, n = arguments.length; i < n; i++) {
43
- s = arguments[i];
44
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
45
- }
46
- return t;
47
- };
48
- return __assign.apply(this, arguments);
49
- };
50
-
51
- common.config.touchMouseIgnoreWait = 500;
52
- var ignoreMouseDepth = 0;
53
- var listenerCnt = 0;
54
- var isWindowTouchMoveCancelled = false;
55
- /*
56
- Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
57
- Tracks when the pointer "drags" on a certain element, meaning down+move+up.
58
-
59
- Also, tracks if there was touch-scrolling.
60
- Also, can prevent touch-scrolling from happening.
61
- Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
62
-
63
- emits:
64
- - pointerdown
65
- - pointermove
66
- - pointerup
67
- */
68
- var PointerDragging = /** @class */ (function () {
69
- function PointerDragging(containerEl) {
70
- var _this = this;
71
- this.subjectEl = null;
72
- // options that can be directly assigned by caller
73
- this.selector = ''; // will cause subjectEl in all emitted events to be this element
74
- this.handleSelector = '';
75
- this.shouldIgnoreMove = false;
76
- this.shouldWatchScroll = true; // for simulating pointermove on scroll
77
- // internal states
78
- this.isDragging = false;
79
- this.isTouchDragging = false;
80
- this.wasTouchScroll = false;
81
- // Mouse
82
- // ----------------------------------------------------------------------------------------------------
83
- this.handleMouseDown = function (ev) {
84
- if (!_this.shouldIgnoreMouse() &&
85
- isPrimaryMouseButton(ev) &&
86
- _this.tryStart(ev)) {
87
- var pev = _this.createEventFromMouse(ev, true);
88
- _this.emitter.trigger('pointerdown', pev);
89
- _this.initScrollWatch(pev);
90
- if (!_this.shouldIgnoreMove) {
91
- document.addEventListener('mousemove', _this.handleMouseMove);
92
- }
93
- document.addEventListener('mouseup', _this.handleMouseUp);
94
- }
95
- };
96
- this.handleMouseMove = function (ev) {
97
- var pev = _this.createEventFromMouse(ev);
98
- _this.recordCoords(pev);
99
- _this.emitter.trigger('pointermove', pev);
100
- };
101
- this.handleMouseUp = function (ev) {
102
- document.removeEventListener('mousemove', _this.handleMouseMove);
103
- document.removeEventListener('mouseup', _this.handleMouseUp);
104
- _this.emitter.trigger('pointerup', _this.createEventFromMouse(ev));
105
- _this.cleanup(); // call last so that pointerup has access to props
106
- };
107
- // Touch
108
- // ----------------------------------------------------------------------------------------------------
109
- this.handleTouchStart = function (ev) {
110
- if (_this.tryStart(ev)) {
111
- _this.isTouchDragging = true;
112
- var pev = _this.createEventFromTouch(ev, true);
113
- _this.emitter.trigger('pointerdown', pev);
114
- _this.initScrollWatch(pev);
115
- // unlike mouse, need to attach to target, not document
116
- // https://stackoverflow.com/a/45760014
117
- var targetEl = ev.target;
118
- if (!_this.shouldIgnoreMove) {
119
- targetEl.addEventListener('touchmove', _this.handleTouchMove);
120
- }
121
- targetEl.addEventListener('touchend', _this.handleTouchEnd);
122
- targetEl.addEventListener('touchcancel', _this.handleTouchEnd); // treat it as a touch end
123
- // attach a handler to get called when ANY scroll action happens on the page.
124
- // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
125
- // http://stackoverflow.com/a/32954565/96342
126
- window.addEventListener('scroll', _this.handleTouchScroll, true);
127
- }
128
- };
129
- this.handleTouchMove = function (ev) {
130
- var pev = _this.createEventFromTouch(ev);
131
- _this.recordCoords(pev);
132
- _this.emitter.trigger('pointermove', pev);
133
- };
134
- this.handleTouchEnd = function (ev) {
135
- if (_this.isDragging) { // done to guard against touchend followed by touchcancel
136
- var targetEl = ev.target;
137
- targetEl.removeEventListener('touchmove', _this.handleTouchMove);
138
- targetEl.removeEventListener('touchend', _this.handleTouchEnd);
139
- targetEl.removeEventListener('touchcancel', _this.handleTouchEnd);
140
- window.removeEventListener('scroll', _this.handleTouchScroll, true); // useCaptured=true
141
- _this.emitter.trigger('pointerup', _this.createEventFromTouch(ev));
142
- _this.cleanup(); // call last so that pointerup has access to props
143
- _this.isTouchDragging = false;
144
- startIgnoringMouse();
145
- }
146
- };
147
- this.handleTouchScroll = function () {
148
- _this.wasTouchScroll = true;
149
- };
150
- this.handleScroll = function (ev) {
151
- if (!_this.shouldIgnoreMove) {
152
- var pageX = (window.pageXOffset - _this.prevScrollX) + _this.prevPageX;
153
- var pageY = (window.pageYOffset - _this.prevScrollY) + _this.prevPageY;
154
- _this.emitter.trigger('pointermove', {
155
- origEvent: ev,
156
- isTouch: _this.isTouchDragging,
157
- subjectEl: _this.subjectEl,
158
- pageX: pageX,
159
- pageY: pageY,
160
- deltaX: pageX - _this.origPageX,
161
- deltaY: pageY - _this.origPageY,
162
- });
163
- }
164
- };
165
- this.containerEl = containerEl;
166
- this.emitter = new common.Emitter();
167
- containerEl.addEventListener('mousedown', this.handleMouseDown);
168
- containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
169
- listenerCreated();
170
- }
171
- PointerDragging.prototype.destroy = function () {
172
- this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
173
- this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
174
- listenerDestroyed();
175
- };
176
- PointerDragging.prototype.tryStart = function (ev) {
177
- var subjectEl = this.querySubjectEl(ev);
178
- var downEl = ev.target;
179
- if (subjectEl &&
180
- (!this.handleSelector || common.elementClosest(downEl, this.handleSelector))) {
181
- this.subjectEl = subjectEl;
182
- this.isDragging = true; // do this first so cancelTouchScroll will work
183
- this.wasTouchScroll = false;
184
- return true;
185
- }
186
- return false;
187
- };
188
- PointerDragging.prototype.cleanup = function () {
189
- isWindowTouchMoveCancelled = false;
190
- this.isDragging = false;
191
- this.subjectEl = null;
192
- // keep wasTouchScroll around for later access
193
- this.destroyScrollWatch();
194
- };
195
- PointerDragging.prototype.querySubjectEl = function (ev) {
196
- if (this.selector) {
197
- return common.elementClosest(ev.target, this.selector);
198
- }
199
- return this.containerEl;
200
- };
201
- PointerDragging.prototype.shouldIgnoreMouse = function () {
202
- return ignoreMouseDepth || this.isTouchDragging;
203
- };
204
- // can be called by user of this class, to cancel touch-based scrolling for the current drag
205
- PointerDragging.prototype.cancelTouchScroll = function () {
206
- if (this.isDragging) {
207
- isWindowTouchMoveCancelled = true;
208
- }
209
- };
210
- // Scrolling that simulates pointermoves
211
- // ----------------------------------------------------------------------------------------------------
212
- PointerDragging.prototype.initScrollWatch = function (ev) {
213
- if (this.shouldWatchScroll) {
214
- this.recordCoords(ev);
215
- window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
216
- }
217
- };
218
- PointerDragging.prototype.recordCoords = function (ev) {
219
- if (this.shouldWatchScroll) {
220
- this.prevPageX = ev.pageX;
221
- this.prevPageY = ev.pageY;
222
- this.prevScrollX = window.pageXOffset;
223
- this.prevScrollY = window.pageYOffset;
224
- }
225
- };
226
- PointerDragging.prototype.destroyScrollWatch = function () {
227
- if (this.shouldWatchScroll) {
228
- window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
229
- }
230
- };
231
- // Event Normalization
232
- // ----------------------------------------------------------------------------------------------------
233
- PointerDragging.prototype.createEventFromMouse = function (ev, isFirst) {
234
- var deltaX = 0;
235
- var deltaY = 0;
236
- // TODO: repeat code
237
- if (isFirst) {
238
- this.origPageX = ev.pageX;
239
- this.origPageY = ev.pageY;
240
- }
241
- else {
242
- deltaX = ev.pageX - this.origPageX;
243
- deltaY = ev.pageY - this.origPageY;
244
- }
245
- return {
246
- origEvent: ev,
247
- isTouch: false,
248
- subjectEl: this.subjectEl,
249
- pageX: ev.pageX,
250
- pageY: ev.pageY,
251
- deltaX: deltaX,
252
- deltaY: deltaY,
253
- };
254
- };
255
- PointerDragging.prototype.createEventFromTouch = function (ev, isFirst) {
256
- var touches = ev.touches;
257
- var pageX;
258
- var pageY;
259
- var deltaX = 0;
260
- var deltaY = 0;
261
- // if touch coords available, prefer,
262
- // because FF would give bad ev.pageX ev.pageY
263
- if (touches && touches.length) {
264
- pageX = touches[0].pageX;
265
- pageY = touches[0].pageY;
266
- }
267
- else {
268
- pageX = ev.pageX;
269
- pageY = ev.pageY;
270
- }
271
- // TODO: repeat code
272
- if (isFirst) {
273
- this.origPageX = pageX;
274
- this.origPageY = pageY;
275
- }
276
- else {
277
- deltaX = pageX - this.origPageX;
278
- deltaY = pageY - this.origPageY;
279
- }
280
- return {
281
- origEvent: ev,
282
- isTouch: true,
283
- subjectEl: this.subjectEl,
284
- pageX: pageX,
285
- pageY: pageY,
286
- deltaX: deltaX,
287
- deltaY: deltaY,
288
- };
289
- };
290
- return PointerDragging;
291
- }());
292
- // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
293
- function isPrimaryMouseButton(ev) {
294
- return ev.button === 0 && !ev.ctrlKey;
295
- }
296
- // Ignoring fake mouse events generated by touch
297
- // ----------------------------------------------------------------------------------------------------
298
- function startIgnoringMouse() {
299
- ignoreMouseDepth += 1;
300
- setTimeout(function () {
301
- ignoreMouseDepth -= 1;
302
- }, common.config.touchMouseIgnoreWait);
303
- }
304
- // We want to attach touchmove as early as possible for Safari
305
- // ----------------------------------------------------------------------------------------------------
306
- function listenerCreated() {
307
- listenerCnt += 1;
308
- if (listenerCnt === 1) {
309
- window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
310
- }
311
- }
312
- function listenerDestroyed() {
313
- listenerCnt -= 1;
314
- if (!listenerCnt) {
315
- window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
316
- }
317
- }
318
- function onWindowTouchMove(ev) {
319
- if (isWindowTouchMoveCancelled) {
320
- ev.preventDefault();
321
- }
322
- }
323
-
324
- /*
325
- An effect in which an element follows the movement of a pointer across the screen.
326
- The moving element is a clone of some other element.
327
- Must call start + handleMove + stop.
328
- */
329
- var ElementMirror = /** @class */ (function () {
330
- function ElementMirror() {
331
- this.isVisible = false; // must be explicitly enabled
332
- this.sourceEl = null;
333
- this.mirrorEl = null;
334
- this.sourceElRect = null; // screen coords relative to viewport
335
- // options that can be set directly by caller
336
- this.parentNode = document.body; // HIGHLY SUGGESTED to set this to sidestep ShadowDOM issues
337
- this.zIndex = 9999;
338
- this.revertDuration = 0;
339
- }
340
- ElementMirror.prototype.start = function (sourceEl, pageX, pageY) {
341
- this.sourceEl = sourceEl;
342
- this.sourceElRect = this.sourceEl.getBoundingClientRect();
343
- this.origScreenX = pageX - window.pageXOffset;
344
- this.origScreenY = pageY - window.pageYOffset;
345
- this.deltaX = 0;
346
- this.deltaY = 0;
347
- this.updateElPosition();
348
- };
349
- ElementMirror.prototype.handleMove = function (pageX, pageY) {
350
- this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
351
- this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
352
- this.updateElPosition();
353
- };
354
- // can be called before start
355
- ElementMirror.prototype.setIsVisible = function (bool) {
356
- if (bool) {
357
- if (!this.isVisible) {
358
- if (this.mirrorEl) {
359
- this.mirrorEl.style.display = '';
360
- }
361
- this.isVisible = bool; // needs to happen before updateElPosition
362
- this.updateElPosition(); // because was not updating the position while invisible
363
- }
364
- }
365
- else if (this.isVisible) {
366
- if (this.mirrorEl) {
367
- this.mirrorEl.style.display = 'none';
368
- }
369
- this.isVisible = bool;
370
- }
371
- };
372
- // always async
373
- ElementMirror.prototype.stop = function (needsRevertAnimation, callback) {
374
- var _this = this;
375
- var done = function () {
376
- _this.cleanup();
377
- callback();
378
- };
379
- if (needsRevertAnimation &&
380
- this.mirrorEl &&
381
- this.isVisible &&
382
- this.revertDuration && // if 0, transition won't work
383
- (this.deltaX || this.deltaY) // if same coords, transition won't work
384
- ) {
385
- this.doRevertAnimation(done, this.revertDuration);
386
- }
387
- else {
388
- setTimeout(done, 0);
389
- }
390
- };
391
- ElementMirror.prototype.doRevertAnimation = function (callback, revertDuration) {
392
- var mirrorEl = this.mirrorEl;
393
- var finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
394
- mirrorEl.style.transition =
395
- 'top ' + revertDuration + 'ms,' +
396
- 'left ' + revertDuration + 'ms';
397
- common.applyStyle(mirrorEl, {
398
- left: finalSourceElRect.left,
399
- top: finalSourceElRect.top,
400
- });
401
- common.whenTransitionDone(mirrorEl, function () {
402
- mirrorEl.style.transition = '';
403
- callback();
404
- });
405
- };
406
- ElementMirror.prototype.cleanup = function () {
407
- if (this.mirrorEl) {
408
- common.removeElement(this.mirrorEl);
409
- this.mirrorEl = null;
410
- }
411
- this.sourceEl = null;
412
- };
413
- ElementMirror.prototype.updateElPosition = function () {
414
- if (this.sourceEl && this.isVisible) {
415
- common.applyStyle(this.getMirrorEl(), {
416
- left: this.sourceElRect.left + this.deltaX,
417
- top: this.sourceElRect.top + this.deltaY,
418
- });
419
- }
420
- };
421
- ElementMirror.prototype.getMirrorEl = function () {
422
- var sourceElRect = this.sourceElRect;
423
- var mirrorEl = this.mirrorEl;
424
- if (!mirrorEl) {
425
- mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
426
- // we don't want long taps or any mouse interaction causing selection/menus.
427
- // would use preventSelection(), but that prevents selectstart, causing problems.
428
- mirrorEl.classList.add('fc-unselectable');
429
- mirrorEl.classList.add('fc-event-dragging');
430
- common.applyStyle(mirrorEl, {
431
- position: 'fixed',
432
- zIndex: this.zIndex,
433
- visibility: '',
434
- boxSizing: 'border-box',
435
- width: sourceElRect.right - sourceElRect.left,
436
- height: sourceElRect.bottom - sourceElRect.top,
437
- right: 'auto',
438
- bottom: 'auto',
439
- margin: 0,
440
- });
441
- this.parentNode.appendChild(mirrorEl);
442
- }
443
- return mirrorEl;
444
- };
445
- return ElementMirror;
446
- }());
447
-
448
- /*
449
- Is a cache for a given element's scroll information (all the info that ScrollController stores)
450
- in addition the "client rectangle" of the element.. the area within the scrollbars.
451
-
452
- The cache can be in one of two modes:
453
- - doesListening:false - ignores when the container is scrolled by someone else
454
- - doesListening:true - watch for scrolling and update the cache
455
- */
456
- var ScrollGeomCache = /** @class */ (function (_super) {
457
- __extends(ScrollGeomCache, _super);
458
- function ScrollGeomCache(scrollController, doesListening) {
459
- var _this = _super.call(this) || this;
460
- _this.handleScroll = function () {
461
- _this.scrollTop = _this.scrollController.getScrollTop();
462
- _this.scrollLeft = _this.scrollController.getScrollLeft();
463
- _this.handleScrollChange();
464
- };
465
- _this.scrollController = scrollController;
466
- _this.doesListening = doesListening;
467
- _this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
468
- _this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
469
- _this.scrollWidth = scrollController.getScrollWidth();
470
- _this.scrollHeight = scrollController.getScrollHeight();
471
- _this.clientWidth = scrollController.getClientWidth();
472
- _this.clientHeight = scrollController.getClientHeight();
473
- _this.clientRect = _this.computeClientRect(); // do last in case it needs cached values
474
- if (_this.doesListening) {
475
- _this.getEventTarget().addEventListener('scroll', _this.handleScroll);
476
- }
477
- return _this;
478
- }
479
- ScrollGeomCache.prototype.destroy = function () {
480
- if (this.doesListening) {
481
- this.getEventTarget().removeEventListener('scroll', this.handleScroll);
482
- }
483
- };
484
- ScrollGeomCache.prototype.getScrollTop = function () {
485
- return this.scrollTop;
486
- };
487
- ScrollGeomCache.prototype.getScrollLeft = function () {
488
- return this.scrollLeft;
489
- };
490
- ScrollGeomCache.prototype.setScrollTop = function (top) {
491
- this.scrollController.setScrollTop(top);
492
- if (!this.doesListening) {
493
- // we are not relying on the element to normalize out-of-bounds scroll values
494
- // so we need to sanitize ourselves
495
- this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
496
- this.handleScrollChange();
497
- }
498
- };
499
- ScrollGeomCache.prototype.setScrollLeft = function (top) {
500
- this.scrollController.setScrollLeft(top);
501
- if (!this.doesListening) {
502
- // we are not relying on the element to normalize out-of-bounds scroll values
503
- // so we need to sanitize ourselves
504
- this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
505
- this.handleScrollChange();
506
- }
507
- };
508
- ScrollGeomCache.prototype.getClientWidth = function () {
509
- return this.clientWidth;
510
- };
511
- ScrollGeomCache.prototype.getClientHeight = function () {
512
- return this.clientHeight;
513
- };
514
- ScrollGeomCache.prototype.getScrollWidth = function () {
515
- return this.scrollWidth;
516
- };
517
- ScrollGeomCache.prototype.getScrollHeight = function () {
518
- return this.scrollHeight;
519
- };
520
- ScrollGeomCache.prototype.handleScrollChange = function () {
521
- };
522
- return ScrollGeomCache;
523
- }(common.ScrollController));
524
-
525
- var ElementScrollGeomCache = /** @class */ (function (_super) {
526
- __extends(ElementScrollGeomCache, _super);
527
- function ElementScrollGeomCache(el, doesListening) {
528
- return _super.call(this, new common.ElementScrollController(el), doesListening) || this;
529
- }
530
- ElementScrollGeomCache.prototype.getEventTarget = function () {
531
- return this.scrollController.el;
532
- };
533
- ElementScrollGeomCache.prototype.computeClientRect = function () {
534
- return common.computeInnerRect(this.scrollController.el);
535
- };
536
- return ElementScrollGeomCache;
537
- }(ScrollGeomCache));
538
-
539
- var WindowScrollGeomCache = /** @class */ (function (_super) {
540
- __extends(WindowScrollGeomCache, _super);
541
- function WindowScrollGeomCache(doesListening) {
542
- return _super.call(this, new common.WindowScrollController(), doesListening) || this;
543
- }
544
- WindowScrollGeomCache.prototype.getEventTarget = function () {
545
- return window;
546
- };
547
- WindowScrollGeomCache.prototype.computeClientRect = function () {
548
- return {
549
- left: this.scrollLeft,
550
- right: this.scrollLeft + this.clientWidth,
551
- top: this.scrollTop,
552
- bottom: this.scrollTop + this.clientHeight,
553
- };
554
- };
555
- // the window is the only scroll object that changes it's rectangle relative
556
- // to the document's topleft as it scrolls
557
- WindowScrollGeomCache.prototype.handleScrollChange = function () {
558
- this.clientRect = this.computeClientRect();
559
- };
560
- return WindowScrollGeomCache;
561
- }(ScrollGeomCache));
562
-
563
- // If available we are using native "performance" API instead of "Date"
564
- // Read more about it on MDN:
565
- // https://developer.mozilla.org/en-US/docs/Web/API/Performance
566
- var getTime = typeof performance === 'function' ? performance.now : Date.now;
567
- /*
568
- For a pointer interaction, automatically scrolls certain scroll containers when the pointer
569
- approaches the edge.
570
-
571
- The caller must call start + handleMove + stop.
572
- */
573
- var AutoScroller = /** @class */ (function () {
574
- function AutoScroller() {
575
- var _this = this;
576
- // options that can be set by caller
577
- this.isEnabled = true;
578
- this.scrollQuery = [window, '.fc-scroller'];
579
- this.edgeThreshold = 50; // pixels
580
- this.maxVelocity = 300; // pixels per second
581
- // internal state
582
- this.pointerScreenX = null;
583
- this.pointerScreenY = null;
584
- this.isAnimating = false;
585
- this.scrollCaches = null;
586
- // protect against the initial pointerdown being too close to an edge and starting the scroll
587
- this.everMovedUp = false;
588
- this.everMovedDown = false;
589
- this.everMovedLeft = false;
590
- this.everMovedRight = false;
591
- this.animate = function () {
592
- if (_this.isAnimating) { // wasn't cancelled between animation calls
593
- var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
594
- if (edge) {
595
- var now = getTime();
596
- _this.handleSide(edge, (now - _this.msSinceRequest) / 1000);
597
- _this.requestAnimation(now);
598
- }
599
- else {
600
- _this.isAnimating = false; // will stop animation
601
- }
602
- }
603
- };
604
- }
605
- AutoScroller.prototype.start = function (pageX, pageY, scrollStartEl) {
606
- if (this.isEnabled) {
607
- this.scrollCaches = this.buildCaches(scrollStartEl);
608
- this.pointerScreenX = null;
609
- this.pointerScreenY = null;
610
- this.everMovedUp = false;
611
- this.everMovedDown = false;
612
- this.everMovedLeft = false;
613
- this.everMovedRight = false;
614
- this.handleMove(pageX, pageY);
615
- }
616
- };
617
- AutoScroller.prototype.handleMove = function (pageX, pageY) {
618
- if (this.isEnabled) {
619
- var pointerScreenX = pageX - window.pageXOffset;
620
- var pointerScreenY = pageY - window.pageYOffset;
621
- var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
622
- var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
623
- if (yDelta < 0) {
624
- this.everMovedUp = true;
625
- }
626
- else if (yDelta > 0) {
627
- this.everMovedDown = true;
628
- }
629
- if (xDelta < 0) {
630
- this.everMovedLeft = true;
631
- }
632
- else if (xDelta > 0) {
633
- this.everMovedRight = true;
634
- }
635
- this.pointerScreenX = pointerScreenX;
636
- this.pointerScreenY = pointerScreenY;
637
- if (!this.isAnimating) {
638
- this.isAnimating = true;
639
- this.requestAnimation(getTime());
640
- }
641
- }
642
- };
643
- AutoScroller.prototype.stop = function () {
644
- if (this.isEnabled) {
645
- this.isAnimating = false; // will stop animation
646
- for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
647
- var scrollCache = _a[_i];
648
- scrollCache.destroy();
649
- }
650
- this.scrollCaches = null;
651
- }
652
- };
653
- AutoScroller.prototype.requestAnimation = function (now) {
654
- this.msSinceRequest = now;
655
- requestAnimationFrame(this.animate);
656
- };
657
- AutoScroller.prototype.handleSide = function (edge, seconds) {
658
- var scrollCache = edge.scrollCache;
659
- var edgeThreshold = this.edgeThreshold;
660
- var invDistance = edgeThreshold - edge.distance;
661
- var velocity = // the closer to the edge, the faster we scroll
662
- ((invDistance * invDistance) / (edgeThreshold * edgeThreshold)) * // quadratic
663
- this.maxVelocity * seconds;
664
- var sign = 1;
665
- switch (edge.name) {
666
- case 'left':
667
- sign = -1;
668
- // falls through
669
- case 'right':
670
- scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
671
- break;
672
- case 'top':
673
- sign = -1;
674
- // falls through
675
- case 'bottom':
676
- scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
677
- break;
678
- }
679
- };
680
- // left/top are relative to document topleft
681
- AutoScroller.prototype.computeBestEdge = function (left, top) {
682
- var edgeThreshold = this.edgeThreshold;
683
- var bestSide = null;
684
- var scrollCaches = this.scrollCaches || [];
685
- for (var _i = 0, scrollCaches_1 = scrollCaches; _i < scrollCaches_1.length; _i++) {
686
- var scrollCache = scrollCaches_1[_i];
687
- var rect = scrollCache.clientRect;
688
- var leftDist = left - rect.left;
689
- var rightDist = rect.right - left;
690
- var topDist = top - rect.top;
691
- var bottomDist = rect.bottom - top;
692
- // completely within the rect?
693
- if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
694
- if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
695
- (!bestSide || bestSide.distance > topDist)) {
696
- bestSide = { scrollCache: scrollCache, name: 'top', distance: topDist };
697
- }
698
- if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
699
- (!bestSide || bestSide.distance > bottomDist)) {
700
- bestSide = { scrollCache: scrollCache, name: 'bottom', distance: bottomDist };
701
- }
702
- if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
703
- (!bestSide || bestSide.distance > leftDist)) {
704
- bestSide = { scrollCache: scrollCache, name: 'left', distance: leftDist };
705
- }
706
- if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
707
- (!bestSide || bestSide.distance > rightDist)) {
708
- bestSide = { scrollCache: scrollCache, name: 'right', distance: rightDist };
709
- }
710
- }
711
- }
712
- return bestSide;
713
- };
714
- AutoScroller.prototype.buildCaches = function (scrollStartEl) {
715
- return this.queryScrollEls(scrollStartEl).map(function (el) {
716
- if (el === window) {
717
- return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
718
- }
719
- return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
720
- });
721
- };
722
- AutoScroller.prototype.queryScrollEls = function (scrollStartEl) {
723
- var els = [];
724
- for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
725
- var query = _a[_i];
726
- if (typeof query === 'object') {
727
- els.push(query);
728
- }
729
- else {
730
- els.push.apply(els, Array.prototype.slice.call(common.getElRoot(scrollStartEl).querySelectorAll(query)));
731
- }
732
- }
733
- return els;
734
- };
735
- return AutoScroller;
736
- }());
737
-
738
- /*
739
- Monitors dragging on an element. Has a number of high-level features:
740
- - minimum distance required before dragging
741
- - minimum wait time ("delay") before dragging
742
- - a mirror element that follows the pointer
743
- */
744
- var FeaturefulElementDragging = /** @class */ (function (_super) {
745
- __extends(FeaturefulElementDragging, _super);
746
- function FeaturefulElementDragging(containerEl, selector) {
747
- var _this = _super.call(this, containerEl) || this;
748
- _this.containerEl = containerEl;
749
- // options that can be directly set by caller
750
- // the caller can also set the PointerDragging's options as well
751
- _this.delay = null;
752
- _this.minDistance = 0;
753
- _this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
754
- _this.mirrorNeedsRevert = false;
755
- _this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
756
- _this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
757
- _this.isDelayEnded = false;
758
- _this.isDistanceSurpassed = false;
759
- _this.delayTimeoutId = null;
760
- _this.onPointerDown = function (ev) {
761
- if (!_this.isDragging) { // so new drag doesn't happen while revert animation is going
762
- _this.isInteracting = true;
763
- _this.isDelayEnded = false;
764
- _this.isDistanceSurpassed = false;
765
- common.preventSelection(document.body);
766
- common.preventContextMenu(document.body);
767
- // prevent links from being visited if there's an eventual drag.
768
- // also prevents selection in older browsers (maybe?).
769
- // not necessary for touch, besides, browser would complain about passiveness.
770
- if (!ev.isTouch) {
771
- ev.origEvent.preventDefault();
772
- }
773
- _this.emitter.trigger('pointerdown', ev);
774
- if (_this.isInteracting && // not destroyed via pointerdown handler
775
- !_this.pointer.shouldIgnoreMove) {
776
- // actions related to initiating dragstart+dragmove+dragend...
777
- _this.mirror.setIsVisible(false); // reset. caller must set-visible
778
- _this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
779
- _this.startDelay(ev);
780
- if (!_this.minDistance) {
781
- _this.handleDistanceSurpassed(ev);
782
- }
783
- }
784
- }
785
- };
786
- _this.onPointerMove = function (ev) {
787
- if (_this.isInteracting) {
788
- _this.emitter.trigger('pointermove', ev);
789
- if (!_this.isDistanceSurpassed) {
790
- var minDistance = _this.minDistance;
791
- var distanceSq = void 0; // current distance from the origin, squared
792
- var deltaX = ev.deltaX, deltaY = ev.deltaY;
793
- distanceSq = deltaX * deltaX + deltaY * deltaY;
794
- if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
795
- _this.handleDistanceSurpassed(ev);
796
- }
797
- }
798
- if (_this.isDragging) {
799
- // a real pointer move? (not one simulated by scrolling)
800
- if (ev.origEvent.type !== 'scroll') {
801
- _this.mirror.handleMove(ev.pageX, ev.pageY);
802
- _this.autoScroller.handleMove(ev.pageX, ev.pageY);
803
- }
804
- _this.emitter.trigger('dragmove', ev);
805
- }
806
- }
807
- };
808
- _this.onPointerUp = function (ev) {
809
- if (_this.isInteracting) {
810
- _this.isInteracting = false;
811
- common.allowSelection(document.body);
812
- common.allowContextMenu(document.body);
813
- _this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
814
- if (_this.isDragging) {
815
- _this.autoScroller.stop();
816
- _this.tryStopDrag(ev); // which will stop the mirror
817
- }
818
- if (_this.delayTimeoutId) {
819
- clearTimeout(_this.delayTimeoutId);
820
- _this.delayTimeoutId = null;
821
- }
822
- }
823
- };
824
- var pointer = _this.pointer = new PointerDragging(containerEl);
825
- pointer.emitter.on('pointerdown', _this.onPointerDown);
826
- pointer.emitter.on('pointermove', _this.onPointerMove);
827
- pointer.emitter.on('pointerup', _this.onPointerUp);
828
- if (selector) {
829
- pointer.selector = selector;
830
- }
831
- _this.mirror = new ElementMirror();
832
- _this.autoScroller = new AutoScroller();
833
- return _this;
834
- }
835
- FeaturefulElementDragging.prototype.destroy = function () {
836
- this.pointer.destroy();
837
- // HACK: simulate a pointer-up to end the current drag
838
- // TODO: fire 'dragend' directly and stop interaction. discourage use of pointerup event (b/c might not fire)
839
- this.onPointerUp({});
840
- };
841
- FeaturefulElementDragging.prototype.startDelay = function (ev) {
842
- var _this = this;
843
- if (typeof this.delay === 'number') {
844
- this.delayTimeoutId = setTimeout(function () {
845
- _this.delayTimeoutId = null;
846
- _this.handleDelayEnd(ev);
847
- }, this.delay); // not assignable to number!
848
- }
849
- else {
850
- this.handleDelayEnd(ev);
851
- }
852
- };
853
- FeaturefulElementDragging.prototype.handleDelayEnd = function (ev) {
854
- this.isDelayEnded = true;
855
- this.tryStartDrag(ev);
856
- };
857
- FeaturefulElementDragging.prototype.handleDistanceSurpassed = function (ev) {
858
- this.isDistanceSurpassed = true;
859
- this.tryStartDrag(ev);
860
- };
861
- FeaturefulElementDragging.prototype.tryStartDrag = function (ev) {
862
- if (this.isDelayEnded && this.isDistanceSurpassed) {
863
- if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
864
- this.isDragging = true;
865
- this.mirrorNeedsRevert = false;
866
- this.autoScroller.start(ev.pageX, ev.pageY, this.containerEl);
867
- this.emitter.trigger('dragstart', ev);
868
- if (this.touchScrollAllowed === false) {
869
- this.pointer.cancelTouchScroll();
870
- }
871
- }
872
- }
873
- };
874
- FeaturefulElementDragging.prototype.tryStopDrag = function (ev) {
875
- // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
876
- // that come from the document to fire beforehand. much more convenient this way.
877
- this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
878
- };
879
- FeaturefulElementDragging.prototype.stopDrag = function (ev) {
880
- this.isDragging = false;
881
- this.emitter.trigger('dragend', ev);
882
- };
883
- // fill in the implementations...
884
- FeaturefulElementDragging.prototype.setIgnoreMove = function (bool) {
885
- this.pointer.shouldIgnoreMove = bool;
886
- };
887
- FeaturefulElementDragging.prototype.setMirrorIsVisible = function (bool) {
888
- this.mirror.setIsVisible(bool);
889
- };
890
- FeaturefulElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
891
- this.mirrorNeedsRevert = bool;
892
- };
893
- FeaturefulElementDragging.prototype.setAutoScrollEnabled = function (bool) {
894
- this.autoScroller.isEnabled = bool;
895
- };
896
- return FeaturefulElementDragging;
897
- }(common.ElementDragging));
898
-
899
- /*
900
- When this class is instantiated, it records the offset of an element (relative to the document topleft),
901
- and continues to monitor scrolling, updating the cached coordinates if it needs to.
902
- Does not access the DOM after instantiation, so highly performant.
903
-
904
- Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
905
- and an determine if a given point is inside the combined clipping rectangle.
906
- */
907
- var OffsetTracker = /** @class */ (function () {
908
- function OffsetTracker(el) {
909
- this.origRect = common.computeRect(el);
910
- // will work fine for divs that have overflow:hidden
911
- this.scrollCaches = common.getClippingParents(el).map(function (scrollEl) { return new ElementScrollGeomCache(scrollEl, true); });
912
- }
913
- OffsetTracker.prototype.destroy = function () {
914
- for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
915
- var scrollCache = _a[_i];
916
- scrollCache.destroy();
917
- }
918
- };
919
- OffsetTracker.prototype.computeLeft = function () {
920
- var left = this.origRect.left;
921
- for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
922
- var scrollCache = _a[_i];
923
- left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
924
- }
925
- return left;
926
- };
927
- OffsetTracker.prototype.computeTop = function () {
928
- var top = this.origRect.top;
929
- for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
930
- var scrollCache = _a[_i];
931
- top += scrollCache.origScrollTop - scrollCache.getScrollTop();
932
- }
933
- return top;
934
- };
935
- OffsetTracker.prototype.isWithinClipping = function (pageX, pageY) {
936
- var point = { left: pageX, top: pageY };
937
- for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
938
- var scrollCache = _a[_i];
939
- if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
940
- !common.pointInsideRect(point, scrollCache.clientRect)) {
941
- return false;
942
- }
943
- }
944
- return true;
945
- };
946
- return OffsetTracker;
947
- }());
948
- // certain clipping containers should never constrain interactions, like <html> and <body>
949
- // https://github.com/fullcalendar/fullcalendar/issues/3615
950
- function isIgnoredClipping(node) {
951
- var tagName = node.tagName;
952
- return tagName === 'HTML' || tagName === 'BODY';
953
- }
954
-
955
- /*
956
- Tracks movement over multiple droppable areas (aka "hits")
957
- that exist in one or more DateComponents.
958
- Relies on an existing draggable.
959
-
960
- emits:
961
- - pointerdown
962
- - dragstart
963
- - hitchange - fires initially, even if not over a hit
964
- - pointerup
965
- - (hitchange - again, to null, if ended over a hit)
966
- - dragend
967
- */
968
- var HitDragging = /** @class */ (function () {
969
- function HitDragging(dragging, droppableStore) {
970
- var _this = this;
971
- // options that can be set by caller
972
- this.useSubjectCenter = false;
973
- this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
974
- this.initialHit = null;
975
- this.movingHit = null;
976
- this.finalHit = null; // won't ever be populated if shouldIgnoreMove
977
- this.handlePointerDown = function (ev) {
978
- var dragging = _this.dragging;
979
- _this.initialHit = null;
980
- _this.movingHit = null;
981
- _this.finalHit = null;
982
- _this.prepareHits();
983
- _this.processFirstCoord(ev);
984
- if (_this.initialHit || !_this.requireInitial) {
985
- dragging.setIgnoreMove(false);
986
- // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
987
- _this.emitter.trigger('pointerdown', ev);
988
- }
989
- else {
990
- dragging.setIgnoreMove(true);
991
- }
992
- };
993
- this.handleDragStart = function (ev) {
994
- _this.emitter.trigger('dragstart', ev);
995
- _this.handleMove(ev, true); // force = fire even if initially null
996
- };
997
- this.handleDragMove = function (ev) {
998
- _this.emitter.trigger('dragmove', ev);
999
- _this.handleMove(ev);
1000
- };
1001
- this.handlePointerUp = function (ev) {
1002
- _this.releaseHits();
1003
- _this.emitter.trigger('pointerup', ev);
1004
- };
1005
- this.handleDragEnd = function (ev) {
1006
- if (_this.movingHit) {
1007
- _this.emitter.trigger('hitupdate', null, true, ev);
1008
- }
1009
- _this.finalHit = _this.movingHit;
1010
- _this.movingHit = null;
1011
- _this.emitter.trigger('dragend', ev);
1012
- };
1013
- this.droppableStore = droppableStore;
1014
- dragging.emitter.on('pointerdown', this.handlePointerDown);
1015
- dragging.emitter.on('dragstart', this.handleDragStart);
1016
- dragging.emitter.on('dragmove', this.handleDragMove);
1017
- dragging.emitter.on('pointerup', this.handlePointerUp);
1018
- dragging.emitter.on('dragend', this.handleDragEnd);
1019
- this.dragging = dragging;
1020
- this.emitter = new common.Emitter();
1021
- }
1022
- // sets initialHit
1023
- // sets coordAdjust
1024
- HitDragging.prototype.processFirstCoord = function (ev) {
1025
- var origPoint = { left: ev.pageX, top: ev.pageY };
1026
- var adjustedPoint = origPoint;
1027
- var subjectEl = ev.subjectEl;
1028
- var subjectRect;
1029
- if (subjectEl instanceof HTMLElement) { // i.e. not a Document/ShadowRoot
1030
- subjectRect = common.computeRect(subjectEl);
1031
- adjustedPoint = common.constrainPoint(adjustedPoint, subjectRect);
1032
- }
1033
- var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
1034
- if (initialHit) {
1035
- if (this.useSubjectCenter && subjectRect) {
1036
- var slicedSubjectRect = common.intersectRects(subjectRect, initialHit.rect);
1037
- if (slicedSubjectRect) {
1038
- adjustedPoint = common.getRectCenter(slicedSubjectRect);
1039
- }
1040
- }
1041
- this.coordAdjust = common.diffPoints(adjustedPoint, origPoint);
1042
- }
1043
- else {
1044
- this.coordAdjust = { left: 0, top: 0 };
1045
- }
1046
- };
1047
- HitDragging.prototype.handleMove = function (ev, forceHandle) {
1048
- var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
1049
- if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
1050
- this.movingHit = hit;
1051
- this.emitter.trigger('hitupdate', hit, false, ev);
1052
- }
1053
- };
1054
- HitDragging.prototype.prepareHits = function () {
1055
- this.offsetTrackers = common.mapHash(this.droppableStore, function (interactionSettings) {
1056
- interactionSettings.component.prepareHits();
1057
- return new OffsetTracker(interactionSettings.el);
1058
- });
1059
- };
1060
- HitDragging.prototype.releaseHits = function () {
1061
- var offsetTrackers = this.offsetTrackers;
1062
- for (var id in offsetTrackers) {
1063
- offsetTrackers[id].destroy();
1064
- }
1065
- this.offsetTrackers = {};
1066
- };
1067
- HitDragging.prototype.queryHitForOffset = function (offsetLeft, offsetTop) {
1068
- var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
1069
- var bestHit = null;
1070
- for (var id in droppableStore) {
1071
- var component = droppableStore[id].component;
1072
- var offsetTracker = offsetTrackers[id];
1073
- if (offsetTracker && // wasn't destroyed mid-drag
1074
- offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
1075
- var originLeft = offsetTracker.computeLeft();
1076
- var originTop = offsetTracker.computeTop();
1077
- var positionLeft = offsetLeft - originLeft;
1078
- var positionTop = offsetTop - originTop;
1079
- var origRect = offsetTracker.origRect;
1080
- var width = origRect.right - origRect.left;
1081
- var height = origRect.bottom - origRect.top;
1082
- if (
1083
- // must be within the element's bounds
1084
- positionLeft >= 0 && positionLeft < width &&
1085
- positionTop >= 0 && positionTop < height) {
1086
- var hit = component.queryHit(positionLeft, positionTop, width, height);
1087
- if (hit && (
1088
- // make sure the hit is within activeRange, meaning it's not a dead cell
1089
- common.rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range)) &&
1090
- (!bestHit || hit.layer > bestHit.layer)) {
1091
- hit.componentId = id;
1092
- hit.context = component.context;
1093
- // TODO: better way to re-orient rectangle
1094
- hit.rect.left += originLeft;
1095
- hit.rect.right += originLeft;
1096
- hit.rect.top += originTop;
1097
- hit.rect.bottom += originTop;
1098
- bestHit = hit;
1099
- }
1100
- }
1101
- }
1102
- }
1103
- return bestHit;
1104
- };
1105
- return HitDragging;
1106
- }());
1107
- function isHitsEqual(hit0, hit1) {
1108
- if (!hit0 && !hit1) {
1109
- return true;
1110
- }
1111
- if (Boolean(hit0) !== Boolean(hit1)) {
1112
- return false;
1113
- }
1114
- return common.isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
1115
- }
1116
-
1117
- function buildDatePointApiWithContext(dateSpan, context) {
1118
- var props = {};
1119
- for (var _i = 0, _a = context.pluginHooks.datePointTransforms; _i < _a.length; _i++) {
1120
- var transform = _a[_i];
1121
- __assign(props, transform(dateSpan, context));
1122
- }
1123
- __assign(props, buildDatePointApi(dateSpan, context.dateEnv));
1124
- return props;
1125
- }
1126
- function buildDatePointApi(span, dateEnv) {
1127
- return {
1128
- date: dateEnv.toDate(span.range.start),
1129
- dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
1130
- allDay: span.allDay,
1131
- };
1132
- }
1133
-
1134
- /*
1135
- Monitors when the user clicks on a specific date/time of a component.
1136
- A pointerdown+pointerup on the same "hit" constitutes a click.
1137
- */
1138
- var DateClicking = /** @class */ (function (_super) {
1139
- __extends(DateClicking, _super);
1140
- function DateClicking(settings) {
1141
- var _this = _super.call(this, settings) || this;
1142
- _this.handlePointerDown = function (pev) {
1143
- var dragging = _this.dragging;
1144
- var downEl = pev.origEvent.target;
1145
- // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
1146
- dragging.setIgnoreMove(!_this.component.isValidDateDownEl(downEl));
1147
- };
1148
- // won't even fire if moving was ignored
1149
- _this.handleDragEnd = function (ev) {
1150
- var component = _this.component;
1151
- var pointer = _this.dragging.pointer;
1152
- if (!pointer.wasTouchScroll) {
1153
- var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
1154
- if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
1155
- var context = component.context;
1156
- var arg = __assign(__assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
1157
- context.emitter.trigger('dateClick', arg);
1158
- }
1159
- }
1160
- };
1161
- // we DO want to watch pointer moves because otherwise finalHit won't get populated
1162
- _this.dragging = new FeaturefulElementDragging(settings.el);
1163
- _this.dragging.autoScroller.isEnabled = false;
1164
- var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, common.interactionSettingsToStore(settings));
1165
- hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1166
- hitDragging.emitter.on('dragend', _this.handleDragEnd);
1167
- return _this;
1168
- }
1169
- DateClicking.prototype.destroy = function () {
1170
- this.dragging.destroy();
1171
- };
1172
- return DateClicking;
1173
- }(common.Interaction));
1174
-
1175
- /*
1176
- Tracks when the user selects a portion of time of a component,
1177
- constituted by a drag over date cells, with a possible delay at the beginning of the drag.
1178
- */
1179
- var DateSelecting = /** @class */ (function (_super) {
1180
- __extends(DateSelecting, _super);
1181
- function DateSelecting(settings) {
1182
- var _this = _super.call(this, settings) || this;
1183
- _this.dragSelection = null;
1184
- _this.handlePointerDown = function (ev) {
1185
- var _a = _this, component = _a.component, dragging = _a.dragging;
1186
- var options = component.context.options;
1187
- var canSelect = options.selectable &&
1188
- component.isValidDateDownEl(ev.origEvent.target);
1189
- // don't bother to watch expensive moves if component won't do selection
1190
- dragging.setIgnoreMove(!canSelect);
1191
- // if touch, require user to hold down
1192
- dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
1193
- };
1194
- _this.handleDragStart = function (ev) {
1195
- _this.component.context.calendarApi.unselect(ev); // unselect previous selections
1196
- };
1197
- _this.handleHitUpdate = function (hit, isFinal) {
1198
- var context = _this.component.context;
1199
- var dragSelection = null;
1200
- var isInvalid = false;
1201
- if (hit) {
1202
- var initialHit = _this.hitDragging.initialHit;
1203
- var disallowed = hit.componentId === initialHit.componentId
1204
- && _this.isHitComboAllowed
1205
- && !_this.isHitComboAllowed(initialHit, hit);
1206
- if (!disallowed) {
1207
- dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
1208
- }
1209
- if (!dragSelection || !common.isDateSelectionValid(dragSelection, hit.dateProfile, context)) {
1210
- isInvalid = true;
1211
- dragSelection = null;
1212
- }
1213
- }
1214
- if (dragSelection) {
1215
- context.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
1216
- }
1217
- else if (!isFinal) { // only unselect if moved away while dragging
1218
- context.dispatch({ type: 'UNSELECT_DATES' });
1219
- }
1220
- if (!isInvalid) {
1221
- common.enableCursor();
1222
- }
1223
- else {
1224
- common.disableCursor();
1225
- }
1226
- if (!isFinal) {
1227
- _this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
1228
- }
1229
- };
1230
- _this.handlePointerUp = function (pev) {
1231
- if (_this.dragSelection) {
1232
- // selection is already rendered, so just need to report selection
1233
- common.triggerDateSelect(_this.dragSelection, pev, _this.component.context);
1234
- _this.dragSelection = null;
1235
- }
1236
- };
1237
- var component = settings.component;
1238
- var options = component.context.options;
1239
- var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
1240
- dragging.touchScrollAllowed = false;
1241
- dragging.minDistance = options.selectMinDistance || 0;
1242
- dragging.autoScroller.isEnabled = options.dragScroll;
1243
- var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, common.interactionSettingsToStore(settings));
1244
- hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1245
- hitDragging.emitter.on('dragstart', _this.handleDragStart);
1246
- hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
1247
- hitDragging.emitter.on('pointerup', _this.handlePointerUp);
1248
- return _this;
1249
- }
1250
- DateSelecting.prototype.destroy = function () {
1251
- this.dragging.destroy();
1252
- };
1253
- return DateSelecting;
1254
- }(common.Interaction));
1255
- function getComponentTouchDelay$1(component) {
1256
- var options = component.context.options;
1257
- var delay = options.selectLongPressDelay;
1258
- if (delay == null) {
1259
- delay = options.longPressDelay;
1260
- }
1261
- return delay;
1262
- }
1263
- function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
1264
- var dateSpan0 = hit0.dateSpan;
1265
- var dateSpan1 = hit1.dateSpan;
1266
- var ms = [
1267
- dateSpan0.range.start,
1268
- dateSpan0.range.end,
1269
- dateSpan1.range.start,
1270
- dateSpan1.range.end,
1271
- ];
1272
- ms.sort(common.compareNumbers);
1273
- var props = {};
1274
- for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
1275
- var transformer = dateSelectionTransformers_1[_i];
1276
- var res = transformer(hit0, hit1);
1277
- if (res === false) {
1278
- return null;
1279
- }
1280
- if (res) {
1281
- __assign(props, res);
1282
- }
1283
- }
1284
- props.range = { start: ms[0], end: ms[3] };
1285
- props.allDay = dateSpan0.allDay;
1286
- return props;
1287
- }
1288
-
1289
- var EventDragging = /** @class */ (function (_super) {
1290
- __extends(EventDragging, _super);
1291
- function EventDragging(settings) {
1292
- var _this = _super.call(this, settings) || this;
1293
- // internal state
1294
- _this.subjectEl = null;
1295
- _this.subjectSeg = null; // the seg being selected/dragged
1296
- _this.isDragging = false;
1297
- _this.eventRange = null;
1298
- _this.relevantEvents = null; // the events being dragged
1299
- _this.receivingContext = null;
1300
- _this.validMutation = null;
1301
- _this.mutatedRelevantEvents = null;
1302
- _this.handlePointerDown = function (ev) {
1303
- var origTarget = ev.origEvent.target;
1304
- var _a = _this, component = _a.component, dragging = _a.dragging;
1305
- var mirror = dragging.mirror;
1306
- var options = component.context.options;
1307
- var initialContext = component.context;
1308
- _this.subjectEl = ev.subjectEl;
1309
- var subjectSeg = _this.subjectSeg = common.getElSeg(ev.subjectEl);
1310
- var eventRange = _this.eventRange = subjectSeg.eventRange;
1311
- var eventInstanceId = eventRange.instance.instanceId;
1312
- _this.relevantEvents = common.getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
1313
- dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
1314
- dragging.delay =
1315
- // only do a touch delay if touch and this event hasn't been selected yet
1316
- (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
1317
- getComponentTouchDelay(component) :
1318
- null;
1319
- if (options.fixedMirrorParent) {
1320
- mirror.parentNode = options.fixedMirrorParent;
1321
- }
1322
- else {
1323
- mirror.parentNode = common.elementClosest(origTarget, '.fc');
1324
- }
1325
- mirror.revertDuration = options.dragRevertDuration;
1326
- var isValid = component.isValidSegDownEl(origTarget) &&
1327
- !common.elementClosest(origTarget, '.fc-event-resizer'); // NOT on a resizer
1328
- dragging.setIgnoreMove(!isValid);
1329
- // disable dragging for elements that are resizable (ie, selectable)
1330
- // but are not draggable
1331
- _this.isDragging = isValid &&
1332
- ev.subjectEl.classList.contains('fc-event-draggable');
1333
- };
1334
- _this.handleDragStart = function (ev) {
1335
- var initialContext = _this.component.context;
1336
- var eventRange = _this.eventRange;
1337
- var eventInstanceId = eventRange.instance.instanceId;
1338
- if (ev.isTouch) {
1339
- // need to select a different event?
1340
- if (eventInstanceId !== _this.component.props.eventSelection) {
1341
- initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId: eventInstanceId });
1342
- }
1343
- }
1344
- else {
1345
- // if now using mouse, but was previous touch interaction, clear selected event
1346
- initialContext.dispatch({ type: 'UNSELECT_EVENT' });
1347
- }
1348
- if (_this.isDragging) {
1349
- initialContext.calendarApi.unselect(ev); // unselect *date* selection
1350
- initialContext.emitter.trigger('eventDragStart', {
1351
- el: _this.subjectEl,
1352
- event: new common.EventApi(initialContext, eventRange.def, eventRange.instance),
1353
- jsEvent: ev.origEvent,
1354
- view: initialContext.viewApi,
1355
- });
1356
- }
1357
- };
1358
- _this.handleHitUpdate = function (hit, isFinal) {
1359
- if (!_this.isDragging) {
1360
- return;
1361
- }
1362
- var relevantEvents = _this.relevantEvents;
1363
- var initialHit = _this.hitDragging.initialHit;
1364
- var initialContext = _this.component.context;
1365
- // states based on new hit
1366
- var receivingContext = null;
1367
- var mutation = null;
1368
- var mutatedRelevantEvents = null;
1369
- var isInvalid = false;
1370
- var interaction = {
1371
- affectedEvents: relevantEvents,
1372
- mutatedEvents: common.createEmptyEventStore(),
1373
- isEvent: true,
1374
- };
1375
- if (hit) {
1376
- receivingContext = hit.context;
1377
- var receivingOptions = receivingContext.options;
1378
- if (initialContext === receivingContext ||
1379
- (receivingOptions.editable && receivingOptions.droppable)) {
1380
- mutation = computeEventMutation(initialHit, hit, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
1381
- if (mutation) {
1382
- mutatedRelevantEvents = common.applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
1383
- interaction.mutatedEvents = mutatedRelevantEvents;
1384
- if (!common.isInteractionValid(interaction, hit.dateProfile, receivingContext)) {
1385
- isInvalid = true;
1386
- mutation = null;
1387
- mutatedRelevantEvents = null;
1388
- interaction.mutatedEvents = common.createEmptyEventStore();
1389
- }
1390
- }
1391
- }
1392
- else {
1393
- receivingContext = null;
1394
- }
1395
- }
1396
- _this.displayDrag(receivingContext, interaction);
1397
- if (!isInvalid) {
1398
- common.enableCursor();
1399
- }
1400
- else {
1401
- common.disableCursor();
1402
- }
1403
- if (!isFinal) {
1404
- if (initialContext === receivingContext && // TODO: write test for this
1405
- isHitsEqual(initialHit, hit)) {
1406
- mutation = null;
1407
- }
1408
- _this.dragging.setMirrorNeedsRevert(!mutation);
1409
- // render the mirror if no already-rendered mirror
1410
- // TODO: wish we could somehow wait for dispatch to guarantee render
1411
- _this.dragging.setMirrorIsVisible(!hit || !common.getElRoot(_this.subjectEl).querySelector('.fc-event-mirror'));
1412
- // assign states based on new hit
1413
- _this.receivingContext = receivingContext;
1414
- _this.validMutation = mutation;
1415
- _this.mutatedRelevantEvents = mutatedRelevantEvents;
1416
- }
1417
- };
1418
- _this.handlePointerUp = function () {
1419
- if (!_this.isDragging) {
1420
- _this.cleanup(); // because handleDragEnd won't fire
1421
- }
1422
- };
1423
- _this.handleDragEnd = function (ev) {
1424
- if (_this.isDragging) {
1425
- var initialContext_1 = _this.component.context;
1426
- var initialView = initialContext_1.viewApi;
1427
- var _a = _this, receivingContext_1 = _a.receivingContext, validMutation = _a.validMutation;
1428
- var eventDef = _this.eventRange.def;
1429
- var eventInstance = _this.eventRange.instance;
1430
- var eventApi = new common.EventApi(initialContext_1, eventDef, eventInstance);
1431
- var relevantEvents_1 = _this.relevantEvents;
1432
- var mutatedRelevantEvents_1 = _this.mutatedRelevantEvents;
1433
- var finalHit = _this.hitDragging.finalHit;
1434
- _this.clearDrag(); // must happen after revert animation
1435
- initialContext_1.emitter.trigger('eventDragStop', {
1436
- el: _this.subjectEl,
1437
- event: eventApi,
1438
- jsEvent: ev.origEvent,
1439
- view: initialView,
1440
- });
1441
- if (validMutation) {
1442
- // dropped within same calendar
1443
- if (receivingContext_1 === initialContext_1) {
1444
- var updatedEventApi = new common.EventApi(initialContext_1, mutatedRelevantEvents_1.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents_1.instances[eventInstance.instanceId] : null);
1445
- initialContext_1.dispatch({
1446
- type: 'MERGE_EVENTS',
1447
- eventStore: mutatedRelevantEvents_1,
1448
- });
1449
- var eventChangeArg = {
1450
- oldEvent: eventApi,
1451
- event: updatedEventApi,
1452
- relatedEvents: common.buildEventApis(mutatedRelevantEvents_1, initialContext_1, eventInstance),
1453
- revert: function () {
1454
- initialContext_1.dispatch({
1455
- type: 'MERGE_EVENTS',
1456
- eventStore: relevantEvents_1, // the pre-change data
1457
- });
1458
- },
1459
- };
1460
- var transformed = {};
1461
- for (var _i = 0, _b = initialContext_1.getCurrentData().pluginHooks.eventDropTransformers; _i < _b.length; _i++) {
1462
- var transformer = _b[_i];
1463
- __assign(transformed, transformer(validMutation, initialContext_1));
1464
- }
1465
- initialContext_1.emitter.trigger('eventDrop', __assign(__assign(__assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
1466
- initialContext_1.emitter.trigger('eventChange', eventChangeArg);
1467
- // dropped in different calendar
1468
- }
1469
- else if (receivingContext_1) {
1470
- var eventRemoveArg = {
1471
- event: eventApi,
1472
- relatedEvents: common.buildEventApis(relevantEvents_1, initialContext_1, eventInstance),
1473
- revert: function () {
1474
- initialContext_1.dispatch({
1475
- type: 'MERGE_EVENTS',
1476
- eventStore: relevantEvents_1,
1477
- });
1478
- },
1479
- };
1480
- initialContext_1.emitter.trigger('eventLeave', __assign(__assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
1481
- initialContext_1.dispatch({
1482
- type: 'REMOVE_EVENTS',
1483
- eventStore: relevantEvents_1,
1484
- });
1485
- initialContext_1.emitter.trigger('eventRemove', eventRemoveArg);
1486
- var addedEventDef = mutatedRelevantEvents_1.defs[eventDef.defId];
1487
- var addedEventInstance = mutatedRelevantEvents_1.instances[eventInstance.instanceId];
1488
- var addedEventApi = new common.EventApi(receivingContext_1, addedEventDef, addedEventInstance);
1489
- receivingContext_1.dispatch({
1490
- type: 'MERGE_EVENTS',
1491
- eventStore: mutatedRelevantEvents_1,
1492
- });
1493
- var eventAddArg = {
1494
- event: addedEventApi,
1495
- relatedEvents: common.buildEventApis(mutatedRelevantEvents_1, receivingContext_1, addedEventInstance),
1496
- revert: function () {
1497
- receivingContext_1.dispatch({
1498
- type: 'REMOVE_EVENTS',
1499
- eventStore: mutatedRelevantEvents_1,
1500
- });
1501
- },
1502
- };
1503
- receivingContext_1.emitter.trigger('eventAdd', eventAddArg);
1504
- if (ev.isTouch) {
1505
- receivingContext_1.dispatch({
1506
- type: 'SELECT_EVENT',
1507
- eventInstanceId: eventInstance.instanceId,
1508
- });
1509
- }
1510
- receivingContext_1.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext_1)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.context.viewApi }));
1511
- receivingContext_1.emitter.trigger('eventReceive', __assign(__assign({}, eventAddArg), { draggedEl: ev.subjectEl, view: finalHit.context.viewApi }));
1512
- }
1513
- }
1514
- else {
1515
- initialContext_1.emitter.trigger('_noEventDrop');
1516
- }
1517
- }
1518
- _this.cleanup();
1519
- };
1520
- var component = _this.component;
1521
- var options = component.context.options;
1522
- var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
1523
- dragging.pointer.selector = EventDragging.SELECTOR;
1524
- dragging.touchScrollAllowed = false;
1525
- dragging.autoScroller.isEnabled = options.dragScroll;
1526
- var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, common.interactionSettingsStore);
1527
- hitDragging.useSubjectCenter = settings.useEventCenter;
1528
- hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1529
- hitDragging.emitter.on('dragstart', _this.handleDragStart);
1530
- hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
1531
- hitDragging.emitter.on('pointerup', _this.handlePointerUp);
1532
- hitDragging.emitter.on('dragend', _this.handleDragEnd);
1533
- return _this;
1534
- }
1535
- EventDragging.prototype.destroy = function () {
1536
- this.dragging.destroy();
1537
- };
1538
- // render a drag state on the next receivingCalendar
1539
- EventDragging.prototype.displayDrag = function (nextContext, state) {
1540
- var initialContext = this.component.context;
1541
- var prevContext = this.receivingContext;
1542
- // does the previous calendar need to be cleared?
1543
- if (prevContext && prevContext !== nextContext) {
1544
- // does the initial calendar need to be cleared?
1545
- // if so, don't clear all the way. we still need to to hide the affectedEvents
1546
- if (prevContext === initialContext) {
1547
- prevContext.dispatch({
1548
- type: 'SET_EVENT_DRAG',
1549
- state: {
1550
- affectedEvents: state.affectedEvents,
1551
- mutatedEvents: common.createEmptyEventStore(),
1552
- isEvent: true,
1553
- },
1554
- });
1555
- // completely clear the old calendar if it wasn't the initial
1556
- }
1557
- else {
1558
- prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
1559
- }
1560
- }
1561
- if (nextContext) {
1562
- nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
1563
- }
1564
- };
1565
- EventDragging.prototype.clearDrag = function () {
1566
- var initialCalendar = this.component.context;
1567
- var receivingContext = this.receivingContext;
1568
- if (receivingContext) {
1569
- receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
1570
- }
1571
- // the initial calendar might have an dummy drag state from displayDrag
1572
- if (initialCalendar !== receivingContext) {
1573
- initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
1574
- }
1575
- };
1576
- EventDragging.prototype.cleanup = function () {
1577
- this.subjectSeg = null;
1578
- this.isDragging = false;
1579
- this.eventRange = null;
1580
- this.relevantEvents = null;
1581
- this.receivingContext = null;
1582
- this.validMutation = null;
1583
- this.mutatedRelevantEvents = null;
1584
- };
1585
- // TODO: test this in IE11
1586
- // QUESTION: why do we need it on the resizable???
1587
- EventDragging.SELECTOR = '.fc-event-draggable, .fc-event-resizable';
1588
- return EventDragging;
1589
- }(common.Interaction));
1590
- function computeEventMutation(hit0, hit1, massagers) {
1591
- var dateSpan0 = hit0.dateSpan;
1592
- var dateSpan1 = hit1.dateSpan;
1593
- var date0 = dateSpan0.range.start;
1594
- var date1 = dateSpan1.range.start;
1595
- var standardProps = {};
1596
- if (dateSpan0.allDay !== dateSpan1.allDay) {
1597
- standardProps.allDay = dateSpan1.allDay;
1598
- standardProps.hasEnd = hit1.context.options.allDayMaintainDuration;
1599
- if (dateSpan1.allDay) {
1600
- // means date1 is already start-of-day,
1601
- // but date0 needs to be converted
1602
- date0 = common.startOfDay(date0);
1603
- }
1604
- }
1605
- var delta = common.diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ?
1606
- hit0.largeUnit :
1607
- null);
1608
- if (delta.milliseconds) { // has hours/minutes/seconds
1609
- standardProps.allDay = false;
1610
- }
1611
- var mutation = {
1612
- datesDelta: delta,
1613
- standardProps: standardProps,
1614
- };
1615
- for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
1616
- var massager = massagers_1[_i];
1617
- massager(mutation, hit0, hit1);
1618
- }
1619
- return mutation;
1620
- }
1621
- function getComponentTouchDelay(component) {
1622
- var options = component.context.options;
1623
- var delay = options.eventLongPressDelay;
1624
- if (delay == null) {
1625
- delay = options.longPressDelay;
1626
- }
1627
- return delay;
1628
- }
1629
-
1630
- var EventResizing = /** @class */ (function (_super) {
1631
- __extends(EventResizing, _super);
1632
- function EventResizing(settings) {
1633
- var _this = _super.call(this, settings) || this;
1634
- // internal state
1635
- _this.draggingSegEl = null;
1636
- _this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
1637
- _this.eventRange = null;
1638
- _this.relevantEvents = null;
1639
- _this.validMutation = null;
1640
- _this.mutatedRelevantEvents = null;
1641
- _this.handlePointerDown = function (ev) {
1642
- var component = _this.component;
1643
- var segEl = _this.querySegEl(ev);
1644
- var seg = common.getElSeg(segEl);
1645
- var eventRange = _this.eventRange = seg.eventRange;
1646
- _this.dragging.minDistance = component.context.options.eventDragMinDistance;
1647
- // if touch, need to be working with a selected event
1648
- _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
1649
- (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
1650
- };
1651
- _this.handleDragStart = function (ev) {
1652
- var context = _this.component.context;
1653
- var eventRange = _this.eventRange;
1654
- _this.relevantEvents = common.getRelevantEvents(context.getCurrentData().eventStore, _this.eventRange.instance.instanceId);
1655
- var segEl = _this.querySegEl(ev);
1656
- _this.draggingSegEl = segEl;
1657
- _this.draggingSeg = common.getElSeg(segEl);
1658
- context.calendarApi.unselect();
1659
- context.emitter.trigger('eventResizeStart', {
1660
- el: segEl,
1661
- event: new common.EventApi(context, eventRange.def, eventRange.instance),
1662
- jsEvent: ev.origEvent,
1663
- view: context.viewApi,
1664
- });
1665
- };
1666
- _this.handleHitUpdate = function (hit, isFinal, ev) {
1667
- var context = _this.component.context;
1668
- var relevantEvents = _this.relevantEvents;
1669
- var initialHit = _this.hitDragging.initialHit;
1670
- var eventInstance = _this.eventRange.instance;
1671
- var mutation = null;
1672
- var mutatedRelevantEvents = null;
1673
- var isInvalid = false;
1674
- var interaction = {
1675
- affectedEvents: relevantEvents,
1676
- mutatedEvents: common.createEmptyEventStore(),
1677
- isEvent: true,
1678
- };
1679
- if (hit) {
1680
- var disallowed = hit.componentId === initialHit.componentId
1681
- && _this.isHitComboAllowed
1682
- && !_this.isHitComboAllowed(initialHit, hit);
1683
- if (!disallowed) {
1684
- mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range);
1685
- }
1686
- }
1687
- if (mutation) {
1688
- mutatedRelevantEvents = common.applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
1689
- interaction.mutatedEvents = mutatedRelevantEvents;
1690
- if (!common.isInteractionValid(interaction, hit.dateProfile, context)) {
1691
- isInvalid = true;
1692
- mutation = null;
1693
- mutatedRelevantEvents = null;
1694
- interaction.mutatedEvents = null;
1695
- }
1696
- }
1697
- if (mutatedRelevantEvents) {
1698
- context.dispatch({
1699
- type: 'SET_EVENT_RESIZE',
1700
- state: interaction,
1701
- });
1702
- }
1703
- else {
1704
- context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
1705
- }
1706
- if (!isInvalid) {
1707
- common.enableCursor();
1708
- }
1709
- else {
1710
- common.disableCursor();
1711
- }
1712
- if (!isFinal) {
1713
- if (mutation && isHitsEqual(initialHit, hit)) {
1714
- mutation = null;
1715
- }
1716
- _this.validMutation = mutation;
1717
- _this.mutatedRelevantEvents = mutatedRelevantEvents;
1718
- }
1719
- };
1720
- _this.handleDragEnd = function (ev) {
1721
- var context = _this.component.context;
1722
- var eventDef = _this.eventRange.def;
1723
- var eventInstance = _this.eventRange.instance;
1724
- var eventApi = new common.EventApi(context, eventDef, eventInstance);
1725
- var relevantEvents = _this.relevantEvents;
1726
- var mutatedRelevantEvents = _this.mutatedRelevantEvents;
1727
- context.emitter.trigger('eventResizeStop', {
1728
- el: _this.draggingSegEl,
1729
- event: eventApi,
1730
- jsEvent: ev.origEvent,
1731
- view: context.viewApi,
1732
- });
1733
- if (_this.validMutation) {
1734
- var updatedEventApi = new common.EventApi(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
1735
- context.dispatch({
1736
- type: 'MERGE_EVENTS',
1737
- eventStore: mutatedRelevantEvents,
1738
- });
1739
- var eventChangeArg = {
1740
- oldEvent: eventApi,
1741
- event: updatedEventApi,
1742
- relatedEvents: common.buildEventApis(mutatedRelevantEvents, context, eventInstance),
1743
- revert: function () {
1744
- context.dispatch({
1745
- type: 'MERGE_EVENTS',
1746
- eventStore: relevantEvents, // the pre-change events
1747
- });
1748
- },
1749
- };
1750
- context.emitter.trigger('eventResize', __assign(__assign({}, eventChangeArg), { el: _this.draggingSegEl, startDelta: _this.validMutation.startDelta || common.createDuration(0), endDelta: _this.validMutation.endDelta || common.createDuration(0), jsEvent: ev.origEvent, view: context.viewApi }));
1751
- context.emitter.trigger('eventChange', eventChangeArg);
1752
- }
1753
- else {
1754
- context.emitter.trigger('_noEventResize');
1755
- }
1756
- // reset all internal state
1757
- _this.draggingSeg = null;
1758
- _this.relevantEvents = null;
1759
- _this.validMutation = null;
1760
- // okay to keep eventInstance around. useful to set it in handlePointerDown
1761
- };
1762
- var component = settings.component;
1763
- var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
1764
- dragging.pointer.selector = '.fc-event-resizer';
1765
- dragging.touchScrollAllowed = false;
1766
- dragging.autoScroller.isEnabled = component.context.options.dragScroll;
1767
- var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, common.interactionSettingsToStore(settings));
1768
- hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
1769
- hitDragging.emitter.on('dragstart', _this.handleDragStart);
1770
- hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
1771
- hitDragging.emitter.on('dragend', _this.handleDragEnd);
1772
- return _this;
1773
- }
1774
- EventResizing.prototype.destroy = function () {
1775
- this.dragging.destroy();
1776
- };
1777
- EventResizing.prototype.querySegEl = function (ev) {
1778
- return common.elementClosest(ev.subjectEl, '.fc-event');
1779
- };
1780
- return EventResizing;
1781
- }(common.Interaction));
1782
- function computeMutation(hit0, hit1, isFromStart, instanceRange) {
1783
- var dateEnv = hit0.context.dateEnv;
1784
- var date0 = hit0.dateSpan.range.start;
1785
- var date1 = hit1.dateSpan.range.start;
1786
- var delta = common.diffDates(date0, date1, dateEnv, hit0.largeUnit);
1787
- if (isFromStart) {
1788
- if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
1789
- return { startDelta: delta };
1790
- }
1791
- }
1792
- else if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
1793
- return { endDelta: delta };
1794
- }
1795
- return null;
1796
- }
1797
-
1798
- var UnselectAuto = /** @class */ (function () {
1799
- function UnselectAuto(context) {
1800
- var _this = this;
1801
- this.context = context;
1802
- this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
1803
- this.matchesCancel = false;
1804
- this.matchesEvent = false;
1805
- this.onSelect = function (selectInfo) {
1806
- if (selectInfo.jsEvent) {
1807
- _this.isRecentPointerDateSelect = true;
1808
- }
1809
- };
1810
- this.onDocumentPointerDown = function (pev) {
1811
- var unselectCancel = _this.context.options.unselectCancel;
1812
- var downEl = common.getEventTargetViaRoot(pev.origEvent);
1813
- _this.matchesCancel = !!common.elementClosest(downEl, unselectCancel);
1814
- _this.matchesEvent = !!common.elementClosest(downEl, EventDragging.SELECTOR); // interaction started on an event?
1815
- };
1816
- this.onDocumentPointerUp = function (pev) {
1817
- var context = _this.context;
1818
- var documentPointer = _this.documentPointer;
1819
- var calendarState = context.getCurrentData();
1820
- // touch-scrolling should never unfocus any type of selection
1821
- if (!documentPointer.wasTouchScroll) {
1822
- if (calendarState.dateSelection && // an existing date selection?
1823
- !_this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
1824
- ) {
1825
- var unselectAuto = context.options.unselectAuto;
1826
- if (unselectAuto && (!unselectAuto || !_this.matchesCancel)) {
1827
- context.calendarApi.unselect(pev);
1828
- }
1829
- }
1830
- if (calendarState.eventSelection && // an existing event selected?
1831
- !_this.matchesEvent // interaction DIDN'T start on an event
1832
- ) {
1833
- context.dispatch({ type: 'UNSELECT_EVENT' });
1834
- }
1835
- }
1836
- _this.isRecentPointerDateSelect = false;
1837
- };
1838
- var documentPointer = this.documentPointer = new PointerDragging(document);
1839
- documentPointer.shouldIgnoreMove = true;
1840
- documentPointer.shouldWatchScroll = false;
1841
- documentPointer.emitter.on('pointerdown', this.onDocumentPointerDown);
1842
- documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
1843
- /*
1844
- TODO: better way to know about whether there was a selection with the pointer
1845
- */
1846
- context.emitter.on('select', this.onSelect);
1847
- }
1848
- UnselectAuto.prototype.destroy = function () {
1849
- this.context.emitter.off('select', this.onSelect);
1850
- this.documentPointer.destroy();
1851
- };
1852
- return UnselectAuto;
1853
- }());
1854
-
1855
- var OPTION_REFINERS = {
1856
- fixedMirrorParent: common.identity,
1857
- };
1858
- var LISTENER_REFINERS = {
1859
- dateClick: common.identity,
1860
- eventDragStart: common.identity,
1861
- eventDragStop: common.identity,
1862
- eventDrop: common.identity,
1863
- eventResizeStart: common.identity,
1864
- eventResizeStop: common.identity,
1865
- eventResize: common.identity,
1866
- drop: common.identity,
1867
- eventReceive: common.identity,
1868
- eventLeave: common.identity,
1869
- };
1870
-
1871
- /*
1872
- Given an already instantiated draggable object for one-or-more elements,
1873
- Interprets any dragging as an attempt to drag an events that lives outside
1874
- of a calendar onto a calendar.
1875
- */
1876
- var ExternalElementDragging = /** @class */ (function () {
1877
- function ExternalElementDragging(dragging, suppliedDragMeta) {
1878
- var _this = this;
1879
- this.receivingContext = null;
1880
- this.droppableEvent = null; // will exist for all drags, even if create:false
1881
- this.suppliedDragMeta = null;
1882
- this.dragMeta = null;
1883
- this.handleDragStart = function (ev) {
1884
- _this.dragMeta = _this.buildDragMeta(ev.subjectEl);
1885
- };
1886
- this.handleHitUpdate = function (hit, isFinal, ev) {
1887
- var dragging = _this.hitDragging.dragging;
1888
- var receivingContext = null;
1889
- var droppableEvent = null;
1890
- var isInvalid = false;
1891
- var interaction = {
1892
- affectedEvents: common.createEmptyEventStore(),
1893
- mutatedEvents: common.createEmptyEventStore(),
1894
- isEvent: _this.dragMeta.create,
1895
- };
1896
- if (hit) {
1897
- receivingContext = hit.context;
1898
- if (_this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
1899
- droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingContext);
1900
- interaction.mutatedEvents = common.eventTupleToStore(droppableEvent);
1901
- isInvalid = !common.isInteractionValid(interaction, hit.dateProfile, receivingContext);
1902
- if (isInvalid) {
1903
- interaction.mutatedEvents = common.createEmptyEventStore();
1904
- droppableEvent = null;
1905
- }
1906
- }
1907
- }
1908
- _this.displayDrag(receivingContext, interaction);
1909
- // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
1910
- // TODO: wish we could somehow wait for dispatch to guarantee render
1911
- dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-event-mirror'));
1912
- if (!isInvalid) {
1913
- common.enableCursor();
1914
- }
1915
- else {
1916
- common.disableCursor();
1917
- }
1918
- if (!isFinal) {
1919
- dragging.setMirrorNeedsRevert(!droppableEvent);
1920
- _this.receivingContext = receivingContext;
1921
- _this.droppableEvent = droppableEvent;
1922
- }
1923
- };
1924
- this.handleDragEnd = function (pev) {
1925
- var _a = _this, receivingContext = _a.receivingContext, droppableEvent = _a.droppableEvent;
1926
- _this.clearDrag();
1927
- if (receivingContext && droppableEvent) {
1928
- var finalHit = _this.hitDragging.finalHit;
1929
- var finalView = finalHit.context.viewApi;
1930
- var dragMeta = _this.dragMeta;
1931
- receivingContext.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
1932
- if (dragMeta.create) {
1933
- var addingEvents_1 = common.eventTupleToStore(droppableEvent);
1934
- receivingContext.dispatch({
1935
- type: 'MERGE_EVENTS',
1936
- eventStore: addingEvents_1,
1937
- });
1938
- if (pev.isTouch) {
1939
- receivingContext.dispatch({
1940
- type: 'SELECT_EVENT',
1941
- eventInstanceId: droppableEvent.instance.instanceId,
1942
- });
1943
- }
1944
- // signal that an external event landed
1945
- receivingContext.emitter.trigger('eventReceive', {
1946
- event: new common.EventApi(receivingContext, droppableEvent.def, droppableEvent.instance),
1947
- relatedEvents: [],
1948
- revert: function () {
1949
- receivingContext.dispatch({
1950
- type: 'REMOVE_EVENTS',
1951
- eventStore: addingEvents_1,
1952
- });
1953
- },
1954
- draggedEl: pev.subjectEl,
1955
- view: finalView,
1956
- });
1957
- }
1958
- }
1959
- _this.receivingContext = null;
1960
- _this.droppableEvent = null;
1961
- };
1962
- var hitDragging = this.hitDragging = new HitDragging(dragging, common.interactionSettingsStore);
1963
- hitDragging.requireInitial = false; // will start outside of a component
1964
- hitDragging.emitter.on('dragstart', this.handleDragStart);
1965
- hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
1966
- hitDragging.emitter.on('dragend', this.handleDragEnd);
1967
- this.suppliedDragMeta = suppliedDragMeta;
1968
- }
1969
- ExternalElementDragging.prototype.buildDragMeta = function (subjectEl) {
1970
- if (typeof this.suppliedDragMeta === 'object') {
1971
- return common.parseDragMeta(this.suppliedDragMeta);
1972
- }
1973
- if (typeof this.suppliedDragMeta === 'function') {
1974
- return common.parseDragMeta(this.suppliedDragMeta(subjectEl));
1975
- }
1976
- return getDragMetaFromEl(subjectEl);
1977
- };
1978
- ExternalElementDragging.prototype.displayDrag = function (nextContext, state) {
1979
- var prevContext = this.receivingContext;
1980
- if (prevContext && prevContext !== nextContext) {
1981
- prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
1982
- }
1983
- if (nextContext) {
1984
- nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
1985
- }
1986
- };
1987
- ExternalElementDragging.prototype.clearDrag = function () {
1988
- if (this.receivingContext) {
1989
- this.receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
1990
- }
1991
- };
1992
- ExternalElementDragging.prototype.canDropElOnCalendar = function (el, receivingContext) {
1993
- var dropAccept = receivingContext.options.dropAccept;
1994
- if (typeof dropAccept === 'function') {
1995
- return dropAccept.call(receivingContext.calendarApi, el);
1996
- }
1997
- if (typeof dropAccept === 'string' && dropAccept) {
1998
- return Boolean(common.elementMatches(el, dropAccept));
1999
- }
2000
- return true;
2001
- };
2002
- return ExternalElementDragging;
2003
- }());
2004
- // Utils for computing event store from the DragMeta
2005
- // ----------------------------------------------------------------------------------------------------
2006
- function computeEventForDateSpan(dateSpan, dragMeta, context) {
2007
- var defProps = __assign({}, dragMeta.leftoverProps);
2008
- for (var _i = 0, _a = context.pluginHooks.externalDefTransforms; _i < _a.length; _i++) {
2009
- var transform = _a[_i];
2010
- __assign(defProps, transform(dateSpan, dragMeta));
2011
- }
2012
- var _b = common.refineEventDef(defProps, context), refined = _b.refined, extra = _b.extra;
2013
- var def = common.parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), // hasEnd
2014
- context);
2015
- var start = dateSpan.range.start;
2016
- // only rely on time info if drop zone is all-day,
2017
- // otherwise, we already know the time
2018
- if (dateSpan.allDay && dragMeta.startTime) {
2019
- start = context.dateEnv.add(start, dragMeta.startTime);
2020
- }
2021
- var end = dragMeta.duration ?
2022
- context.dateEnv.add(start, dragMeta.duration) :
2023
- common.getDefaultEventEnd(dateSpan.allDay, start, context);
2024
- var instance = common.createEventInstance(def.defId, { start: start, end: end });
2025
- return { def: def, instance: instance };
2026
- }
2027
- // Utils for extracting data from element
2028
- // ----------------------------------------------------------------------------------------------------
2029
- function getDragMetaFromEl(el) {
2030
- var str = getEmbeddedElData(el, 'event');
2031
- var obj = str ?
2032
- JSON.parse(str) :
2033
- { create: false }; // if no embedded data, assume no event creation
2034
- return common.parseDragMeta(obj);
2035
- }
2036
- common.config.dataAttrPrefix = '';
2037
- function getEmbeddedElData(el, name) {
2038
- var prefix = common.config.dataAttrPrefix;
2039
- var prefixedName = (prefix ? prefix + '-' : '') + name;
2040
- return el.getAttribute('data-' + prefixedName) || '';
2041
- }
2042
-
2043
- /*
2044
- Makes an element (that is *external* to any calendar) draggable.
2045
- Can pass in data that determines how an event will be created when dropped onto a calendar.
2046
- Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
2047
- */
2048
- var ExternalDraggable = /** @class */ (function () {
2049
- function ExternalDraggable(el, settings) {
2050
- var _this = this;
2051
- if (settings === void 0) { settings = {}; }
2052
- this.handlePointerDown = function (ev) {
2053
- var dragging = _this.dragging;
2054
- var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
2055
- dragging.minDistance =
2056
- minDistance != null ?
2057
- minDistance :
2058
- (ev.isTouch ? 0 : common.BASE_OPTION_DEFAULTS.eventDragMinDistance);
2059
- dragging.delay =
2060
- ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
2061
- (longPressDelay != null ? longPressDelay : common.BASE_OPTION_DEFAULTS.longPressDelay) :
2062
- 0;
2063
- };
2064
- this.handleDragStart = function (ev) {
2065
- if (ev.isTouch &&
2066
- _this.dragging.delay &&
2067
- ev.subjectEl.classList.contains('fc-event')) {
2068
- _this.dragging.mirror.getMirrorEl().classList.add('fc-event-selected');
2069
- }
2070
- };
2071
- this.settings = settings;
2072
- var dragging = this.dragging = new FeaturefulElementDragging(el);
2073
- dragging.touchScrollAllowed = false;
2074
- if (settings.itemSelector != null) {
2075
- dragging.pointer.selector = settings.itemSelector;
2076
- }
2077
- if (settings.appendTo != null) {
2078
- dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
2079
- }
2080
- dragging.emitter.on('pointerdown', this.handlePointerDown);
2081
- dragging.emitter.on('dragstart', this.handleDragStart);
2082
- new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
2083
- }
2084
- ExternalDraggable.prototype.destroy = function () {
2085
- this.dragging.destroy();
2086
- };
2087
- return ExternalDraggable;
2088
- }());
2089
-
2090
- /*
2091
- Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
2092
- The third-party system is responsible for drawing the visuals effects of the drag.
2093
- This class simply monitors for pointer movements and fires events.
2094
- It also has the ability to hide the moving element (the "mirror") during the drag.
2095
- */
2096
- var InferredElementDragging = /** @class */ (function (_super) {
2097
- __extends(InferredElementDragging, _super);
2098
- function InferredElementDragging(containerEl) {
2099
- var _this = _super.call(this, containerEl) || this;
2100
- _this.shouldIgnoreMove = false;
2101
- _this.mirrorSelector = '';
2102
- _this.currentMirrorEl = null;
2103
- _this.handlePointerDown = function (ev) {
2104
- _this.emitter.trigger('pointerdown', ev);
2105
- if (!_this.shouldIgnoreMove) {
2106
- // fire dragstart right away. does not support delay or min-distance
2107
- _this.emitter.trigger('dragstart', ev);
2108
- }
2109
- };
2110
- _this.handlePointerMove = function (ev) {
2111
- if (!_this.shouldIgnoreMove) {
2112
- _this.emitter.trigger('dragmove', ev);
2113
- }
2114
- };
2115
- _this.handlePointerUp = function (ev) {
2116
- _this.emitter.trigger('pointerup', ev);
2117
- if (!_this.shouldIgnoreMove) {
2118
- // fire dragend right away. does not support a revert animation
2119
- _this.emitter.trigger('dragend', ev);
2120
- }
2121
- };
2122
- var pointer = _this.pointer = new PointerDragging(containerEl);
2123
- pointer.emitter.on('pointerdown', _this.handlePointerDown);
2124
- pointer.emitter.on('pointermove', _this.handlePointerMove);
2125
- pointer.emitter.on('pointerup', _this.handlePointerUp);
2126
- return _this;
2127
- }
2128
- InferredElementDragging.prototype.destroy = function () {
2129
- this.pointer.destroy();
2130
- };
2131
- InferredElementDragging.prototype.setIgnoreMove = function (bool) {
2132
- this.shouldIgnoreMove = bool;
2133
- };
2134
- InferredElementDragging.prototype.setMirrorIsVisible = function (bool) {
2135
- if (bool) {
2136
- // restore a previously hidden element.
2137
- // use the reference in case the selector class has already been removed.
2138
- if (this.currentMirrorEl) {
2139
- this.currentMirrorEl.style.visibility = '';
2140
- this.currentMirrorEl = null;
2141
- }
2142
- }
2143
- else {
2144
- var mirrorEl = this.mirrorSelector
2145
- // TODO: somehow query FullCalendars WITHIN shadow-roots
2146
- ? document.querySelector(this.mirrorSelector)
2147
- : null;
2148
- if (mirrorEl) {
2149
- this.currentMirrorEl = mirrorEl;
2150
- mirrorEl.style.visibility = 'hidden';
2151
- }
2152
- }
2153
- };
2154
- return InferredElementDragging;
2155
- }(common.ElementDragging));
2156
-
2157
- /*
2158
- Bridges third-party drag-n-drop systems with FullCalendar.
2159
- Must be instantiated and destroyed by caller.
2160
- */
2161
- var ThirdPartyDraggable = /** @class */ (function () {
2162
- function ThirdPartyDraggable(containerOrSettings, settings) {
2163
- var containerEl = document;
2164
- if (
2165
- // wish we could just test instanceof EventTarget, but doesn't work in IE11
2166
- containerOrSettings === document ||
2167
- containerOrSettings instanceof Element) {
2168
- containerEl = containerOrSettings;
2169
- settings = settings || {};
2170
- }
2171
- else {
2172
- settings = (containerOrSettings || {});
2173
- }
2174
- var dragging = this.dragging = new InferredElementDragging(containerEl);
2175
- if (typeof settings.itemSelector === 'string') {
2176
- dragging.pointer.selector = settings.itemSelector;
2177
- }
2178
- else if (containerEl === document) {
2179
- dragging.pointer.selector = '[data-event]';
2180
- }
2181
- if (typeof settings.mirrorSelector === 'string') {
2182
- dragging.mirrorSelector = settings.mirrorSelector;
2183
- }
2184
- new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
2185
- }
2186
- ThirdPartyDraggable.prototype.destroy = function () {
2187
- this.dragging.destroy();
2188
- };
2189
- return ThirdPartyDraggable;
2190
- }());
2191
-
2192
- var plugin = common.createPlugin({
2193
- componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
2194
- calendarInteractions: [UnselectAuto],
2195
- elementDraggingImpl: FeaturefulElementDragging,
2196
- optionRefiners: OPTION_REFINERS,
2197
- listenerRefiners: LISTENER_REFINERS,
2198
- });
2199
-
2200
- common.globalPlugins.push(plugin);
2201
-
2202
- exports.Draggable = ExternalDraggable;
2203
- exports.FeaturefulElementDragging = FeaturefulElementDragging;
2204
- exports.PointerDragging = PointerDragging;
2205
- exports.ThirdPartyDraggable = ThirdPartyDraggable;
2206
- exports.default = plugin;
2207
-
2208
- Object.defineProperty(exports, '__esModule', { value: true });
2209
-
2210
- return exports;
2211
-
2212
- }({}, FullCalendar));