main.js 100 KB

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