govuk_publishing_components 24.4.1 → 24.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js +108 -0
  3. data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +6 -2
  4. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  5. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -1
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +117 -0
  7. data/app/views/govuk_publishing_components/components/_list.html.erb +5 -5
  8. data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +45 -0
  9. data/app/views/govuk_publishing_components/components/_search.html.erb +27 -16
  10. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +67 -30
  11. data/app/views/govuk_publishing_components/components/docs/reorderable_list.yml +85 -0
  12. data/app/views/govuk_publishing_components/components/docs/search.yml +10 -0
  13. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +17 -3
  14. data/config/locales/en.yml +24 -16
  15. data/lib/govuk_publishing_components/version.rb +1 -1
  16. data/node_modules/sortablejs/LICENSE +21 -0
  17. data/node_modules/sortablejs/README.md +815 -0
  18. data/node_modules/sortablejs/Sortable.js +3721 -0
  19. data/node_modules/sortablejs/Sortable.min.js +2 -0
  20. data/node_modules/sortablejs/modular/sortable.complete.esm.js +3713 -0
  21. data/node_modules/sortablejs/modular/sortable.core.esm.js +3710 -0
  22. data/node_modules/sortablejs/modular/sortable.esm.js +3711 -0
  23. data/node_modules/sortablejs/package.json +56 -0
  24. metadata +14 -2
@@ -0,0 +1,3721 @@
1
+ /**!
2
+ * Sortable 1.13.0
3
+ * @author RubaXa <trash@rubaxa.org>
4
+ * @author owenm <owen23355@gmail.com>
5
+ * @license MIT
6
+ */
7
+ (function (global, factory) {
8
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
9
+ typeof define === 'function' && define.amd ? define(factory) :
10
+ (global = global || self, global.Sortable = factory());
11
+ }(this, function () { 'use strict';
12
+
13
+ function _typeof(obj) {
14
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
15
+ _typeof = function (obj) {
16
+ return typeof obj;
17
+ };
18
+ } else {
19
+ _typeof = function (obj) {
20
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
21
+ };
22
+ }
23
+
24
+ return _typeof(obj);
25
+ }
26
+
27
+ function _defineProperty(obj, key, value) {
28
+ if (key in obj) {
29
+ Object.defineProperty(obj, key, {
30
+ value: value,
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true
34
+ });
35
+ } else {
36
+ obj[key] = value;
37
+ }
38
+
39
+ return obj;
40
+ }
41
+
42
+ function _extends() {
43
+ _extends = Object.assign || function (target) {
44
+ for (var i = 1; i < arguments.length; i++) {
45
+ var source = arguments[i];
46
+
47
+ for (var key in source) {
48
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
49
+ target[key] = source[key];
50
+ }
51
+ }
52
+ }
53
+
54
+ return target;
55
+ };
56
+
57
+ return _extends.apply(this, arguments);
58
+ }
59
+
60
+ function _objectSpread(target) {
61
+ for (var i = 1; i < arguments.length; i++) {
62
+ var source = arguments[i] != null ? arguments[i] : {};
63
+ var ownKeys = Object.keys(source);
64
+
65
+ if (typeof Object.getOwnPropertySymbols === 'function') {
66
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
67
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
68
+ }));
69
+ }
70
+
71
+ ownKeys.forEach(function (key) {
72
+ _defineProperty(target, key, source[key]);
73
+ });
74
+ }
75
+
76
+ return target;
77
+ }
78
+
79
+ function _objectWithoutPropertiesLoose(source, excluded) {
80
+ if (source == null) return {};
81
+ var target = {};
82
+ var sourceKeys = Object.keys(source);
83
+ var key, i;
84
+
85
+ for (i = 0; i < sourceKeys.length; i++) {
86
+ key = sourceKeys[i];
87
+ if (excluded.indexOf(key) >= 0) continue;
88
+ target[key] = source[key];
89
+ }
90
+
91
+ return target;
92
+ }
93
+
94
+ function _objectWithoutProperties(source, excluded) {
95
+ if (source == null) return {};
96
+
97
+ var target = _objectWithoutPropertiesLoose(source, excluded);
98
+
99
+ var key, i;
100
+
101
+ if (Object.getOwnPropertySymbols) {
102
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
103
+
104
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
105
+ key = sourceSymbolKeys[i];
106
+ if (excluded.indexOf(key) >= 0) continue;
107
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
108
+ target[key] = source[key];
109
+ }
110
+ }
111
+
112
+ return target;
113
+ }
114
+
115
+ function _toConsumableArray(arr) {
116
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
117
+ }
118
+
119
+ function _arrayWithoutHoles(arr) {
120
+ if (Array.isArray(arr)) {
121
+ for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
122
+
123
+ return arr2;
124
+ }
125
+ }
126
+
127
+ function _iterableToArray(iter) {
128
+ if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
129
+ }
130
+
131
+ function _nonIterableSpread() {
132
+ throw new TypeError("Invalid attempt to spread non-iterable instance");
133
+ }
134
+
135
+ var version = "1.13.0";
136
+
137
+ function userAgent(pattern) {
138
+ if (typeof window !== 'undefined' && window.navigator) {
139
+ return !!
140
+ /*@__PURE__*/
141
+ navigator.userAgent.match(pattern);
142
+ }
143
+ }
144
+
145
+ var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
146
+ var Edge = userAgent(/Edge/i);
147
+ var FireFox = userAgent(/firefox/i);
148
+ var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
149
+ var IOS = userAgent(/iP(ad|od|hone)/i);
150
+ var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
151
+
152
+ var captureMode = {
153
+ capture: false,
154
+ passive: false
155
+ };
156
+
157
+ function on(el, event, fn) {
158
+ el.addEventListener(event, fn, !IE11OrLess && captureMode);
159
+ }
160
+
161
+ function off(el, event, fn) {
162
+ el.removeEventListener(event, fn, !IE11OrLess && captureMode);
163
+ }
164
+
165
+ function matches(
166
+ /**HTMLElement*/
167
+ el,
168
+ /**String*/
169
+ selector) {
170
+ if (!selector) return;
171
+ selector[0] === '>' && (selector = selector.substring(1));
172
+
173
+ if (el) {
174
+ try {
175
+ if (el.matches) {
176
+ return el.matches(selector);
177
+ } else if (el.msMatchesSelector) {
178
+ return el.msMatchesSelector(selector);
179
+ } else if (el.webkitMatchesSelector) {
180
+ return el.webkitMatchesSelector(selector);
181
+ }
182
+ } catch (_) {
183
+ return false;
184
+ }
185
+ }
186
+
187
+ return false;
188
+ }
189
+
190
+ function getParentOrHost(el) {
191
+ return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
192
+ }
193
+
194
+ function closest(
195
+ /**HTMLElement*/
196
+ el,
197
+ /**String*/
198
+ selector,
199
+ /**HTMLElement*/
200
+ ctx, includeCTX) {
201
+ if (el) {
202
+ ctx = ctx || document;
203
+
204
+ do {
205
+ if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
206
+ return el;
207
+ }
208
+
209
+ if (el === ctx) break;
210
+ /* jshint boss:true */
211
+ } while (el = getParentOrHost(el));
212
+ }
213
+
214
+ return null;
215
+ }
216
+
217
+ var R_SPACE = /\s+/g;
218
+
219
+ function toggleClass(el, name, state) {
220
+ if (el && name) {
221
+ if (el.classList) {
222
+ el.classList[state ? 'add' : 'remove'](name);
223
+ } else {
224
+ var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
225
+ el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
226
+ }
227
+ }
228
+ }
229
+
230
+ function css(el, prop, val) {
231
+ var style = el && el.style;
232
+
233
+ if (style) {
234
+ if (val === void 0) {
235
+ if (document.defaultView && document.defaultView.getComputedStyle) {
236
+ val = document.defaultView.getComputedStyle(el, '');
237
+ } else if (el.currentStyle) {
238
+ val = el.currentStyle;
239
+ }
240
+
241
+ return prop === void 0 ? val : val[prop];
242
+ } else {
243
+ if (!(prop in style) && prop.indexOf('webkit') === -1) {
244
+ prop = '-webkit-' + prop;
245
+ }
246
+
247
+ style[prop] = val + (typeof val === 'string' ? '' : 'px');
248
+ }
249
+ }
250
+ }
251
+
252
+ function matrix(el, selfOnly) {
253
+ var appliedTransforms = '';
254
+
255
+ if (typeof el === 'string') {
256
+ appliedTransforms = el;
257
+ } else {
258
+ do {
259
+ var transform = css(el, 'transform');
260
+
261
+ if (transform && transform !== 'none') {
262
+ appliedTransforms = transform + ' ' + appliedTransforms;
263
+ }
264
+ /* jshint boss:true */
265
+
266
+ } while (!selfOnly && (el = el.parentNode));
267
+ }
268
+
269
+ var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
270
+ /*jshint -W056 */
271
+
272
+ return matrixFn && new matrixFn(appliedTransforms);
273
+ }
274
+
275
+ function find(ctx, tagName, iterator) {
276
+ if (ctx) {
277
+ var list = ctx.getElementsByTagName(tagName),
278
+ i = 0,
279
+ n = list.length;
280
+
281
+ if (iterator) {
282
+ for (; i < n; i++) {
283
+ iterator(list[i], i);
284
+ }
285
+ }
286
+
287
+ return list;
288
+ }
289
+
290
+ return [];
291
+ }
292
+
293
+ function getWindowScrollingElement() {
294
+ var scrollingElement = document.scrollingElement;
295
+
296
+ if (scrollingElement) {
297
+ return scrollingElement;
298
+ } else {
299
+ return document.documentElement;
300
+ }
301
+ }
302
+ /**
303
+ * Returns the "bounding client rect" of given element
304
+ * @param {HTMLElement} el The element whose boundingClientRect is wanted
305
+ * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
306
+ * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
307
+ * @param {[Boolean]} undoScale Whether the container's scale() should be undone
308
+ * @param {[HTMLElement]} container The parent the element will be placed in
309
+ * @return {Object} The boundingClientRect of el, with specified adjustments
310
+ */
311
+
312
+
313
+ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
314
+ if (!el.getBoundingClientRect && el !== window) return;
315
+ var elRect, top, left, bottom, right, height, width;
316
+
317
+ if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
318
+ elRect = el.getBoundingClientRect();
319
+ top = elRect.top;
320
+ left = elRect.left;
321
+ bottom = elRect.bottom;
322
+ right = elRect.right;
323
+ height = elRect.height;
324
+ width = elRect.width;
325
+ } else {
326
+ top = 0;
327
+ left = 0;
328
+ bottom = window.innerHeight;
329
+ right = window.innerWidth;
330
+ height = window.innerHeight;
331
+ width = window.innerWidth;
332
+ }
333
+
334
+ if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
335
+ // Adjust for translate()
336
+ container = container || el.parentNode; // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
337
+ // Not needed on <= IE11
338
+
339
+ if (!IE11OrLess) {
340
+ do {
341
+ if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
342
+ var containerRect = container.getBoundingClientRect(); // Set relative to edges of padding box of container
343
+
344
+ top -= containerRect.top + parseInt(css(container, 'border-top-width'));
345
+ left -= containerRect.left + parseInt(css(container, 'border-left-width'));
346
+ bottom = top + elRect.height;
347
+ right = left + elRect.width;
348
+ break;
349
+ }
350
+ /* jshint boss:true */
351
+
352
+ } while (container = container.parentNode);
353
+ }
354
+ }
355
+
356
+ if (undoScale && el !== window) {
357
+ // Adjust for scale()
358
+ var elMatrix = matrix(container || el),
359
+ scaleX = elMatrix && elMatrix.a,
360
+ scaleY = elMatrix && elMatrix.d;
361
+
362
+ if (elMatrix) {
363
+ top /= scaleY;
364
+ left /= scaleX;
365
+ width /= scaleX;
366
+ height /= scaleY;
367
+ bottom = top + height;
368
+ right = left + width;
369
+ }
370
+ }
371
+
372
+ return {
373
+ top: top,
374
+ left: left,
375
+ bottom: bottom,
376
+ right: right,
377
+ width: width,
378
+ height: height
379
+ };
380
+ }
381
+ /**
382
+ * Checks if a side of an element is scrolled past a side of its parents
383
+ * @param {HTMLElement} el The element who's side being scrolled out of view is in question
384
+ * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
385
+ * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
386
+ * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
387
+ */
388
+
389
+
390
+ function isScrolledPast(el, elSide, parentSide) {
391
+ var parent = getParentAutoScrollElement(el, true),
392
+ elSideVal = getRect(el)[elSide];
393
+ /* jshint boss:true */
394
+
395
+ while (parent) {
396
+ var parentSideVal = getRect(parent)[parentSide],
397
+ visible = void 0;
398
+
399
+ if (parentSide === 'top' || parentSide === 'left') {
400
+ visible = elSideVal >= parentSideVal;
401
+ } else {
402
+ visible = elSideVal <= parentSideVal;
403
+ }
404
+
405
+ if (!visible) return parent;
406
+ if (parent === getWindowScrollingElement()) break;
407
+ parent = getParentAutoScrollElement(parent, false);
408
+ }
409
+
410
+ return false;
411
+ }
412
+ /**
413
+ * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
414
+ * and non-draggable elements
415
+ * @param {HTMLElement} el The parent element
416
+ * @param {Number} childNum The index of the child
417
+ * @param {Object} options Parent Sortable's options
418
+ * @return {HTMLElement} The child at index childNum, or null if not found
419
+ */
420
+
421
+
422
+ function getChild(el, childNum, options) {
423
+ var currentChild = 0,
424
+ i = 0,
425
+ children = el.children;
426
+
427
+ while (i < children.length) {
428
+ if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && children[i] !== Sortable.dragged && closest(children[i], options.draggable, el, false)) {
429
+ if (currentChild === childNum) {
430
+ return children[i];
431
+ }
432
+
433
+ currentChild++;
434
+ }
435
+
436
+ i++;
437
+ }
438
+
439
+ return null;
440
+ }
441
+ /**
442
+ * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
443
+ * @param {HTMLElement} el Parent element
444
+ * @param {selector} selector Any other elements that should be ignored
445
+ * @return {HTMLElement} The last child, ignoring ghostEl
446
+ */
447
+
448
+
449
+ function lastChild(el, selector) {
450
+ var last = el.lastElementChild;
451
+
452
+ while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
453
+ last = last.previousElementSibling;
454
+ }
455
+
456
+ return last || null;
457
+ }
458
+ /**
459
+ * Returns the index of an element within its parent for a selected set of
460
+ * elements
461
+ * @param {HTMLElement} el
462
+ * @param {selector} selector
463
+ * @return {number}
464
+ */
465
+
466
+
467
+ function index(el, selector) {
468
+ var index = 0;
469
+
470
+ if (!el || !el.parentNode) {
471
+ return -1;
472
+ }
473
+ /* jshint boss:true */
474
+
475
+
476
+ while (el = el.previousElementSibling) {
477
+ if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
478
+ index++;
479
+ }
480
+ }
481
+
482
+ return index;
483
+ }
484
+ /**
485
+ * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
486
+ * The value is returned in real pixels.
487
+ * @param {HTMLElement} el
488
+ * @return {Array} Offsets in the format of [left, top]
489
+ */
490
+
491
+
492
+ function getRelativeScrollOffset(el) {
493
+ var offsetLeft = 0,
494
+ offsetTop = 0,
495
+ winScroller = getWindowScrollingElement();
496
+
497
+ if (el) {
498
+ do {
499
+ var elMatrix = matrix(el),
500
+ scaleX = elMatrix.a,
501
+ scaleY = elMatrix.d;
502
+ offsetLeft += el.scrollLeft * scaleX;
503
+ offsetTop += el.scrollTop * scaleY;
504
+ } while (el !== winScroller && (el = el.parentNode));
505
+ }
506
+
507
+ return [offsetLeft, offsetTop];
508
+ }
509
+ /**
510
+ * Returns the index of the object within the given array
511
+ * @param {Array} arr Array that may or may not hold the object
512
+ * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
513
+ * @return {Number} The index of the object in the array, or -1
514
+ */
515
+
516
+
517
+ function indexOfObject(arr, obj) {
518
+ for (var i in arr) {
519
+ if (!arr.hasOwnProperty(i)) continue;
520
+
521
+ for (var key in obj) {
522
+ if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
523
+ }
524
+ }
525
+
526
+ return -1;
527
+ }
528
+
529
+ function getParentAutoScrollElement(el, includeSelf) {
530
+ // skip to window
531
+ if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
532
+ var elem = el;
533
+ var gotSelf = false;
534
+
535
+ do {
536
+ // we don't need to get elem css if it isn't even overflowing in the first place (performance)
537
+ if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
538
+ var elemCSS = css(elem);
539
+
540
+ if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
541
+ if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
542
+ if (gotSelf || includeSelf) return elem;
543
+ gotSelf = true;
544
+ }
545
+ }
546
+ /* jshint boss:true */
547
+
548
+ } while (elem = elem.parentNode);
549
+
550
+ return getWindowScrollingElement();
551
+ }
552
+
553
+ function extend(dst, src) {
554
+ if (dst && src) {
555
+ for (var key in src) {
556
+ if (src.hasOwnProperty(key)) {
557
+ dst[key] = src[key];
558
+ }
559
+ }
560
+ }
561
+
562
+ return dst;
563
+ }
564
+
565
+ function isRectEqual(rect1, rect2) {
566
+ return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
567
+ }
568
+
569
+ var _throttleTimeout;
570
+
571
+ function throttle(callback, ms) {
572
+ return function () {
573
+ if (!_throttleTimeout) {
574
+ var args = arguments,
575
+ _this = this;
576
+
577
+ if (args.length === 1) {
578
+ callback.call(_this, args[0]);
579
+ } else {
580
+ callback.apply(_this, args);
581
+ }
582
+
583
+ _throttleTimeout = setTimeout(function () {
584
+ _throttleTimeout = void 0;
585
+ }, ms);
586
+ }
587
+ };
588
+ }
589
+
590
+ function cancelThrottle() {
591
+ clearTimeout(_throttleTimeout);
592
+ _throttleTimeout = void 0;
593
+ }
594
+
595
+ function scrollBy(el, x, y) {
596
+ el.scrollLeft += x;
597
+ el.scrollTop += y;
598
+ }
599
+
600
+ function clone(el) {
601
+ var Polymer = window.Polymer;
602
+ var $ = window.jQuery || window.Zepto;
603
+
604
+ if (Polymer && Polymer.dom) {
605
+ return Polymer.dom(el).cloneNode(true);
606
+ } else if ($) {
607
+ return $(el).clone(true)[0];
608
+ } else {
609
+ return el.cloneNode(true);
610
+ }
611
+ }
612
+
613
+ function setRect(el, rect) {
614
+ css(el, 'position', 'absolute');
615
+ css(el, 'top', rect.top);
616
+ css(el, 'left', rect.left);
617
+ css(el, 'width', rect.width);
618
+ css(el, 'height', rect.height);
619
+ }
620
+
621
+ function unsetRect(el) {
622
+ css(el, 'position', '');
623
+ css(el, 'top', '');
624
+ css(el, 'left', '');
625
+ css(el, 'width', '');
626
+ css(el, 'height', '');
627
+ }
628
+
629
+ var expando = 'Sortable' + new Date().getTime();
630
+
631
+ function AnimationStateManager() {
632
+ var animationStates = [],
633
+ animationCallbackId;
634
+ return {
635
+ captureAnimationState: function captureAnimationState() {
636
+ animationStates = [];
637
+ if (!this.options.animation) return;
638
+ var children = [].slice.call(this.el.children);
639
+ children.forEach(function (child) {
640
+ if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
641
+ animationStates.push({
642
+ target: child,
643
+ rect: getRect(child)
644
+ });
645
+
646
+ var fromRect = _objectSpread({}, animationStates[animationStates.length - 1].rect); // If animating: compensate for current animation
647
+
648
+
649
+ if (child.thisAnimationDuration) {
650
+ var childMatrix = matrix(child, true);
651
+
652
+ if (childMatrix) {
653
+ fromRect.top -= childMatrix.f;
654
+ fromRect.left -= childMatrix.e;
655
+ }
656
+ }
657
+
658
+ child.fromRect = fromRect;
659
+ });
660
+ },
661
+ addAnimationState: function addAnimationState(state) {
662
+ animationStates.push(state);
663
+ },
664
+ removeAnimationState: function removeAnimationState(target) {
665
+ animationStates.splice(indexOfObject(animationStates, {
666
+ target: target
667
+ }), 1);
668
+ },
669
+ animateAll: function animateAll(callback) {
670
+ var _this = this;
671
+
672
+ if (!this.options.animation) {
673
+ clearTimeout(animationCallbackId);
674
+ if (typeof callback === 'function') callback();
675
+ return;
676
+ }
677
+
678
+ var animating = false,
679
+ animationTime = 0;
680
+ animationStates.forEach(function (state) {
681
+ var time = 0,
682
+ target = state.target,
683
+ fromRect = target.fromRect,
684
+ toRect = getRect(target),
685
+ prevFromRect = target.prevFromRect,
686
+ prevToRect = target.prevToRect,
687
+ animatingRect = state.rect,
688
+ targetMatrix = matrix(target, true);
689
+
690
+ if (targetMatrix) {
691
+ // Compensate for current animation
692
+ toRect.top -= targetMatrix.f;
693
+ toRect.left -= targetMatrix.e;
694
+ }
695
+
696
+ target.toRect = toRect;
697
+
698
+ if (target.thisAnimationDuration) {
699
+ // Could also check if animatingRect is between fromRect and toRect
700
+ if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && // Make sure animatingRect is on line between toRect & fromRect
701
+ (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
702
+ // If returning to same place as started from animation and on same axis
703
+ time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
704
+ }
705
+ } // if fromRect != toRect: animate
706
+
707
+
708
+ if (!isRectEqual(toRect, fromRect)) {
709
+ target.prevFromRect = fromRect;
710
+ target.prevToRect = toRect;
711
+
712
+ if (!time) {
713
+ time = _this.options.animation;
714
+ }
715
+
716
+ _this.animate(target, animatingRect, toRect, time);
717
+ }
718
+
719
+ if (time) {
720
+ animating = true;
721
+ animationTime = Math.max(animationTime, time);
722
+ clearTimeout(target.animationResetTimer);
723
+ target.animationResetTimer = setTimeout(function () {
724
+ target.animationTime = 0;
725
+ target.prevFromRect = null;
726
+ target.fromRect = null;
727
+ target.prevToRect = null;
728
+ target.thisAnimationDuration = null;
729
+ }, time);
730
+ target.thisAnimationDuration = time;
731
+ }
732
+ });
733
+ clearTimeout(animationCallbackId);
734
+
735
+ if (!animating) {
736
+ if (typeof callback === 'function') callback();
737
+ } else {
738
+ animationCallbackId = setTimeout(function () {
739
+ if (typeof callback === 'function') callback();
740
+ }, animationTime);
741
+ }
742
+
743
+ animationStates = [];
744
+ },
745
+ animate: function animate(target, currentRect, toRect, duration) {
746
+ if (duration) {
747
+ css(target, 'transition', '');
748
+ css(target, 'transform', '');
749
+ var elMatrix = matrix(this.el),
750
+ scaleX = elMatrix && elMatrix.a,
751
+ scaleY = elMatrix && elMatrix.d,
752
+ translateX = (currentRect.left - toRect.left) / (scaleX || 1),
753
+ translateY = (currentRect.top - toRect.top) / (scaleY || 1);
754
+ target.animatingX = !!translateX;
755
+ target.animatingY = !!translateY;
756
+ css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
757
+ this.forRepaintDummy = repaint(target); // repaint
758
+
759
+ css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
760
+ css(target, 'transform', 'translate3d(0,0,0)');
761
+ typeof target.animated === 'number' && clearTimeout(target.animated);
762
+ target.animated = setTimeout(function () {
763
+ css(target, 'transition', '');
764
+ css(target, 'transform', '');
765
+ target.animated = false;
766
+ target.animatingX = false;
767
+ target.animatingY = false;
768
+ }, duration);
769
+ }
770
+ }
771
+ };
772
+ }
773
+
774
+ function repaint(target) {
775
+ return target.offsetWidth;
776
+ }
777
+
778
+ function calculateRealTime(animatingRect, fromRect, toRect, options) {
779
+ return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
780
+ }
781
+
782
+ var plugins = [];
783
+ var defaults = {
784
+ initializeByDefault: true
785
+ };
786
+ var PluginManager = {
787
+ mount: function mount(plugin) {
788
+ // Set default static properties
789
+ for (var option in defaults) {
790
+ if (defaults.hasOwnProperty(option) && !(option in plugin)) {
791
+ plugin[option] = defaults[option];
792
+ }
793
+ }
794
+
795
+ plugins.forEach(function (p) {
796
+ if (p.pluginName === plugin.pluginName) {
797
+ throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
798
+ }
799
+ });
800
+ plugins.push(plugin);
801
+ },
802
+ pluginEvent: function pluginEvent(eventName, sortable, evt) {
803
+ var _this = this;
804
+
805
+ this.eventCanceled = false;
806
+
807
+ evt.cancel = function () {
808
+ _this.eventCanceled = true;
809
+ };
810
+
811
+ var eventNameGlobal = eventName + 'Global';
812
+ plugins.forEach(function (plugin) {
813
+ if (!sortable[plugin.pluginName]) return; // Fire global events if it exists in this sortable
814
+
815
+ if (sortable[plugin.pluginName][eventNameGlobal]) {
816
+ sortable[plugin.pluginName][eventNameGlobal](_objectSpread({
817
+ sortable: sortable
818
+ }, evt));
819
+ } // Only fire plugin event if plugin is enabled in this sortable,
820
+ // and plugin has event defined
821
+
822
+
823
+ if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
824
+ sortable[plugin.pluginName][eventName](_objectSpread({
825
+ sortable: sortable
826
+ }, evt));
827
+ }
828
+ });
829
+ },
830
+ initializePlugins: function initializePlugins(sortable, el, defaults, options) {
831
+ plugins.forEach(function (plugin) {
832
+ var pluginName = plugin.pluginName;
833
+ if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
834
+ var initialized = new plugin(sortable, el, sortable.options);
835
+ initialized.sortable = sortable;
836
+ initialized.options = sortable.options;
837
+ sortable[pluginName] = initialized; // Add default options from plugin
838
+
839
+ _extends(defaults, initialized.defaults);
840
+ });
841
+
842
+ for (var option in sortable.options) {
843
+ if (!sortable.options.hasOwnProperty(option)) continue;
844
+ var modified = this.modifyOption(sortable, option, sortable.options[option]);
845
+
846
+ if (typeof modified !== 'undefined') {
847
+ sortable.options[option] = modified;
848
+ }
849
+ }
850
+ },
851
+ getEventProperties: function getEventProperties(name, sortable) {
852
+ var eventProperties = {};
853
+ plugins.forEach(function (plugin) {
854
+ if (typeof plugin.eventProperties !== 'function') return;
855
+
856
+ _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
857
+ });
858
+ return eventProperties;
859
+ },
860
+ modifyOption: function modifyOption(sortable, name, value) {
861
+ var modifiedValue;
862
+ plugins.forEach(function (plugin) {
863
+ // Plugin must exist on the Sortable
864
+ if (!sortable[plugin.pluginName]) return; // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
865
+
866
+ if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
867
+ modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
868
+ }
869
+ });
870
+ return modifiedValue;
871
+ }
872
+ };
873
+
874
+ function dispatchEvent(_ref) {
875
+ var sortable = _ref.sortable,
876
+ rootEl = _ref.rootEl,
877
+ name = _ref.name,
878
+ targetEl = _ref.targetEl,
879
+ cloneEl = _ref.cloneEl,
880
+ toEl = _ref.toEl,
881
+ fromEl = _ref.fromEl,
882
+ oldIndex = _ref.oldIndex,
883
+ newIndex = _ref.newIndex,
884
+ oldDraggableIndex = _ref.oldDraggableIndex,
885
+ newDraggableIndex = _ref.newDraggableIndex,
886
+ originalEvent = _ref.originalEvent,
887
+ putSortable = _ref.putSortable,
888
+ extraEventProperties = _ref.extraEventProperties;
889
+ sortable = sortable || rootEl && rootEl[expando];
890
+ if (!sortable) return;
891
+ var evt,
892
+ options = sortable.options,
893
+ onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1); // Support for new CustomEvent feature
894
+
895
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
896
+ evt = new CustomEvent(name, {
897
+ bubbles: true,
898
+ cancelable: true
899
+ });
900
+ } else {
901
+ evt = document.createEvent('Event');
902
+ evt.initEvent(name, true, true);
903
+ }
904
+
905
+ evt.to = toEl || rootEl;
906
+ evt.from = fromEl || rootEl;
907
+ evt.item = targetEl || rootEl;
908
+ evt.clone = cloneEl;
909
+ evt.oldIndex = oldIndex;
910
+ evt.newIndex = newIndex;
911
+ evt.oldDraggableIndex = oldDraggableIndex;
912
+ evt.newDraggableIndex = newDraggableIndex;
913
+ evt.originalEvent = originalEvent;
914
+ evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
915
+
916
+ var allEventProperties = _objectSpread({}, extraEventProperties, PluginManager.getEventProperties(name, sortable));
917
+
918
+ for (var option in allEventProperties) {
919
+ evt[option] = allEventProperties[option];
920
+ }
921
+
922
+ if (rootEl) {
923
+ rootEl.dispatchEvent(evt);
924
+ }
925
+
926
+ if (options[onName]) {
927
+ options[onName].call(sortable, evt);
928
+ }
929
+ }
930
+
931
+ var pluginEvent = function pluginEvent(eventName, sortable) {
932
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
933
+ originalEvent = _ref.evt,
934
+ data = _objectWithoutProperties(_ref, ["evt"]);
935
+
936
+ PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread({
937
+ dragEl: dragEl,
938
+ parentEl: parentEl,
939
+ ghostEl: ghostEl,
940
+ rootEl: rootEl,
941
+ nextEl: nextEl,
942
+ lastDownEl: lastDownEl,
943
+ cloneEl: cloneEl,
944
+ cloneHidden: cloneHidden,
945
+ dragStarted: moved,
946
+ putSortable: putSortable,
947
+ activeSortable: Sortable.active,
948
+ originalEvent: originalEvent,
949
+ oldIndex: oldIndex,
950
+ oldDraggableIndex: oldDraggableIndex,
951
+ newIndex: newIndex,
952
+ newDraggableIndex: newDraggableIndex,
953
+ hideGhostForTarget: _hideGhostForTarget,
954
+ unhideGhostForTarget: _unhideGhostForTarget,
955
+ cloneNowHidden: function cloneNowHidden() {
956
+ cloneHidden = true;
957
+ },
958
+ cloneNowShown: function cloneNowShown() {
959
+ cloneHidden = false;
960
+ },
961
+ dispatchSortableEvent: function dispatchSortableEvent(name) {
962
+ _dispatchEvent({
963
+ sortable: sortable,
964
+ name: name,
965
+ originalEvent: originalEvent
966
+ });
967
+ }
968
+ }, data));
969
+ };
970
+
971
+ function _dispatchEvent(info) {
972
+ dispatchEvent(_objectSpread({
973
+ putSortable: putSortable,
974
+ cloneEl: cloneEl,
975
+ targetEl: dragEl,
976
+ rootEl: rootEl,
977
+ oldIndex: oldIndex,
978
+ oldDraggableIndex: oldDraggableIndex,
979
+ newIndex: newIndex,
980
+ newDraggableIndex: newDraggableIndex
981
+ }, info));
982
+ }
983
+
984
+ var dragEl,
985
+ parentEl,
986
+ ghostEl,
987
+ rootEl,
988
+ nextEl,
989
+ lastDownEl,
990
+ cloneEl,
991
+ cloneHidden,
992
+ oldIndex,
993
+ newIndex,
994
+ oldDraggableIndex,
995
+ newDraggableIndex,
996
+ activeGroup,
997
+ putSortable,
998
+ awaitingDragStarted = false,
999
+ ignoreNextClick = false,
1000
+ sortables = [],
1001
+ tapEvt,
1002
+ touchEvt,
1003
+ lastDx,
1004
+ lastDy,
1005
+ tapDistanceLeft,
1006
+ tapDistanceTop,
1007
+ moved,
1008
+ lastTarget,
1009
+ lastDirection,
1010
+ pastFirstInvertThresh = false,
1011
+ isCircumstantialInvert = false,
1012
+ targetMoveDistance,
1013
+ // For positioning ghost absolutely
1014
+ ghostRelativeParent,
1015
+ ghostRelativeParentInitialScroll = [],
1016
+ // (left, top)
1017
+ _silent = false,
1018
+ savedInputChecked = [];
1019
+ /** @const */
1020
+
1021
+ var documentExists = typeof document !== 'undefined',
1022
+ PositionGhostAbsolutely = IOS,
1023
+ CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
1024
+ // This will not pass for IE9, because IE9 DnD only works on anchors
1025
+ supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
1026
+ supportCssPointerEvents = function () {
1027
+ if (!documentExists) return; // false when <= IE11
1028
+
1029
+ if (IE11OrLess) {
1030
+ return false;
1031
+ }
1032
+
1033
+ var el = document.createElement('x');
1034
+ el.style.cssText = 'pointer-events:auto';
1035
+ return el.style.pointerEvents === 'auto';
1036
+ }(),
1037
+ _detectDirection = function _detectDirection(el, options) {
1038
+ var elCSS = css(el),
1039
+ elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
1040
+ child1 = getChild(el, 0, options),
1041
+ child2 = getChild(el, 1, options),
1042
+ firstChildCSS = child1 && css(child1),
1043
+ secondChildCSS = child2 && css(child2),
1044
+ firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
1045
+ secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
1046
+
1047
+ if (elCSS.display === 'flex') {
1048
+ return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
1049
+ }
1050
+
1051
+ if (elCSS.display === 'grid') {
1052
+ return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
1053
+ }
1054
+
1055
+ if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
1056
+ var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
1057
+ return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
1058
+ }
1059
+
1060
+ return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
1061
+ },
1062
+ _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
1063
+ var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
1064
+ dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
1065
+ dragElOppLength = vertical ? dragRect.width : dragRect.height,
1066
+ targetS1Opp = vertical ? targetRect.left : targetRect.top,
1067
+ targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
1068
+ targetOppLength = vertical ? targetRect.width : targetRect.height;
1069
+ return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
1070
+ },
1071
+
1072
+ /**
1073
+ * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
1074
+ * @param {Number} x X position
1075
+ * @param {Number} y Y position
1076
+ * @return {HTMLElement} Element of the first found nearest Sortable
1077
+ */
1078
+ _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
1079
+ var ret;
1080
+ sortables.some(function (sortable) {
1081
+ if (lastChild(sortable)) return;
1082
+ var rect = getRect(sortable),
1083
+ threshold = sortable[expando].options.emptyInsertThreshold,
1084
+ insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
1085
+ insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
1086
+
1087
+ if (threshold && insideHorizontally && insideVertically) {
1088
+ return ret = sortable;
1089
+ }
1090
+ });
1091
+ return ret;
1092
+ },
1093
+ _prepareGroup = function _prepareGroup(options) {
1094
+ function toFn(value, pull) {
1095
+ return function (to, from, dragEl, evt) {
1096
+ var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
1097
+
1098
+ if (value == null && (pull || sameGroup)) {
1099
+ // Default pull value
1100
+ // Default pull and put value if same group
1101
+ return true;
1102
+ } else if (value == null || value === false) {
1103
+ return false;
1104
+ } else if (pull && value === 'clone') {
1105
+ return value;
1106
+ } else if (typeof value === 'function') {
1107
+ return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
1108
+ } else {
1109
+ var otherGroup = (pull ? to : from).options.group.name;
1110
+ return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
1111
+ }
1112
+ };
1113
+ }
1114
+
1115
+ var group = {};
1116
+ var originalGroup = options.group;
1117
+
1118
+ if (!originalGroup || _typeof(originalGroup) != 'object') {
1119
+ originalGroup = {
1120
+ name: originalGroup
1121
+ };
1122
+ }
1123
+
1124
+ group.name = originalGroup.name;
1125
+ group.checkPull = toFn(originalGroup.pull, true);
1126
+ group.checkPut = toFn(originalGroup.put);
1127
+ group.revertClone = originalGroup.revertClone;
1128
+ options.group = group;
1129
+ },
1130
+ _hideGhostForTarget = function _hideGhostForTarget() {
1131
+ if (!supportCssPointerEvents && ghostEl) {
1132
+ css(ghostEl, 'display', 'none');
1133
+ }
1134
+ },
1135
+ _unhideGhostForTarget = function _unhideGhostForTarget() {
1136
+ if (!supportCssPointerEvents && ghostEl) {
1137
+ css(ghostEl, 'display', '');
1138
+ }
1139
+ }; // #1184 fix - Prevent click event on fallback if dragged but item not changed position
1140
+
1141
+
1142
+ if (documentExists) {
1143
+ document.addEventListener('click', function (evt) {
1144
+ if (ignoreNextClick) {
1145
+ evt.preventDefault();
1146
+ evt.stopPropagation && evt.stopPropagation();
1147
+ evt.stopImmediatePropagation && evt.stopImmediatePropagation();
1148
+ ignoreNextClick = false;
1149
+ return false;
1150
+ }
1151
+ }, true);
1152
+ }
1153
+
1154
+ var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
1155
+ if (dragEl) {
1156
+ evt = evt.touches ? evt.touches[0] : evt;
1157
+
1158
+ var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
1159
+
1160
+ if (nearest) {
1161
+ // Create imitation event
1162
+ var event = {};
1163
+
1164
+ for (var i in evt) {
1165
+ if (evt.hasOwnProperty(i)) {
1166
+ event[i] = evt[i];
1167
+ }
1168
+ }
1169
+
1170
+ event.target = event.rootEl = nearest;
1171
+ event.preventDefault = void 0;
1172
+ event.stopPropagation = void 0;
1173
+
1174
+ nearest[expando]._onDragOver(event);
1175
+ }
1176
+ }
1177
+ };
1178
+
1179
+ var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
1180
+ if (dragEl) {
1181
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1182
+ }
1183
+ };
1184
+ /**
1185
+ * @class Sortable
1186
+ * @param {HTMLElement} el
1187
+ * @param {Object} [options]
1188
+ */
1189
+
1190
+
1191
+ function Sortable(el, options) {
1192
+ if (!(el && el.nodeType && el.nodeType === 1)) {
1193
+ throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
1194
+ }
1195
+
1196
+ this.el = el; // root element
1197
+
1198
+ this.options = options = _extends({}, options); // Export instance
1199
+
1200
+ el[expando] = this;
1201
+ var defaults = {
1202
+ group: null,
1203
+ sort: true,
1204
+ disabled: false,
1205
+ store: null,
1206
+ handle: null,
1207
+ draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
1208
+ swapThreshold: 1,
1209
+ // percentage; 0 <= x <= 1
1210
+ invertSwap: false,
1211
+ // invert always
1212
+ invertedSwapThreshold: null,
1213
+ // will be set to same as swapThreshold if default
1214
+ removeCloneOnHide: true,
1215
+ direction: function direction() {
1216
+ return _detectDirection(el, this.options);
1217
+ },
1218
+ ghostClass: 'sortable-ghost',
1219
+ chosenClass: 'sortable-chosen',
1220
+ dragClass: 'sortable-drag',
1221
+ ignore: 'a, img',
1222
+ filter: null,
1223
+ preventOnFilter: true,
1224
+ animation: 0,
1225
+ easing: null,
1226
+ setData: function setData(dataTransfer, dragEl) {
1227
+ dataTransfer.setData('Text', dragEl.textContent);
1228
+ },
1229
+ dropBubble: false,
1230
+ dragoverBubble: false,
1231
+ dataIdAttr: 'data-id',
1232
+ delay: 0,
1233
+ delayOnTouchOnly: false,
1234
+ touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
1235
+ forceFallback: false,
1236
+ fallbackClass: 'sortable-fallback',
1237
+ fallbackOnBody: false,
1238
+ fallbackTolerance: 0,
1239
+ fallbackOffset: {
1240
+ x: 0,
1241
+ y: 0
1242
+ },
1243
+ supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && !Safari,
1244
+ emptyInsertThreshold: 5
1245
+ };
1246
+ PluginManager.initializePlugins(this, el, defaults); // Set default options
1247
+
1248
+ for (var name in defaults) {
1249
+ !(name in options) && (options[name] = defaults[name]);
1250
+ }
1251
+
1252
+ _prepareGroup(options); // Bind all private methods
1253
+
1254
+
1255
+ for (var fn in this) {
1256
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
1257
+ this[fn] = this[fn].bind(this);
1258
+ }
1259
+ } // Setup drag mode
1260
+
1261
+
1262
+ this.nativeDraggable = options.forceFallback ? false : supportDraggable;
1263
+
1264
+ if (this.nativeDraggable) {
1265
+ // Touch start threshold cannot be greater than the native dragstart threshold
1266
+ this.options.touchStartThreshold = 1;
1267
+ } // Bind events
1268
+
1269
+
1270
+ if (options.supportPointer) {
1271
+ on(el, 'pointerdown', this._onTapStart);
1272
+ } else {
1273
+ on(el, 'mousedown', this._onTapStart);
1274
+ on(el, 'touchstart', this._onTapStart);
1275
+ }
1276
+
1277
+ if (this.nativeDraggable) {
1278
+ on(el, 'dragover', this);
1279
+ on(el, 'dragenter', this);
1280
+ }
1281
+
1282
+ sortables.push(this.el); // Restore sorting
1283
+
1284
+ options.store && options.store.get && this.sort(options.store.get(this) || []); // Add animation state manager
1285
+
1286
+ _extends(this, AnimationStateManager());
1287
+ }
1288
+
1289
+ Sortable.prototype =
1290
+ /** @lends Sortable.prototype */
1291
+ {
1292
+ constructor: Sortable,
1293
+ _isOutsideThisEl: function _isOutsideThisEl(target) {
1294
+ if (!this.el.contains(target) && target !== this.el) {
1295
+ lastTarget = null;
1296
+ }
1297
+ },
1298
+ _getDirection: function _getDirection(evt, target) {
1299
+ return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
1300
+ },
1301
+ _onTapStart: function _onTapStart(
1302
+ /** Event|TouchEvent */
1303
+ evt) {
1304
+ if (!evt.cancelable) return;
1305
+
1306
+ var _this = this,
1307
+ el = this.el,
1308
+ options = this.options,
1309
+ preventOnFilter = options.preventOnFilter,
1310
+ type = evt.type,
1311
+ touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
1312
+ target = (touch || evt).target,
1313
+ originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
1314
+ filter = options.filter;
1315
+
1316
+ _saveInputCheckedState(el); // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
1317
+
1318
+
1319
+ if (dragEl) {
1320
+ return;
1321
+ }
1322
+
1323
+ if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
1324
+ return; // only left button and enabled
1325
+ } // cancel dnd if original target is content editable
1326
+
1327
+
1328
+ if (originalTarget.isContentEditable) {
1329
+ return;
1330
+ } // Safari ignores further event handling after mousedown
1331
+
1332
+
1333
+ if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
1334
+ return;
1335
+ }
1336
+
1337
+ target = closest(target, options.draggable, el, false);
1338
+
1339
+ if (target && target.animated) {
1340
+ return;
1341
+ }
1342
+
1343
+ if (lastDownEl === target) {
1344
+ // Ignoring duplicate `down`
1345
+ return;
1346
+ } // Get the index of the dragged element within its parent
1347
+
1348
+
1349
+ oldIndex = index(target);
1350
+ oldDraggableIndex = index(target, options.draggable); // Check filter
1351
+
1352
+ if (typeof filter === 'function') {
1353
+ if (filter.call(this, evt, target, this)) {
1354
+ _dispatchEvent({
1355
+ sortable: _this,
1356
+ rootEl: originalTarget,
1357
+ name: 'filter',
1358
+ targetEl: target,
1359
+ toEl: el,
1360
+ fromEl: el
1361
+ });
1362
+
1363
+ pluginEvent('filter', _this, {
1364
+ evt: evt
1365
+ });
1366
+ preventOnFilter && evt.cancelable && evt.preventDefault();
1367
+ return; // cancel dnd
1368
+ }
1369
+ } else if (filter) {
1370
+ filter = filter.split(',').some(function (criteria) {
1371
+ criteria = closest(originalTarget, criteria.trim(), el, false);
1372
+
1373
+ if (criteria) {
1374
+ _dispatchEvent({
1375
+ sortable: _this,
1376
+ rootEl: criteria,
1377
+ name: 'filter',
1378
+ targetEl: target,
1379
+ fromEl: el,
1380
+ toEl: el
1381
+ });
1382
+
1383
+ pluginEvent('filter', _this, {
1384
+ evt: evt
1385
+ });
1386
+ return true;
1387
+ }
1388
+ });
1389
+
1390
+ if (filter) {
1391
+ preventOnFilter && evt.cancelable && evt.preventDefault();
1392
+ return; // cancel dnd
1393
+ }
1394
+ }
1395
+
1396
+ if (options.handle && !closest(originalTarget, options.handle, el, false)) {
1397
+ return;
1398
+ } // Prepare `dragstart`
1399
+
1400
+
1401
+ this._prepareDragStart(evt, touch, target);
1402
+ },
1403
+ _prepareDragStart: function _prepareDragStart(
1404
+ /** Event */
1405
+ evt,
1406
+ /** Touch */
1407
+ touch,
1408
+ /** HTMLElement */
1409
+ target) {
1410
+ var _this = this,
1411
+ el = _this.el,
1412
+ options = _this.options,
1413
+ ownerDocument = el.ownerDocument,
1414
+ dragStartFn;
1415
+
1416
+ if (target && !dragEl && target.parentNode === el) {
1417
+ var dragRect = getRect(target);
1418
+ rootEl = el;
1419
+ dragEl = target;
1420
+ parentEl = dragEl.parentNode;
1421
+ nextEl = dragEl.nextSibling;
1422
+ lastDownEl = target;
1423
+ activeGroup = options.group;
1424
+ Sortable.dragged = dragEl;
1425
+ tapEvt = {
1426
+ target: dragEl,
1427
+ clientX: (touch || evt).clientX,
1428
+ clientY: (touch || evt).clientY
1429
+ };
1430
+ tapDistanceLeft = tapEvt.clientX - dragRect.left;
1431
+ tapDistanceTop = tapEvt.clientY - dragRect.top;
1432
+ this._lastX = (touch || evt).clientX;
1433
+ this._lastY = (touch || evt).clientY;
1434
+ dragEl.style['will-change'] = 'all';
1435
+
1436
+ dragStartFn = function dragStartFn() {
1437
+ pluginEvent('delayEnded', _this, {
1438
+ evt: evt
1439
+ });
1440
+
1441
+ if (Sortable.eventCanceled) {
1442
+ _this._onDrop();
1443
+
1444
+ return;
1445
+ } // Delayed drag has been triggered
1446
+ // we can re-enable the events: touchmove/mousemove
1447
+
1448
+
1449
+ _this._disableDelayedDragEvents();
1450
+
1451
+ if (!FireFox && _this.nativeDraggable) {
1452
+ dragEl.draggable = true;
1453
+ } // Bind the events: dragstart/dragend
1454
+
1455
+
1456
+ _this._triggerDragStart(evt, touch); // Drag start event
1457
+
1458
+
1459
+ _dispatchEvent({
1460
+ sortable: _this,
1461
+ name: 'choose',
1462
+ originalEvent: evt
1463
+ }); // Chosen item
1464
+
1465
+
1466
+ toggleClass(dragEl, options.chosenClass, true);
1467
+ }; // Disable "draggable"
1468
+
1469
+
1470
+ options.ignore.split(',').forEach(function (criteria) {
1471
+ find(dragEl, criteria.trim(), _disableDraggable);
1472
+ });
1473
+ on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
1474
+ on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
1475
+ on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
1476
+ on(ownerDocument, 'mouseup', _this._onDrop);
1477
+ on(ownerDocument, 'touchend', _this._onDrop);
1478
+ on(ownerDocument, 'touchcancel', _this._onDrop); // Make dragEl draggable (must be before delay for FireFox)
1479
+
1480
+ if (FireFox && this.nativeDraggable) {
1481
+ this.options.touchStartThreshold = 4;
1482
+ dragEl.draggable = true;
1483
+ }
1484
+
1485
+ pluginEvent('delayStart', this, {
1486
+ evt: evt
1487
+ }); // Delay is impossible for native DnD in Edge or IE
1488
+
1489
+ if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
1490
+ if (Sortable.eventCanceled) {
1491
+ this._onDrop();
1492
+
1493
+ return;
1494
+ } // If the user moves the pointer or let go the click or touch
1495
+ // before the delay has been reached:
1496
+ // disable the delayed drag
1497
+
1498
+
1499
+ on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1500
+ on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1501
+ on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1502
+ on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
1503
+ on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
1504
+ options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
1505
+ _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
1506
+ } else {
1507
+ dragStartFn();
1508
+ }
1509
+ }
1510
+ },
1511
+ _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(
1512
+ /** TouchEvent|PointerEvent **/
1513
+ e) {
1514
+ var touch = e.touches ? e.touches[0] : e;
1515
+
1516
+ if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
1517
+ this._disableDelayedDrag();
1518
+ }
1519
+ },
1520
+ _disableDelayedDrag: function _disableDelayedDrag() {
1521
+ dragEl && _disableDraggable(dragEl);
1522
+ clearTimeout(this._dragStartTimer);
1523
+
1524
+ this._disableDelayedDragEvents();
1525
+ },
1526
+ _disableDelayedDragEvents: function _disableDelayedDragEvents() {
1527
+ var ownerDocument = this.el.ownerDocument;
1528
+ off(ownerDocument, 'mouseup', this._disableDelayedDrag);
1529
+ off(ownerDocument, 'touchend', this._disableDelayedDrag);
1530
+ off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
1531
+ off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
1532
+ off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
1533
+ off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
1534
+ },
1535
+ _triggerDragStart: function _triggerDragStart(
1536
+ /** Event */
1537
+ evt,
1538
+ /** Touch */
1539
+ touch) {
1540
+ touch = touch || evt.pointerType == 'touch' && evt;
1541
+
1542
+ if (!this.nativeDraggable || touch) {
1543
+ if (this.options.supportPointer) {
1544
+ on(document, 'pointermove', this._onTouchMove);
1545
+ } else if (touch) {
1546
+ on(document, 'touchmove', this._onTouchMove);
1547
+ } else {
1548
+ on(document, 'mousemove', this._onTouchMove);
1549
+ }
1550
+ } else {
1551
+ on(dragEl, 'dragend', this);
1552
+ on(rootEl, 'dragstart', this._onDragStart);
1553
+ }
1554
+
1555
+ try {
1556
+ if (document.selection) {
1557
+ // Timeout neccessary for IE9
1558
+ _nextTick(function () {
1559
+ document.selection.empty();
1560
+ });
1561
+ } else {
1562
+ window.getSelection().removeAllRanges();
1563
+ }
1564
+ } catch (err) {}
1565
+ },
1566
+ _dragStarted: function _dragStarted(fallback, evt) {
1567
+
1568
+ awaitingDragStarted = false;
1569
+
1570
+ if (rootEl && dragEl) {
1571
+ pluginEvent('dragStarted', this, {
1572
+ evt: evt
1573
+ });
1574
+
1575
+ if (this.nativeDraggable) {
1576
+ on(document, 'dragover', _checkOutsideTargetEl);
1577
+ }
1578
+
1579
+ var options = this.options; // Apply effect
1580
+
1581
+ !fallback && toggleClass(dragEl, options.dragClass, false);
1582
+ toggleClass(dragEl, options.ghostClass, true);
1583
+ Sortable.active = this;
1584
+ fallback && this._appendGhost(); // Drag start event
1585
+
1586
+ _dispatchEvent({
1587
+ sortable: this,
1588
+ name: 'start',
1589
+ originalEvent: evt
1590
+ });
1591
+ } else {
1592
+ this._nulling();
1593
+ }
1594
+ },
1595
+ _emulateDragOver: function _emulateDragOver() {
1596
+ if (touchEvt) {
1597
+ this._lastX = touchEvt.clientX;
1598
+ this._lastY = touchEvt.clientY;
1599
+
1600
+ _hideGhostForTarget();
1601
+
1602
+ var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1603
+ var parent = target;
1604
+
1605
+ while (target && target.shadowRoot) {
1606
+ target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1607
+ if (target === parent) break;
1608
+ parent = target;
1609
+ }
1610
+
1611
+ dragEl.parentNode[expando]._isOutsideThisEl(target);
1612
+
1613
+ if (parent) {
1614
+ do {
1615
+ if (parent[expando]) {
1616
+ var inserted = void 0;
1617
+ inserted = parent[expando]._onDragOver({
1618
+ clientX: touchEvt.clientX,
1619
+ clientY: touchEvt.clientY,
1620
+ target: target,
1621
+ rootEl: parent
1622
+ });
1623
+
1624
+ if (inserted && !this.options.dragoverBubble) {
1625
+ break;
1626
+ }
1627
+ }
1628
+
1629
+ target = parent; // store last element
1630
+ }
1631
+ /* jshint boss:true */
1632
+ while (parent = parent.parentNode);
1633
+ }
1634
+
1635
+ _unhideGhostForTarget();
1636
+ }
1637
+ },
1638
+ _onTouchMove: function _onTouchMove(
1639
+ /**TouchEvent*/
1640
+ evt) {
1641
+ if (tapEvt) {
1642
+ var options = this.options,
1643
+ fallbackTolerance = options.fallbackTolerance,
1644
+ fallbackOffset = options.fallbackOffset,
1645
+ touch = evt.touches ? evt.touches[0] : evt,
1646
+ ghostMatrix = ghostEl && matrix(ghostEl, true),
1647
+ scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
1648
+ scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
1649
+ relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
1650
+ dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
1651
+ dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1); // only set the status to dragging, when we are actually dragging
1652
+
1653
+ if (!Sortable.active && !awaitingDragStarted) {
1654
+ if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
1655
+ return;
1656
+ }
1657
+
1658
+ this._onDragStart(evt, true);
1659
+ }
1660
+
1661
+ if (ghostEl) {
1662
+ if (ghostMatrix) {
1663
+ ghostMatrix.e += dx - (lastDx || 0);
1664
+ ghostMatrix.f += dy - (lastDy || 0);
1665
+ } else {
1666
+ ghostMatrix = {
1667
+ a: 1,
1668
+ b: 0,
1669
+ c: 0,
1670
+ d: 1,
1671
+ e: dx,
1672
+ f: dy
1673
+ };
1674
+ }
1675
+
1676
+ var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
1677
+ css(ghostEl, 'webkitTransform', cssMatrix);
1678
+ css(ghostEl, 'mozTransform', cssMatrix);
1679
+ css(ghostEl, 'msTransform', cssMatrix);
1680
+ css(ghostEl, 'transform', cssMatrix);
1681
+ lastDx = dx;
1682
+ lastDy = dy;
1683
+ touchEvt = touch;
1684
+ }
1685
+
1686
+ evt.cancelable && evt.preventDefault();
1687
+ }
1688
+ },
1689
+ _appendGhost: function _appendGhost() {
1690
+ // Bug if using scale(): https://stackoverflow.com/questions/2637058
1691
+ // Not being adjusted for
1692
+ if (!ghostEl) {
1693
+ var container = this.options.fallbackOnBody ? document.body : rootEl,
1694
+ rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
1695
+ options = this.options; // Position absolutely
1696
+
1697
+ if (PositionGhostAbsolutely) {
1698
+ // Get relatively positioned parent
1699
+ ghostRelativeParent = container;
1700
+
1701
+ while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
1702
+ ghostRelativeParent = ghostRelativeParent.parentNode;
1703
+ }
1704
+
1705
+ if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
1706
+ if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
1707
+ rect.top += ghostRelativeParent.scrollTop;
1708
+ rect.left += ghostRelativeParent.scrollLeft;
1709
+ } else {
1710
+ ghostRelativeParent = getWindowScrollingElement();
1711
+ }
1712
+
1713
+ ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
1714
+ }
1715
+
1716
+ ghostEl = dragEl.cloneNode(true);
1717
+ toggleClass(ghostEl, options.ghostClass, false);
1718
+ toggleClass(ghostEl, options.fallbackClass, true);
1719
+ toggleClass(ghostEl, options.dragClass, true);
1720
+ css(ghostEl, 'transition', '');
1721
+ css(ghostEl, 'transform', '');
1722
+ css(ghostEl, 'box-sizing', 'border-box');
1723
+ css(ghostEl, 'margin', 0);
1724
+ css(ghostEl, 'top', rect.top);
1725
+ css(ghostEl, 'left', rect.left);
1726
+ css(ghostEl, 'width', rect.width);
1727
+ css(ghostEl, 'height', rect.height);
1728
+ css(ghostEl, 'opacity', '0.8');
1729
+ css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
1730
+ css(ghostEl, 'zIndex', '100000');
1731
+ css(ghostEl, 'pointerEvents', 'none');
1732
+ Sortable.ghost = ghostEl;
1733
+ container.appendChild(ghostEl); // Set transform-origin
1734
+
1735
+ css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
1736
+ }
1737
+ },
1738
+ _onDragStart: function _onDragStart(
1739
+ /**Event*/
1740
+ evt,
1741
+ /**boolean*/
1742
+ fallback) {
1743
+ var _this = this;
1744
+
1745
+ var dataTransfer = evt.dataTransfer;
1746
+ var options = _this.options;
1747
+ pluginEvent('dragStart', this, {
1748
+ evt: evt
1749
+ });
1750
+
1751
+ if (Sortable.eventCanceled) {
1752
+ this._onDrop();
1753
+
1754
+ return;
1755
+ }
1756
+
1757
+ pluginEvent('setupClone', this);
1758
+
1759
+ if (!Sortable.eventCanceled) {
1760
+ cloneEl = clone(dragEl);
1761
+ cloneEl.draggable = false;
1762
+ cloneEl.style['will-change'] = '';
1763
+
1764
+ this._hideClone();
1765
+
1766
+ toggleClass(cloneEl, this.options.chosenClass, false);
1767
+ Sortable.clone = cloneEl;
1768
+ } // #1143: IFrame support workaround
1769
+
1770
+
1771
+ _this.cloneId = _nextTick(function () {
1772
+ pluginEvent('clone', _this);
1773
+ if (Sortable.eventCanceled) return;
1774
+
1775
+ if (!_this.options.removeCloneOnHide) {
1776
+ rootEl.insertBefore(cloneEl, dragEl);
1777
+ }
1778
+
1779
+ _this._hideClone();
1780
+
1781
+ _dispatchEvent({
1782
+ sortable: _this,
1783
+ name: 'clone'
1784
+ });
1785
+ });
1786
+ !fallback && toggleClass(dragEl, options.dragClass, true); // Set proper drop events
1787
+
1788
+ if (fallback) {
1789
+ ignoreNextClick = true;
1790
+ _this._loopId = setInterval(_this._emulateDragOver, 50);
1791
+ } else {
1792
+ // Undo what was set in _prepareDragStart before drag started
1793
+ off(document, 'mouseup', _this._onDrop);
1794
+ off(document, 'touchend', _this._onDrop);
1795
+ off(document, 'touchcancel', _this._onDrop);
1796
+
1797
+ if (dataTransfer) {
1798
+ dataTransfer.effectAllowed = 'move';
1799
+ options.setData && options.setData.call(_this, dataTransfer, dragEl);
1800
+ }
1801
+
1802
+ on(document, 'drop', _this); // #1276 fix:
1803
+
1804
+ css(dragEl, 'transform', 'translateZ(0)');
1805
+ }
1806
+
1807
+ awaitingDragStarted = true;
1808
+ _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
1809
+ on(document, 'selectstart', _this);
1810
+ moved = true;
1811
+
1812
+ if (Safari) {
1813
+ css(document.body, 'user-select', 'none');
1814
+ }
1815
+ },
1816
+ // Returns true - if no further action is needed (either inserted or another condition)
1817
+ _onDragOver: function _onDragOver(
1818
+ /**Event*/
1819
+ evt) {
1820
+ var el = this.el,
1821
+ target = evt.target,
1822
+ dragRect,
1823
+ targetRect,
1824
+ revert,
1825
+ options = this.options,
1826
+ group = options.group,
1827
+ activeSortable = Sortable.active,
1828
+ isOwner = activeGroup === group,
1829
+ canSort = options.sort,
1830
+ fromSortable = putSortable || activeSortable,
1831
+ vertical,
1832
+ _this = this,
1833
+ completedFired = false;
1834
+
1835
+ if (_silent) return;
1836
+
1837
+ function dragOverEvent(name, extra) {
1838
+ pluginEvent(name, _this, _objectSpread({
1839
+ evt: evt,
1840
+ isOwner: isOwner,
1841
+ axis: vertical ? 'vertical' : 'horizontal',
1842
+ revert: revert,
1843
+ dragRect: dragRect,
1844
+ targetRect: targetRect,
1845
+ canSort: canSort,
1846
+ fromSortable: fromSortable,
1847
+ target: target,
1848
+ completed: completed,
1849
+ onMove: function onMove(target, after) {
1850
+ return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
1851
+ },
1852
+ changed: changed
1853
+ }, extra));
1854
+ } // Capture animation state
1855
+
1856
+
1857
+ function capture() {
1858
+ dragOverEvent('dragOverAnimationCapture');
1859
+
1860
+ _this.captureAnimationState();
1861
+
1862
+ if (_this !== fromSortable) {
1863
+ fromSortable.captureAnimationState();
1864
+ }
1865
+ } // Return invocation when dragEl is inserted (or completed)
1866
+
1867
+
1868
+ function completed(insertion) {
1869
+ dragOverEvent('dragOverCompleted', {
1870
+ insertion: insertion
1871
+ });
1872
+
1873
+ if (insertion) {
1874
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
1875
+ if (isOwner) {
1876
+ activeSortable._hideClone();
1877
+ } else {
1878
+ activeSortable._showClone(_this);
1879
+ }
1880
+
1881
+ if (_this !== fromSortable) {
1882
+ // Set ghost class to new sortable's ghost class
1883
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
1884
+ toggleClass(dragEl, options.ghostClass, true);
1885
+ }
1886
+
1887
+ if (putSortable !== _this && _this !== Sortable.active) {
1888
+ putSortable = _this;
1889
+ } else if (_this === Sortable.active && putSortable) {
1890
+ putSortable = null;
1891
+ } // Animation
1892
+
1893
+
1894
+ if (fromSortable === _this) {
1895
+ _this._ignoreWhileAnimating = target;
1896
+ }
1897
+
1898
+ _this.animateAll(function () {
1899
+ dragOverEvent('dragOverAnimationComplete');
1900
+ _this._ignoreWhileAnimating = null;
1901
+ });
1902
+
1903
+ if (_this !== fromSortable) {
1904
+ fromSortable.animateAll();
1905
+ fromSortable._ignoreWhileAnimating = null;
1906
+ }
1907
+ } // Null lastTarget if it is not inside a previously swapped element
1908
+
1909
+
1910
+ if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
1911
+ lastTarget = null;
1912
+ } // no bubbling and not fallback
1913
+
1914
+
1915
+ if (!options.dragoverBubble && !evt.rootEl && target !== document) {
1916
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target); // Do not detect for empty insert if already inserted
1917
+
1918
+
1919
+ !insertion && nearestEmptyInsertDetectEvent(evt);
1920
+ }
1921
+
1922
+ !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
1923
+ return completedFired = true;
1924
+ } // Call when dragEl has been inserted
1925
+
1926
+
1927
+ function changed() {
1928
+ newIndex = index(dragEl);
1929
+ newDraggableIndex = index(dragEl, options.draggable);
1930
+
1931
+ _dispatchEvent({
1932
+ sortable: _this,
1933
+ name: 'change',
1934
+ toEl: el,
1935
+ newIndex: newIndex,
1936
+ newDraggableIndex: newDraggableIndex,
1937
+ originalEvent: evt
1938
+ });
1939
+ }
1940
+
1941
+ if (evt.preventDefault !== void 0) {
1942
+ evt.cancelable && evt.preventDefault();
1943
+ }
1944
+
1945
+ target = closest(target, options.draggable, el, true);
1946
+ dragOverEvent('dragOver');
1947
+ if (Sortable.eventCanceled) return completedFired;
1948
+
1949
+ if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
1950
+ return completed(false);
1951
+ }
1952
+
1953
+ ignoreNextClick = false;
1954
+
1955
+ if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list
1956
+ : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
1957
+ vertical = this._getDirection(evt, target) === 'vertical';
1958
+ dragRect = getRect(dragEl);
1959
+ dragOverEvent('dragOverValid');
1960
+ if (Sortable.eventCanceled) return completedFired;
1961
+
1962
+ if (revert) {
1963
+ parentEl = rootEl; // actualization
1964
+
1965
+ capture();
1966
+
1967
+ this._hideClone();
1968
+
1969
+ dragOverEvent('revert');
1970
+
1971
+ if (!Sortable.eventCanceled) {
1972
+ if (nextEl) {
1973
+ rootEl.insertBefore(dragEl, nextEl);
1974
+ } else {
1975
+ rootEl.appendChild(dragEl);
1976
+ }
1977
+ }
1978
+
1979
+ return completed(true);
1980
+ }
1981
+
1982
+ var elLastChild = lastChild(el, options.draggable);
1983
+
1984
+ if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
1985
+ // If already at end of list: Do not insert
1986
+ if (elLastChild === dragEl) {
1987
+ return completed(false);
1988
+ } // assign target only if condition is true
1989
+
1990
+
1991
+ if (elLastChild && el === evt.target) {
1992
+ target = elLastChild;
1993
+ }
1994
+
1995
+ if (target) {
1996
+ targetRect = getRect(target);
1997
+ }
1998
+
1999
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
2000
+ capture();
2001
+ el.appendChild(dragEl);
2002
+ parentEl = el; // actualization
2003
+
2004
+ changed();
2005
+ return completed(true);
2006
+ }
2007
+ } else if (target.parentNode === el) {
2008
+ targetRect = getRect(target);
2009
+ var direction = 0,
2010
+ targetBeforeFirstSwap,
2011
+ differentLevel = dragEl.parentNode !== el,
2012
+ differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
2013
+ side1 = vertical ? 'top' : 'left',
2014
+ scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
2015
+ scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
2016
+
2017
+ if (lastTarget !== target) {
2018
+ targetBeforeFirstSwap = targetRect[side1];
2019
+ pastFirstInvertThresh = false;
2020
+ isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
2021
+ }
2022
+
2023
+ direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
2024
+ var sibling;
2025
+
2026
+ if (direction !== 0) {
2027
+ // Check if target is beside dragEl in respective direction (ignoring hidden elements)
2028
+ var dragIndex = index(dragEl);
2029
+
2030
+ do {
2031
+ dragIndex -= direction;
2032
+ sibling = parentEl.children[dragIndex];
2033
+ } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
2034
+ } // If dragEl is already beside target: Do not insert
2035
+
2036
+
2037
+ if (direction === 0 || sibling === target) {
2038
+ return completed(false);
2039
+ }
2040
+
2041
+ lastTarget = target;
2042
+ lastDirection = direction;
2043
+ var nextSibling = target.nextElementSibling,
2044
+ after = false;
2045
+ after = direction === 1;
2046
+
2047
+ var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
2048
+
2049
+ if (moveVector !== false) {
2050
+ if (moveVector === 1 || moveVector === -1) {
2051
+ after = moveVector === 1;
2052
+ }
2053
+
2054
+ _silent = true;
2055
+ setTimeout(_unsilent, 30);
2056
+ capture();
2057
+
2058
+ if (after && !nextSibling) {
2059
+ el.appendChild(dragEl);
2060
+ } else {
2061
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
2062
+ } // Undo chrome's scroll adjustment (has no effect on other browsers)
2063
+
2064
+
2065
+ if (scrolledPastTop) {
2066
+ scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
2067
+ }
2068
+
2069
+ parentEl = dragEl.parentNode; // actualization
2070
+ // must be done before animation
2071
+
2072
+ if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
2073
+ targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
2074
+ }
2075
+
2076
+ changed();
2077
+ return completed(true);
2078
+ }
2079
+ }
2080
+
2081
+ if (el.contains(dragEl)) {
2082
+ return completed(false);
2083
+ }
2084
+ }
2085
+
2086
+ return false;
2087
+ },
2088
+ _ignoreWhileAnimating: null,
2089
+ _offMoveEvents: function _offMoveEvents() {
2090
+ off(document, 'mousemove', this._onTouchMove);
2091
+ off(document, 'touchmove', this._onTouchMove);
2092
+ off(document, 'pointermove', this._onTouchMove);
2093
+ off(document, 'dragover', nearestEmptyInsertDetectEvent);
2094
+ off(document, 'mousemove', nearestEmptyInsertDetectEvent);
2095
+ off(document, 'touchmove', nearestEmptyInsertDetectEvent);
2096
+ },
2097
+ _offUpEvents: function _offUpEvents() {
2098
+ var ownerDocument = this.el.ownerDocument;
2099
+ off(ownerDocument, 'mouseup', this._onDrop);
2100
+ off(ownerDocument, 'touchend', this._onDrop);
2101
+ off(ownerDocument, 'pointerup', this._onDrop);
2102
+ off(ownerDocument, 'touchcancel', this._onDrop);
2103
+ off(document, 'selectstart', this);
2104
+ },
2105
+ _onDrop: function _onDrop(
2106
+ /**Event*/
2107
+ evt) {
2108
+ var el = this.el,
2109
+ options = this.options; // Get the index of the dragged element within its parent
2110
+
2111
+ newIndex = index(dragEl);
2112
+ newDraggableIndex = index(dragEl, options.draggable);
2113
+ pluginEvent('drop', this, {
2114
+ evt: evt
2115
+ });
2116
+ parentEl = dragEl && dragEl.parentNode; // Get again after plugin event
2117
+
2118
+ newIndex = index(dragEl);
2119
+ newDraggableIndex = index(dragEl, options.draggable);
2120
+
2121
+ if (Sortable.eventCanceled) {
2122
+ this._nulling();
2123
+
2124
+ return;
2125
+ }
2126
+
2127
+ awaitingDragStarted = false;
2128
+ isCircumstantialInvert = false;
2129
+ pastFirstInvertThresh = false;
2130
+ clearInterval(this._loopId);
2131
+ clearTimeout(this._dragStartTimer);
2132
+
2133
+ _cancelNextTick(this.cloneId);
2134
+
2135
+ _cancelNextTick(this._dragStartId); // Unbind events
2136
+
2137
+
2138
+ if (this.nativeDraggable) {
2139
+ off(document, 'drop', this);
2140
+ off(el, 'dragstart', this._onDragStart);
2141
+ }
2142
+
2143
+ this._offMoveEvents();
2144
+
2145
+ this._offUpEvents();
2146
+
2147
+ if (Safari) {
2148
+ css(document.body, 'user-select', '');
2149
+ }
2150
+
2151
+ css(dragEl, 'transform', '');
2152
+
2153
+ if (evt) {
2154
+ if (moved) {
2155
+ evt.cancelable && evt.preventDefault();
2156
+ !options.dropBubble && evt.stopPropagation();
2157
+ }
2158
+
2159
+ ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
2160
+
2161
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
2162
+ // Remove clone(s)
2163
+ cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
2164
+ }
2165
+
2166
+ if (dragEl) {
2167
+ if (this.nativeDraggable) {
2168
+ off(dragEl, 'dragend', this);
2169
+ }
2170
+
2171
+ _disableDraggable(dragEl);
2172
+
2173
+ dragEl.style['will-change'] = ''; // Remove classes
2174
+ // ghostClass is added in dragStarted
2175
+
2176
+ if (moved && !awaitingDragStarted) {
2177
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
2178
+ }
2179
+
2180
+ toggleClass(dragEl, this.options.chosenClass, false); // Drag stop event
2181
+
2182
+ _dispatchEvent({
2183
+ sortable: this,
2184
+ name: 'unchoose',
2185
+ toEl: parentEl,
2186
+ newIndex: null,
2187
+ newDraggableIndex: null,
2188
+ originalEvent: evt
2189
+ });
2190
+
2191
+ if (rootEl !== parentEl) {
2192
+ if (newIndex >= 0) {
2193
+ // Add event
2194
+ _dispatchEvent({
2195
+ rootEl: parentEl,
2196
+ name: 'add',
2197
+ toEl: parentEl,
2198
+ fromEl: rootEl,
2199
+ originalEvent: evt
2200
+ }); // Remove event
2201
+
2202
+
2203
+ _dispatchEvent({
2204
+ sortable: this,
2205
+ name: 'remove',
2206
+ toEl: parentEl,
2207
+ originalEvent: evt
2208
+ }); // drag from one list and drop into another
2209
+
2210
+
2211
+ _dispatchEvent({
2212
+ rootEl: parentEl,
2213
+ name: 'sort',
2214
+ toEl: parentEl,
2215
+ fromEl: rootEl,
2216
+ originalEvent: evt
2217
+ });
2218
+
2219
+ _dispatchEvent({
2220
+ sortable: this,
2221
+ name: 'sort',
2222
+ toEl: parentEl,
2223
+ originalEvent: evt
2224
+ });
2225
+ }
2226
+
2227
+ putSortable && putSortable.save();
2228
+ } else {
2229
+ if (newIndex !== oldIndex) {
2230
+ if (newIndex >= 0) {
2231
+ // drag & drop within the same list
2232
+ _dispatchEvent({
2233
+ sortable: this,
2234
+ name: 'update',
2235
+ toEl: parentEl,
2236
+ originalEvent: evt
2237
+ });
2238
+
2239
+ _dispatchEvent({
2240
+ sortable: this,
2241
+ name: 'sort',
2242
+ toEl: parentEl,
2243
+ originalEvent: evt
2244
+ });
2245
+ }
2246
+ }
2247
+ }
2248
+
2249
+ if (Sortable.active) {
2250
+ /* jshint eqnull:true */
2251
+ if (newIndex == null || newIndex === -1) {
2252
+ newIndex = oldIndex;
2253
+ newDraggableIndex = oldDraggableIndex;
2254
+ }
2255
+
2256
+ _dispatchEvent({
2257
+ sortable: this,
2258
+ name: 'end',
2259
+ toEl: parentEl,
2260
+ originalEvent: evt
2261
+ }); // Save sorting
2262
+
2263
+
2264
+ this.save();
2265
+ }
2266
+ }
2267
+ }
2268
+
2269
+ this._nulling();
2270
+ },
2271
+ _nulling: function _nulling() {
2272
+ pluginEvent('nulling', this);
2273
+ rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
2274
+ savedInputChecked.forEach(function (el) {
2275
+ el.checked = true;
2276
+ });
2277
+ savedInputChecked.length = lastDx = lastDy = 0;
2278
+ },
2279
+ handleEvent: function handleEvent(
2280
+ /**Event*/
2281
+ evt) {
2282
+ switch (evt.type) {
2283
+ case 'drop':
2284
+ case 'dragend':
2285
+ this._onDrop(evt);
2286
+
2287
+ break;
2288
+
2289
+ case 'dragenter':
2290
+ case 'dragover':
2291
+ if (dragEl) {
2292
+ this._onDragOver(evt);
2293
+
2294
+ _globalDragOver(evt);
2295
+ }
2296
+
2297
+ break;
2298
+
2299
+ case 'selectstart':
2300
+ evt.preventDefault();
2301
+ break;
2302
+ }
2303
+ },
2304
+
2305
+ /**
2306
+ * Serializes the item into an array of string.
2307
+ * @returns {String[]}
2308
+ */
2309
+ toArray: function toArray() {
2310
+ var order = [],
2311
+ el,
2312
+ children = this.el.children,
2313
+ i = 0,
2314
+ n = children.length,
2315
+ options = this.options;
2316
+
2317
+ for (; i < n; i++) {
2318
+ el = children[i];
2319
+
2320
+ if (closest(el, options.draggable, this.el, false)) {
2321
+ order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
2322
+ }
2323
+ }
2324
+
2325
+ return order;
2326
+ },
2327
+
2328
+ /**
2329
+ * Sorts the elements according to the array.
2330
+ * @param {String[]} order order of the items
2331
+ */
2332
+ sort: function sort(order, useAnimation) {
2333
+ var items = {},
2334
+ rootEl = this.el;
2335
+ this.toArray().forEach(function (id, i) {
2336
+ var el = rootEl.children[i];
2337
+
2338
+ if (closest(el, this.options.draggable, rootEl, false)) {
2339
+ items[id] = el;
2340
+ }
2341
+ }, this);
2342
+ useAnimation && this.captureAnimationState();
2343
+ order.forEach(function (id) {
2344
+ if (items[id]) {
2345
+ rootEl.removeChild(items[id]);
2346
+ rootEl.appendChild(items[id]);
2347
+ }
2348
+ });
2349
+ useAnimation && this.animateAll();
2350
+ },
2351
+
2352
+ /**
2353
+ * Save the current sorting
2354
+ */
2355
+ save: function save() {
2356
+ var store = this.options.store;
2357
+ store && store.set && store.set(this);
2358
+ },
2359
+
2360
+ /**
2361
+ * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
2362
+ * @param {HTMLElement} el
2363
+ * @param {String} [selector] default: `options.draggable`
2364
+ * @returns {HTMLElement|null}
2365
+ */
2366
+ closest: function closest$1(el, selector) {
2367
+ return closest(el, selector || this.options.draggable, this.el, false);
2368
+ },
2369
+
2370
+ /**
2371
+ * Set/get option
2372
+ * @param {string} name
2373
+ * @param {*} [value]
2374
+ * @returns {*}
2375
+ */
2376
+ option: function option(name, value) {
2377
+ var options = this.options;
2378
+
2379
+ if (value === void 0) {
2380
+ return options[name];
2381
+ } else {
2382
+ var modifiedValue = PluginManager.modifyOption(this, name, value);
2383
+
2384
+ if (typeof modifiedValue !== 'undefined') {
2385
+ options[name] = modifiedValue;
2386
+ } else {
2387
+ options[name] = value;
2388
+ }
2389
+
2390
+ if (name === 'group') {
2391
+ _prepareGroup(options);
2392
+ }
2393
+ }
2394
+ },
2395
+
2396
+ /**
2397
+ * Destroy
2398
+ */
2399
+ destroy: function destroy() {
2400
+ pluginEvent('destroy', this);
2401
+ var el = this.el;
2402
+ el[expando] = null;
2403
+ off(el, 'mousedown', this._onTapStart);
2404
+ off(el, 'touchstart', this._onTapStart);
2405
+ off(el, 'pointerdown', this._onTapStart);
2406
+
2407
+ if (this.nativeDraggable) {
2408
+ off(el, 'dragover', this);
2409
+ off(el, 'dragenter', this);
2410
+ } // Remove draggable attributes
2411
+
2412
+
2413
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
2414
+ el.removeAttribute('draggable');
2415
+ });
2416
+
2417
+ this._onDrop();
2418
+
2419
+ this._disableDelayedDragEvents();
2420
+
2421
+ sortables.splice(sortables.indexOf(this.el), 1);
2422
+ this.el = el = null;
2423
+ },
2424
+ _hideClone: function _hideClone() {
2425
+ if (!cloneHidden) {
2426
+ pluginEvent('hideClone', this);
2427
+ if (Sortable.eventCanceled) return;
2428
+ css(cloneEl, 'display', 'none');
2429
+
2430
+ if (this.options.removeCloneOnHide && cloneEl.parentNode) {
2431
+ cloneEl.parentNode.removeChild(cloneEl);
2432
+ }
2433
+
2434
+ cloneHidden = true;
2435
+ }
2436
+ },
2437
+ _showClone: function _showClone(putSortable) {
2438
+ if (putSortable.lastPutMode !== 'clone') {
2439
+ this._hideClone();
2440
+
2441
+ return;
2442
+ }
2443
+
2444
+ if (cloneHidden) {
2445
+ pluginEvent('showClone', this);
2446
+ if (Sortable.eventCanceled) return; // show clone at dragEl or original position
2447
+
2448
+ if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
2449
+ rootEl.insertBefore(cloneEl, dragEl);
2450
+ } else if (nextEl) {
2451
+ rootEl.insertBefore(cloneEl, nextEl);
2452
+ } else {
2453
+ rootEl.appendChild(cloneEl);
2454
+ }
2455
+
2456
+ if (this.options.group.revertClone) {
2457
+ this.animate(dragEl, cloneEl);
2458
+ }
2459
+
2460
+ css(cloneEl, 'display', '');
2461
+ cloneHidden = false;
2462
+ }
2463
+ }
2464
+ };
2465
+
2466
+ function _globalDragOver(
2467
+ /**Event*/
2468
+ evt) {
2469
+ if (evt.dataTransfer) {
2470
+ evt.dataTransfer.dropEffect = 'move';
2471
+ }
2472
+
2473
+ evt.cancelable && evt.preventDefault();
2474
+ }
2475
+
2476
+ function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
2477
+ var evt,
2478
+ sortable = fromEl[expando],
2479
+ onMoveFn = sortable.options.onMove,
2480
+ retVal; // Support for new CustomEvent feature
2481
+
2482
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
2483
+ evt = new CustomEvent('move', {
2484
+ bubbles: true,
2485
+ cancelable: true
2486
+ });
2487
+ } else {
2488
+ evt = document.createEvent('Event');
2489
+ evt.initEvent('move', true, true);
2490
+ }
2491
+
2492
+ evt.to = toEl;
2493
+ evt.from = fromEl;
2494
+ evt.dragged = dragEl;
2495
+ evt.draggedRect = dragRect;
2496
+ evt.related = targetEl || toEl;
2497
+ evt.relatedRect = targetRect || getRect(toEl);
2498
+ evt.willInsertAfter = willInsertAfter;
2499
+ evt.originalEvent = originalEvent;
2500
+ fromEl.dispatchEvent(evt);
2501
+
2502
+ if (onMoveFn) {
2503
+ retVal = onMoveFn.call(sortable, evt, originalEvent);
2504
+ }
2505
+
2506
+ return retVal;
2507
+ }
2508
+
2509
+ function _disableDraggable(el) {
2510
+ el.draggable = false;
2511
+ }
2512
+
2513
+ function _unsilent() {
2514
+ _silent = false;
2515
+ }
2516
+
2517
+ function _ghostIsLast(evt, vertical, sortable) {
2518
+ var rect = getRect(lastChild(sortable.el, sortable.options.draggable));
2519
+ var spacer = 10;
2520
+ return vertical ? evt.clientX > rect.right + spacer || evt.clientX <= rect.right && evt.clientY > rect.bottom && evt.clientX >= rect.left : evt.clientX > rect.right && evt.clientY > rect.top || evt.clientX <= rect.right && evt.clientY > rect.bottom + spacer;
2521
+ }
2522
+
2523
+ function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
2524
+ var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
2525
+ targetLength = vertical ? targetRect.height : targetRect.width,
2526
+ targetS1 = vertical ? targetRect.top : targetRect.left,
2527
+ targetS2 = vertical ? targetRect.bottom : targetRect.right,
2528
+ invert = false;
2529
+
2530
+ if (!invertSwap) {
2531
+ // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
2532
+ if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
2533
+ // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
2534
+ // check if past first invert threshold on side opposite of lastDirection
2535
+ if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
2536
+ // past first invert threshold, do not restrict inverted threshold to dragEl shadow
2537
+ pastFirstInvertThresh = true;
2538
+ }
2539
+
2540
+ if (!pastFirstInvertThresh) {
2541
+ // dragEl shadow (target move distance shadow)
2542
+ if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
2543
+ : mouseOnAxis > targetS2 - targetMoveDistance) {
2544
+ return -lastDirection;
2545
+ }
2546
+ } else {
2547
+ invert = true;
2548
+ }
2549
+ } else {
2550
+ // Regular
2551
+ if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
2552
+ return _getInsertDirection(target);
2553
+ }
2554
+ }
2555
+ }
2556
+
2557
+ invert = invert || invertSwap;
2558
+
2559
+ if (invert) {
2560
+ // Invert of regular
2561
+ if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
2562
+ return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
2563
+ }
2564
+ }
2565
+
2566
+ return 0;
2567
+ }
2568
+ /**
2569
+ * Gets the direction dragEl must be swapped relative to target in order to make it
2570
+ * seem that dragEl has been "inserted" into that element's position
2571
+ * @param {HTMLElement} target The target whose position dragEl is being inserted at
2572
+ * @return {Number} Direction dragEl must be swapped
2573
+ */
2574
+
2575
+
2576
+ function _getInsertDirection(target) {
2577
+ if (index(dragEl) < index(target)) {
2578
+ return 1;
2579
+ } else {
2580
+ return -1;
2581
+ }
2582
+ }
2583
+ /**
2584
+ * Generate id
2585
+ * @param {HTMLElement} el
2586
+ * @returns {String}
2587
+ * @private
2588
+ */
2589
+
2590
+
2591
+ function _generateId(el) {
2592
+ var str = el.tagName + el.className + el.src + el.href + el.textContent,
2593
+ i = str.length,
2594
+ sum = 0;
2595
+
2596
+ while (i--) {
2597
+ sum += str.charCodeAt(i);
2598
+ }
2599
+
2600
+ return sum.toString(36);
2601
+ }
2602
+
2603
+ function _saveInputCheckedState(root) {
2604
+ savedInputChecked.length = 0;
2605
+ var inputs = root.getElementsByTagName('input');
2606
+ var idx = inputs.length;
2607
+
2608
+ while (idx--) {
2609
+ var el = inputs[idx];
2610
+ el.checked && savedInputChecked.push(el);
2611
+ }
2612
+ }
2613
+
2614
+ function _nextTick(fn) {
2615
+ return setTimeout(fn, 0);
2616
+ }
2617
+
2618
+ function _cancelNextTick(id) {
2619
+ return clearTimeout(id);
2620
+ } // Fixed #973:
2621
+
2622
+
2623
+ if (documentExists) {
2624
+ on(document, 'touchmove', function (evt) {
2625
+ if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
2626
+ evt.preventDefault();
2627
+ }
2628
+ });
2629
+ } // Export utils
2630
+
2631
+
2632
+ Sortable.utils = {
2633
+ on: on,
2634
+ off: off,
2635
+ css: css,
2636
+ find: find,
2637
+ is: function is(el, selector) {
2638
+ return !!closest(el, selector, el, false);
2639
+ },
2640
+ extend: extend,
2641
+ throttle: throttle,
2642
+ closest: closest,
2643
+ toggleClass: toggleClass,
2644
+ clone: clone,
2645
+ index: index,
2646
+ nextTick: _nextTick,
2647
+ cancelNextTick: _cancelNextTick,
2648
+ detectDirection: _detectDirection,
2649
+ getChild: getChild
2650
+ };
2651
+ /**
2652
+ * Get the Sortable instance of an element
2653
+ * @param {HTMLElement} element The element
2654
+ * @return {Sortable|undefined} The instance of Sortable
2655
+ */
2656
+
2657
+ Sortable.get = function (element) {
2658
+ return element[expando];
2659
+ };
2660
+ /**
2661
+ * Mount a plugin to Sortable
2662
+ * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
2663
+ */
2664
+
2665
+
2666
+ Sortable.mount = function () {
2667
+ for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
2668
+ plugins[_key] = arguments[_key];
2669
+ }
2670
+
2671
+ if (plugins[0].constructor === Array) plugins = plugins[0];
2672
+ plugins.forEach(function (plugin) {
2673
+ if (!plugin.prototype || !plugin.prototype.constructor) {
2674
+ throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
2675
+ }
2676
+
2677
+ if (plugin.utils) Sortable.utils = _objectSpread({}, Sortable.utils, plugin.utils);
2678
+ PluginManager.mount(plugin);
2679
+ });
2680
+ };
2681
+ /**
2682
+ * Create sortable instance
2683
+ * @param {HTMLElement} el
2684
+ * @param {Object} [options]
2685
+ */
2686
+
2687
+
2688
+ Sortable.create = function (el, options) {
2689
+ return new Sortable(el, options);
2690
+ }; // Export
2691
+
2692
+
2693
+ Sortable.version = version;
2694
+
2695
+ var autoScrolls = [],
2696
+ scrollEl,
2697
+ scrollRootEl,
2698
+ scrolling = false,
2699
+ lastAutoScrollX,
2700
+ lastAutoScrollY,
2701
+ touchEvt$1,
2702
+ pointerElemChangedInterval;
2703
+
2704
+ function AutoScrollPlugin() {
2705
+ function AutoScroll() {
2706
+ this.defaults = {
2707
+ scroll: true,
2708
+ scrollSensitivity: 30,
2709
+ scrollSpeed: 10,
2710
+ bubbleScroll: true
2711
+ }; // Bind all private methods
2712
+
2713
+ for (var fn in this) {
2714
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
2715
+ this[fn] = this[fn].bind(this);
2716
+ }
2717
+ }
2718
+ }
2719
+
2720
+ AutoScroll.prototype = {
2721
+ dragStarted: function dragStarted(_ref) {
2722
+ var originalEvent = _ref.originalEvent;
2723
+
2724
+ if (this.sortable.nativeDraggable) {
2725
+ on(document, 'dragover', this._handleAutoScroll);
2726
+ } else {
2727
+ if (this.options.supportPointer) {
2728
+ on(document, 'pointermove', this._handleFallbackAutoScroll);
2729
+ } else if (originalEvent.touches) {
2730
+ on(document, 'touchmove', this._handleFallbackAutoScroll);
2731
+ } else {
2732
+ on(document, 'mousemove', this._handleFallbackAutoScroll);
2733
+ }
2734
+ }
2735
+ },
2736
+ dragOverCompleted: function dragOverCompleted(_ref2) {
2737
+ var originalEvent = _ref2.originalEvent;
2738
+
2739
+ // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
2740
+ if (!this.options.dragOverBubble && !originalEvent.rootEl) {
2741
+ this._handleAutoScroll(originalEvent);
2742
+ }
2743
+ },
2744
+ drop: function drop() {
2745
+ if (this.sortable.nativeDraggable) {
2746
+ off(document, 'dragover', this._handleAutoScroll);
2747
+ } else {
2748
+ off(document, 'pointermove', this._handleFallbackAutoScroll);
2749
+ off(document, 'touchmove', this._handleFallbackAutoScroll);
2750
+ off(document, 'mousemove', this._handleFallbackAutoScroll);
2751
+ }
2752
+
2753
+ clearPointerElemChangedInterval();
2754
+ clearAutoScrolls();
2755
+ cancelThrottle();
2756
+ },
2757
+ nulling: function nulling() {
2758
+ touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
2759
+ autoScrolls.length = 0;
2760
+ },
2761
+ _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
2762
+ this._handleAutoScroll(evt, true);
2763
+ },
2764
+ _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
2765
+ var _this = this;
2766
+
2767
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2768
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2769
+ elem = document.elementFromPoint(x, y);
2770
+ touchEvt$1 = evt; // IE does not seem to have native autoscroll,
2771
+ // Edge's autoscroll seems too conditional,
2772
+ // MACOS Safari does not have autoscroll,
2773
+ // Firefox and Chrome are good
2774
+
2775
+ if (fallback || Edge || IE11OrLess || Safari) {
2776
+ autoScroll(evt, this.options, elem, fallback); // Listener for pointer element change
2777
+
2778
+ var ogElemScroller = getParentAutoScrollElement(elem, true);
2779
+
2780
+ if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
2781
+ pointerElemChangedInterval && clearPointerElemChangedInterval(); // Detect for pointer elem change, emulating native DnD behaviour
2782
+
2783
+ pointerElemChangedInterval = setInterval(function () {
2784
+ var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
2785
+
2786
+ if (newElem !== ogElemScroller) {
2787
+ ogElemScroller = newElem;
2788
+ clearAutoScrolls();
2789
+ }
2790
+
2791
+ autoScroll(evt, _this.options, newElem, fallback);
2792
+ }, 10);
2793
+ lastAutoScrollX = x;
2794
+ lastAutoScrollY = y;
2795
+ }
2796
+ } else {
2797
+ // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
2798
+ if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
2799
+ clearAutoScrolls();
2800
+ return;
2801
+ }
2802
+
2803
+ autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
2804
+ }
2805
+ }
2806
+ };
2807
+ return _extends(AutoScroll, {
2808
+ pluginName: 'scroll',
2809
+ initializeByDefault: true
2810
+ });
2811
+ }
2812
+
2813
+ function clearAutoScrolls() {
2814
+ autoScrolls.forEach(function (autoScroll) {
2815
+ clearInterval(autoScroll.pid);
2816
+ });
2817
+ autoScrolls = [];
2818
+ }
2819
+
2820
+ function clearPointerElemChangedInterval() {
2821
+ clearInterval(pointerElemChangedInterval);
2822
+ }
2823
+
2824
+ var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
2825
+ // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
2826
+ if (!options.scroll) return;
2827
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2828
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2829
+ sens = options.scrollSensitivity,
2830
+ speed = options.scrollSpeed,
2831
+ winScroller = getWindowScrollingElement();
2832
+ var scrollThisInstance = false,
2833
+ scrollCustomFn; // New scroll root, set scrollEl
2834
+
2835
+ if (scrollRootEl !== rootEl) {
2836
+ scrollRootEl = rootEl;
2837
+ clearAutoScrolls();
2838
+ scrollEl = options.scroll;
2839
+ scrollCustomFn = options.scrollFn;
2840
+
2841
+ if (scrollEl === true) {
2842
+ scrollEl = getParentAutoScrollElement(rootEl, true);
2843
+ }
2844
+ }
2845
+
2846
+ var layersOut = 0;
2847
+ var currentParent = scrollEl;
2848
+
2849
+ do {
2850
+ var el = currentParent,
2851
+ rect = getRect(el),
2852
+ top = rect.top,
2853
+ bottom = rect.bottom,
2854
+ left = rect.left,
2855
+ right = rect.right,
2856
+ width = rect.width,
2857
+ height = rect.height,
2858
+ canScrollX = void 0,
2859
+ canScrollY = void 0,
2860
+ scrollWidth = el.scrollWidth,
2861
+ scrollHeight = el.scrollHeight,
2862
+ elCSS = css(el),
2863
+ scrollPosX = el.scrollLeft,
2864
+ scrollPosY = el.scrollTop;
2865
+
2866
+ if (el === winScroller) {
2867
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
2868
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
2869
+ } else {
2870
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
2871
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
2872
+ }
2873
+
2874
+ var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
2875
+ var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
2876
+
2877
+ if (!autoScrolls[layersOut]) {
2878
+ for (var i = 0; i <= layersOut; i++) {
2879
+ if (!autoScrolls[i]) {
2880
+ autoScrolls[i] = {};
2881
+ }
2882
+ }
2883
+ }
2884
+
2885
+ if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
2886
+ autoScrolls[layersOut].el = el;
2887
+ autoScrolls[layersOut].vx = vx;
2888
+ autoScrolls[layersOut].vy = vy;
2889
+ clearInterval(autoScrolls[layersOut].pid);
2890
+
2891
+ if (vx != 0 || vy != 0) {
2892
+ scrollThisInstance = true;
2893
+ /* jshint loopfunc:true */
2894
+
2895
+ autoScrolls[layersOut].pid = setInterval(function () {
2896
+ // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
2897
+ if (isFallback && this.layer === 0) {
2898
+ Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
2899
+
2900
+ }
2901
+
2902
+ var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
2903
+ var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
2904
+
2905
+ if (typeof scrollCustomFn === 'function') {
2906
+ if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
2907
+ return;
2908
+ }
2909
+ }
2910
+
2911
+ scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
2912
+ }.bind({
2913
+ layer: layersOut
2914
+ }), 24);
2915
+ }
2916
+ }
2917
+
2918
+ layersOut++;
2919
+ } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
2920
+
2921
+ scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
2922
+ }, 30);
2923
+
2924
+ var drop = function drop(_ref) {
2925
+ var originalEvent = _ref.originalEvent,
2926
+ putSortable = _ref.putSortable,
2927
+ dragEl = _ref.dragEl,
2928
+ activeSortable = _ref.activeSortable,
2929
+ dispatchSortableEvent = _ref.dispatchSortableEvent,
2930
+ hideGhostForTarget = _ref.hideGhostForTarget,
2931
+ unhideGhostForTarget = _ref.unhideGhostForTarget;
2932
+ if (!originalEvent) return;
2933
+ var toSortable = putSortable || activeSortable;
2934
+ hideGhostForTarget();
2935
+ var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
2936
+ var target = document.elementFromPoint(touch.clientX, touch.clientY);
2937
+ unhideGhostForTarget();
2938
+
2939
+ if (toSortable && !toSortable.el.contains(target)) {
2940
+ dispatchSortableEvent('spill');
2941
+ this.onSpill({
2942
+ dragEl: dragEl,
2943
+ putSortable: putSortable
2944
+ });
2945
+ }
2946
+ };
2947
+
2948
+ function Revert() {}
2949
+
2950
+ Revert.prototype = {
2951
+ startIndex: null,
2952
+ dragStart: function dragStart(_ref2) {
2953
+ var oldDraggableIndex = _ref2.oldDraggableIndex;
2954
+ this.startIndex = oldDraggableIndex;
2955
+ },
2956
+ onSpill: function onSpill(_ref3) {
2957
+ var dragEl = _ref3.dragEl,
2958
+ putSortable = _ref3.putSortable;
2959
+ this.sortable.captureAnimationState();
2960
+
2961
+ if (putSortable) {
2962
+ putSortable.captureAnimationState();
2963
+ }
2964
+
2965
+ var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
2966
+
2967
+ if (nextSibling) {
2968
+ this.sortable.el.insertBefore(dragEl, nextSibling);
2969
+ } else {
2970
+ this.sortable.el.appendChild(dragEl);
2971
+ }
2972
+
2973
+ this.sortable.animateAll();
2974
+
2975
+ if (putSortable) {
2976
+ putSortable.animateAll();
2977
+ }
2978
+ },
2979
+ drop: drop
2980
+ };
2981
+
2982
+ _extends(Revert, {
2983
+ pluginName: 'revertOnSpill'
2984
+ });
2985
+
2986
+ function Remove() {}
2987
+
2988
+ Remove.prototype = {
2989
+ onSpill: function onSpill(_ref4) {
2990
+ var dragEl = _ref4.dragEl,
2991
+ putSortable = _ref4.putSortable;
2992
+ var parentSortable = putSortable || this.sortable;
2993
+ parentSortable.captureAnimationState();
2994
+ dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
2995
+ parentSortable.animateAll();
2996
+ },
2997
+ drop: drop
2998
+ };
2999
+
3000
+ _extends(Remove, {
3001
+ pluginName: 'removeOnSpill'
3002
+ });
3003
+
3004
+ var lastSwapEl;
3005
+
3006
+ function SwapPlugin() {
3007
+ function Swap() {
3008
+ this.defaults = {
3009
+ swapClass: 'sortable-swap-highlight'
3010
+ };
3011
+ }
3012
+
3013
+ Swap.prototype = {
3014
+ dragStart: function dragStart(_ref) {
3015
+ var dragEl = _ref.dragEl;
3016
+ lastSwapEl = dragEl;
3017
+ },
3018
+ dragOverValid: function dragOverValid(_ref2) {
3019
+ var completed = _ref2.completed,
3020
+ target = _ref2.target,
3021
+ onMove = _ref2.onMove,
3022
+ activeSortable = _ref2.activeSortable,
3023
+ changed = _ref2.changed,
3024
+ cancel = _ref2.cancel;
3025
+ if (!activeSortable.options.swap) return;
3026
+ var el = this.sortable.el,
3027
+ options = this.options;
3028
+
3029
+ if (target && target !== el) {
3030
+ var prevSwapEl = lastSwapEl;
3031
+
3032
+ if (onMove(target) !== false) {
3033
+ toggleClass(target, options.swapClass, true);
3034
+ lastSwapEl = target;
3035
+ } else {
3036
+ lastSwapEl = null;
3037
+ }
3038
+
3039
+ if (prevSwapEl && prevSwapEl !== lastSwapEl) {
3040
+ toggleClass(prevSwapEl, options.swapClass, false);
3041
+ }
3042
+ }
3043
+
3044
+ changed();
3045
+ completed(true);
3046
+ cancel();
3047
+ },
3048
+ drop: function drop(_ref3) {
3049
+ var activeSortable = _ref3.activeSortable,
3050
+ putSortable = _ref3.putSortable,
3051
+ dragEl = _ref3.dragEl;
3052
+ var toSortable = putSortable || this.sortable;
3053
+ var options = this.options;
3054
+ lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
3055
+
3056
+ if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
3057
+ if (dragEl !== lastSwapEl) {
3058
+ toSortable.captureAnimationState();
3059
+ if (toSortable !== activeSortable) activeSortable.captureAnimationState();
3060
+ swapNodes(dragEl, lastSwapEl);
3061
+ toSortable.animateAll();
3062
+ if (toSortable !== activeSortable) activeSortable.animateAll();
3063
+ }
3064
+ }
3065
+ },
3066
+ nulling: function nulling() {
3067
+ lastSwapEl = null;
3068
+ }
3069
+ };
3070
+ return _extends(Swap, {
3071
+ pluginName: 'swap',
3072
+ eventProperties: function eventProperties() {
3073
+ return {
3074
+ swapItem: lastSwapEl
3075
+ };
3076
+ }
3077
+ });
3078
+ }
3079
+
3080
+ function swapNodes(n1, n2) {
3081
+ var p1 = n1.parentNode,
3082
+ p2 = n2.parentNode,
3083
+ i1,
3084
+ i2;
3085
+ if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
3086
+ i1 = index(n1);
3087
+ i2 = index(n2);
3088
+
3089
+ if (p1.isEqualNode(p2) && i1 < i2) {
3090
+ i2++;
3091
+ }
3092
+
3093
+ p1.insertBefore(n2, p1.children[i1]);
3094
+ p2.insertBefore(n1, p2.children[i2]);
3095
+ }
3096
+
3097
+ var multiDragElements = [],
3098
+ multiDragClones = [],
3099
+ lastMultiDragSelect,
3100
+ // for selection with modifier key down (SHIFT)
3101
+ multiDragSortable,
3102
+ initialFolding = false,
3103
+ // Initial multi-drag fold when drag started
3104
+ folding = false,
3105
+ // Folding any other time
3106
+ dragStarted = false,
3107
+ dragEl$1,
3108
+ clonesFromRect,
3109
+ clonesHidden;
3110
+
3111
+ function MultiDragPlugin() {
3112
+ function MultiDrag(sortable) {
3113
+ // Bind all private methods
3114
+ for (var fn in this) {
3115
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
3116
+ this[fn] = this[fn].bind(this);
3117
+ }
3118
+ }
3119
+
3120
+ if (sortable.options.supportPointer) {
3121
+ on(document, 'pointerup', this._deselectMultiDrag);
3122
+ } else {
3123
+ on(document, 'mouseup', this._deselectMultiDrag);
3124
+ on(document, 'touchend', this._deselectMultiDrag);
3125
+ }
3126
+
3127
+ on(document, 'keydown', this._checkKeyDown);
3128
+ on(document, 'keyup', this._checkKeyUp);
3129
+ this.defaults = {
3130
+ selectedClass: 'sortable-selected',
3131
+ multiDragKey: null,
3132
+ setData: function setData(dataTransfer, dragEl) {
3133
+ var data = '';
3134
+
3135
+ if (multiDragElements.length && multiDragSortable === sortable) {
3136
+ multiDragElements.forEach(function (multiDragElement, i) {
3137
+ data += (!i ? '' : ', ') + multiDragElement.textContent;
3138
+ });
3139
+ } else {
3140
+ data = dragEl.textContent;
3141
+ }
3142
+
3143
+ dataTransfer.setData('Text', data);
3144
+ }
3145
+ };
3146
+ }
3147
+
3148
+ MultiDrag.prototype = {
3149
+ multiDragKeyDown: false,
3150
+ isMultiDrag: false,
3151
+ delayStartGlobal: function delayStartGlobal(_ref) {
3152
+ var dragged = _ref.dragEl;
3153
+ dragEl$1 = dragged;
3154
+ },
3155
+ delayEnded: function delayEnded() {
3156
+ this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
3157
+ },
3158
+ setupClone: function setupClone(_ref2) {
3159
+ var sortable = _ref2.sortable,
3160
+ cancel = _ref2.cancel;
3161
+ if (!this.isMultiDrag) return;
3162
+
3163
+ for (var i = 0; i < multiDragElements.length; i++) {
3164
+ multiDragClones.push(clone(multiDragElements[i]));
3165
+ multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
3166
+ multiDragClones[i].draggable = false;
3167
+ multiDragClones[i].style['will-change'] = '';
3168
+ toggleClass(multiDragClones[i], this.options.selectedClass, false);
3169
+ multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
3170
+ }
3171
+
3172
+ sortable._hideClone();
3173
+
3174
+ cancel();
3175
+ },
3176
+ clone: function clone(_ref3) {
3177
+ var sortable = _ref3.sortable,
3178
+ rootEl = _ref3.rootEl,
3179
+ dispatchSortableEvent = _ref3.dispatchSortableEvent,
3180
+ cancel = _ref3.cancel;
3181
+ if (!this.isMultiDrag) return;
3182
+
3183
+ if (!this.options.removeCloneOnHide) {
3184
+ if (multiDragElements.length && multiDragSortable === sortable) {
3185
+ insertMultiDragClones(true, rootEl);
3186
+ dispatchSortableEvent('clone');
3187
+ cancel();
3188
+ }
3189
+ }
3190
+ },
3191
+ showClone: function showClone(_ref4) {
3192
+ var cloneNowShown = _ref4.cloneNowShown,
3193
+ rootEl = _ref4.rootEl,
3194
+ cancel = _ref4.cancel;
3195
+ if (!this.isMultiDrag) return;
3196
+ insertMultiDragClones(false, rootEl);
3197
+ multiDragClones.forEach(function (clone) {
3198
+ css(clone, 'display', '');
3199
+ });
3200
+ cloneNowShown();
3201
+ clonesHidden = false;
3202
+ cancel();
3203
+ },
3204
+ hideClone: function hideClone(_ref5) {
3205
+ var _this = this;
3206
+
3207
+ var sortable = _ref5.sortable,
3208
+ cloneNowHidden = _ref5.cloneNowHidden,
3209
+ cancel = _ref5.cancel;
3210
+ if (!this.isMultiDrag) return;
3211
+ multiDragClones.forEach(function (clone) {
3212
+ css(clone, 'display', 'none');
3213
+
3214
+ if (_this.options.removeCloneOnHide && clone.parentNode) {
3215
+ clone.parentNode.removeChild(clone);
3216
+ }
3217
+ });
3218
+ cloneNowHidden();
3219
+ clonesHidden = true;
3220
+ cancel();
3221
+ },
3222
+ dragStartGlobal: function dragStartGlobal(_ref6) {
3223
+ var sortable = _ref6.sortable;
3224
+
3225
+ if (!this.isMultiDrag && multiDragSortable) {
3226
+ multiDragSortable.multiDrag._deselectMultiDrag();
3227
+ }
3228
+
3229
+ multiDragElements.forEach(function (multiDragElement) {
3230
+ multiDragElement.sortableIndex = index(multiDragElement);
3231
+ }); // Sort multi-drag elements
3232
+
3233
+ multiDragElements = multiDragElements.sort(function (a, b) {
3234
+ return a.sortableIndex - b.sortableIndex;
3235
+ });
3236
+ dragStarted = true;
3237
+ },
3238
+ dragStarted: function dragStarted(_ref7) {
3239
+ var _this2 = this;
3240
+
3241
+ var sortable = _ref7.sortable;
3242
+ if (!this.isMultiDrag) return;
3243
+
3244
+ if (this.options.sort) {
3245
+ // Capture rects,
3246
+ // hide multi drag elements (by positioning them absolute),
3247
+ // set multi drag elements rects to dragRect,
3248
+ // show multi drag elements,
3249
+ // animate to rects,
3250
+ // unset rects & remove from DOM
3251
+ sortable.captureAnimationState();
3252
+
3253
+ if (this.options.animation) {
3254
+ multiDragElements.forEach(function (multiDragElement) {
3255
+ if (multiDragElement === dragEl$1) return;
3256
+ css(multiDragElement, 'position', 'absolute');
3257
+ });
3258
+ var dragRect = getRect(dragEl$1, false, true, true);
3259
+ multiDragElements.forEach(function (multiDragElement) {
3260
+ if (multiDragElement === dragEl$1) return;
3261
+ setRect(multiDragElement, dragRect);
3262
+ });
3263
+ folding = true;
3264
+ initialFolding = true;
3265
+ }
3266
+ }
3267
+
3268
+ sortable.animateAll(function () {
3269
+ folding = false;
3270
+ initialFolding = false;
3271
+
3272
+ if (_this2.options.animation) {
3273
+ multiDragElements.forEach(function (multiDragElement) {
3274
+ unsetRect(multiDragElement);
3275
+ });
3276
+ } // Remove all auxiliary multidrag items from el, if sorting enabled
3277
+
3278
+
3279
+ if (_this2.options.sort) {
3280
+ removeMultiDragElements();
3281
+ }
3282
+ });
3283
+ },
3284
+ dragOver: function dragOver(_ref8) {
3285
+ var target = _ref8.target,
3286
+ completed = _ref8.completed,
3287
+ cancel = _ref8.cancel;
3288
+
3289
+ if (folding && ~multiDragElements.indexOf(target)) {
3290
+ completed(false);
3291
+ cancel();
3292
+ }
3293
+ },
3294
+ revert: function revert(_ref9) {
3295
+ var fromSortable = _ref9.fromSortable,
3296
+ rootEl = _ref9.rootEl,
3297
+ sortable = _ref9.sortable,
3298
+ dragRect = _ref9.dragRect;
3299
+
3300
+ if (multiDragElements.length > 1) {
3301
+ // Setup unfold animation
3302
+ multiDragElements.forEach(function (multiDragElement) {
3303
+ sortable.addAnimationState({
3304
+ target: multiDragElement,
3305
+ rect: folding ? getRect(multiDragElement) : dragRect
3306
+ });
3307
+ unsetRect(multiDragElement);
3308
+ multiDragElement.fromRect = dragRect;
3309
+ fromSortable.removeAnimationState(multiDragElement);
3310
+ });
3311
+ folding = false;
3312
+ insertMultiDragElements(!this.options.removeCloneOnHide, rootEl);
3313
+ }
3314
+ },
3315
+ dragOverCompleted: function dragOverCompleted(_ref10) {
3316
+ var sortable = _ref10.sortable,
3317
+ isOwner = _ref10.isOwner,
3318
+ insertion = _ref10.insertion,
3319
+ activeSortable = _ref10.activeSortable,
3320
+ parentEl = _ref10.parentEl,
3321
+ putSortable = _ref10.putSortable;
3322
+ var options = this.options;
3323
+
3324
+ if (insertion) {
3325
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
3326
+ if (isOwner) {
3327
+ activeSortable._hideClone();
3328
+ }
3329
+
3330
+ initialFolding = false; // If leaving sort:false root, or already folding - Fold to new location
3331
+
3332
+ if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
3333
+ // Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
3334
+ var dragRectAbsolute = getRect(dragEl$1, false, true, true);
3335
+ multiDragElements.forEach(function (multiDragElement) {
3336
+ if (multiDragElement === dragEl$1) return;
3337
+ setRect(multiDragElement, dragRectAbsolute); // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
3338
+ // while folding, and so that we can capture them again because old sortable will no longer be fromSortable
3339
+
3340
+ parentEl.appendChild(multiDragElement);
3341
+ });
3342
+ folding = true;
3343
+ } // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
3344
+
3345
+
3346
+ if (!isOwner) {
3347
+ // Only remove if not folding (folding will remove them anyways)
3348
+ if (!folding) {
3349
+ removeMultiDragElements();
3350
+ }
3351
+
3352
+ if (multiDragElements.length > 1) {
3353
+ var clonesHiddenBefore = clonesHidden;
3354
+
3355
+ activeSortable._showClone(sortable); // Unfold animation for clones if showing from hidden
3356
+
3357
+
3358
+ if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
3359
+ multiDragClones.forEach(function (clone) {
3360
+ activeSortable.addAnimationState({
3361
+ target: clone,
3362
+ rect: clonesFromRect
3363
+ });
3364
+ clone.fromRect = clonesFromRect;
3365
+ clone.thisAnimationDuration = null;
3366
+ });
3367
+ }
3368
+ } else {
3369
+ activeSortable._showClone(sortable);
3370
+ }
3371
+ }
3372
+ }
3373
+ },
3374
+ dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
3375
+ var dragRect = _ref11.dragRect,
3376
+ isOwner = _ref11.isOwner,
3377
+ activeSortable = _ref11.activeSortable;
3378
+ multiDragElements.forEach(function (multiDragElement) {
3379
+ multiDragElement.thisAnimationDuration = null;
3380
+ });
3381
+
3382
+ if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
3383
+ clonesFromRect = _extends({}, dragRect);
3384
+ var dragMatrix = matrix(dragEl$1, true);
3385
+ clonesFromRect.top -= dragMatrix.f;
3386
+ clonesFromRect.left -= dragMatrix.e;
3387
+ }
3388
+ },
3389
+ dragOverAnimationComplete: function dragOverAnimationComplete() {
3390
+ if (folding) {
3391
+ folding = false;
3392
+ removeMultiDragElements();
3393
+ }
3394
+ },
3395
+ drop: function drop(_ref12) {
3396
+ var evt = _ref12.originalEvent,
3397
+ rootEl = _ref12.rootEl,
3398
+ parentEl = _ref12.parentEl,
3399
+ sortable = _ref12.sortable,
3400
+ dispatchSortableEvent = _ref12.dispatchSortableEvent,
3401
+ oldIndex = _ref12.oldIndex,
3402
+ putSortable = _ref12.putSortable;
3403
+ var toSortable = putSortable || this.sortable;
3404
+ if (!evt) return;
3405
+ var options = this.options,
3406
+ children = parentEl.children; // Multi-drag selection
3407
+
3408
+ if (!dragStarted) {
3409
+ if (options.multiDragKey && !this.multiDragKeyDown) {
3410
+ this._deselectMultiDrag();
3411
+ }
3412
+
3413
+ toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
3414
+
3415
+ if (!~multiDragElements.indexOf(dragEl$1)) {
3416
+ multiDragElements.push(dragEl$1);
3417
+ dispatchEvent({
3418
+ sortable: sortable,
3419
+ rootEl: rootEl,
3420
+ name: 'select',
3421
+ targetEl: dragEl$1,
3422
+ originalEvt: evt
3423
+ }); // Modifier activated, select from last to dragEl
3424
+
3425
+ if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
3426
+ var lastIndex = index(lastMultiDragSelect),
3427
+ currentIndex = index(dragEl$1);
3428
+
3429
+ if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
3430
+ // Must include lastMultiDragSelect (select it), in case modified selection from no selection
3431
+ // (but previous selection existed)
3432
+ var n, i;
3433
+
3434
+ if (currentIndex > lastIndex) {
3435
+ i = lastIndex;
3436
+ n = currentIndex;
3437
+ } else {
3438
+ i = currentIndex;
3439
+ n = lastIndex + 1;
3440
+ }
3441
+
3442
+ for (; i < n; i++) {
3443
+ if (~multiDragElements.indexOf(children[i])) continue;
3444
+ toggleClass(children[i], options.selectedClass, true);
3445
+ multiDragElements.push(children[i]);
3446
+ dispatchEvent({
3447
+ sortable: sortable,
3448
+ rootEl: rootEl,
3449
+ name: 'select',
3450
+ targetEl: children[i],
3451
+ originalEvt: evt
3452
+ });
3453
+ }
3454
+ }
3455
+ } else {
3456
+ lastMultiDragSelect = dragEl$1;
3457
+ }
3458
+
3459
+ multiDragSortable = toSortable;
3460
+ } else {
3461
+ multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
3462
+ lastMultiDragSelect = null;
3463
+ dispatchEvent({
3464
+ sortable: sortable,
3465
+ rootEl: rootEl,
3466
+ name: 'deselect',
3467
+ targetEl: dragEl$1,
3468
+ originalEvt: evt
3469
+ });
3470
+ }
3471
+ } // Multi-drag drop
3472
+
3473
+
3474
+ if (dragStarted && this.isMultiDrag) {
3475
+ // Do not "unfold" after around dragEl if reverted
3476
+ if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
3477
+ var dragRect = getRect(dragEl$1),
3478
+ multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')');
3479
+ if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
3480
+ toSortable.captureAnimationState();
3481
+
3482
+ if (!initialFolding) {
3483
+ if (options.animation) {
3484
+ dragEl$1.fromRect = dragRect;
3485
+ multiDragElements.forEach(function (multiDragElement) {
3486
+ multiDragElement.thisAnimationDuration = null;
3487
+
3488
+ if (multiDragElement !== dragEl$1) {
3489
+ var rect = folding ? getRect(multiDragElement) : dragRect;
3490
+ multiDragElement.fromRect = rect; // Prepare unfold animation
3491
+
3492
+ toSortable.addAnimationState({
3493
+ target: multiDragElement,
3494
+ rect: rect
3495
+ });
3496
+ }
3497
+ });
3498
+ } // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
3499
+ // properly they must all be removed
3500
+
3501
+
3502
+ removeMultiDragElements();
3503
+ multiDragElements.forEach(function (multiDragElement) {
3504
+ if (children[multiDragIndex]) {
3505
+ parentEl.insertBefore(multiDragElement, children[multiDragIndex]);
3506
+ } else {
3507
+ parentEl.appendChild(multiDragElement);
3508
+ }
3509
+
3510
+ multiDragIndex++;
3511
+ }); // If initial folding is done, the elements may have changed position because they are now
3512
+ // unfolding around dragEl, even though dragEl may not have his index changed, so update event
3513
+ // must be fired here as Sortable will not.
3514
+
3515
+ if (oldIndex === index(dragEl$1)) {
3516
+ var update = false;
3517
+ multiDragElements.forEach(function (multiDragElement) {
3518
+ if (multiDragElement.sortableIndex !== index(multiDragElement)) {
3519
+ update = true;
3520
+ return;
3521
+ }
3522
+ });
3523
+
3524
+ if (update) {
3525
+ dispatchSortableEvent('update');
3526
+ }
3527
+ }
3528
+ } // Must be done after capturing individual rects (scroll bar)
3529
+
3530
+
3531
+ multiDragElements.forEach(function (multiDragElement) {
3532
+ unsetRect(multiDragElement);
3533
+ });
3534
+ toSortable.animateAll();
3535
+ }
3536
+
3537
+ multiDragSortable = toSortable;
3538
+ } // Remove clones if necessary
3539
+
3540
+
3541
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
3542
+ multiDragClones.forEach(function (clone) {
3543
+ clone.parentNode && clone.parentNode.removeChild(clone);
3544
+ });
3545
+ }
3546
+ },
3547
+ nullingGlobal: function nullingGlobal() {
3548
+ this.isMultiDrag = dragStarted = false;
3549
+ multiDragClones.length = 0;
3550
+ },
3551
+ destroyGlobal: function destroyGlobal() {
3552
+ this._deselectMultiDrag();
3553
+
3554
+ off(document, 'pointerup', this._deselectMultiDrag);
3555
+ off(document, 'mouseup', this._deselectMultiDrag);
3556
+ off(document, 'touchend', this._deselectMultiDrag);
3557
+ off(document, 'keydown', this._checkKeyDown);
3558
+ off(document, 'keyup', this._checkKeyUp);
3559
+ },
3560
+ _deselectMultiDrag: function _deselectMultiDrag(evt) {
3561
+ if (typeof dragStarted !== "undefined" && dragStarted) return; // Only deselect if selection is in this sortable
3562
+
3563
+ if (multiDragSortable !== this.sortable) return; // Only deselect if target is not item in this sortable
3564
+
3565
+ if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return; // Only deselect if left click
3566
+
3567
+ if (evt && evt.button !== 0) return;
3568
+
3569
+ while (multiDragElements.length) {
3570
+ var el = multiDragElements[0];
3571
+ toggleClass(el, this.options.selectedClass, false);
3572
+ multiDragElements.shift();
3573
+ dispatchEvent({
3574
+ sortable: this.sortable,
3575
+ rootEl: this.sortable.el,
3576
+ name: 'deselect',
3577
+ targetEl: el,
3578
+ originalEvt: evt
3579
+ });
3580
+ }
3581
+ },
3582
+ _checkKeyDown: function _checkKeyDown(evt) {
3583
+ if (evt.key === this.options.multiDragKey) {
3584
+ this.multiDragKeyDown = true;
3585
+ }
3586
+ },
3587
+ _checkKeyUp: function _checkKeyUp(evt) {
3588
+ if (evt.key === this.options.multiDragKey) {
3589
+ this.multiDragKeyDown = false;
3590
+ }
3591
+ }
3592
+ };
3593
+ return _extends(MultiDrag, {
3594
+ // Static methods & properties
3595
+ pluginName: 'multiDrag',
3596
+ utils: {
3597
+ /**
3598
+ * Selects the provided multi-drag item
3599
+ * @param {HTMLElement} el The element to be selected
3600
+ */
3601
+ select: function select(el) {
3602
+ var sortable = el.parentNode[expando];
3603
+ if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return;
3604
+
3605
+ if (multiDragSortable && multiDragSortable !== sortable) {
3606
+ multiDragSortable.multiDrag._deselectMultiDrag();
3607
+
3608
+ multiDragSortable = sortable;
3609
+ }
3610
+
3611
+ toggleClass(el, sortable.options.selectedClass, true);
3612
+ multiDragElements.push(el);
3613
+ },
3614
+
3615
+ /**
3616
+ * Deselects the provided multi-drag item
3617
+ * @param {HTMLElement} el The element to be deselected
3618
+ */
3619
+ deselect: function deselect(el) {
3620
+ var sortable = el.parentNode[expando],
3621
+ index = multiDragElements.indexOf(el);
3622
+ if (!sortable || !sortable.options.multiDrag || !~index) return;
3623
+ toggleClass(el, sortable.options.selectedClass, false);
3624
+ multiDragElements.splice(index, 1);
3625
+ }
3626
+ },
3627
+ eventProperties: function eventProperties() {
3628
+ var _this3 = this;
3629
+
3630
+ var oldIndicies = [],
3631
+ newIndicies = [];
3632
+ multiDragElements.forEach(function (multiDragElement) {
3633
+ oldIndicies.push({
3634
+ multiDragElement: multiDragElement,
3635
+ index: multiDragElement.sortableIndex
3636
+ }); // multiDragElements will already be sorted if folding
3637
+
3638
+ var newIndex;
3639
+
3640
+ if (folding && multiDragElement !== dragEl$1) {
3641
+ newIndex = -1;
3642
+ } else if (folding) {
3643
+ newIndex = index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')');
3644
+ } else {
3645
+ newIndex = index(multiDragElement);
3646
+ }
3647
+
3648
+ newIndicies.push({
3649
+ multiDragElement: multiDragElement,
3650
+ index: newIndex
3651
+ });
3652
+ });
3653
+ return {
3654
+ items: _toConsumableArray(multiDragElements),
3655
+ clones: [].concat(multiDragClones),
3656
+ oldIndicies: oldIndicies,
3657
+ newIndicies: newIndicies
3658
+ };
3659
+ },
3660
+ optionListeners: {
3661
+ multiDragKey: function multiDragKey(key) {
3662
+ key = key.toLowerCase();
3663
+
3664
+ if (key === 'ctrl') {
3665
+ key = 'Control';
3666
+ } else if (key.length > 1) {
3667
+ key = key.charAt(0).toUpperCase() + key.substr(1);
3668
+ }
3669
+
3670
+ return key;
3671
+ }
3672
+ }
3673
+ });
3674
+ }
3675
+
3676
+ function insertMultiDragElements(clonesInserted, rootEl) {
3677
+ multiDragElements.forEach(function (multiDragElement, i) {
3678
+ var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
3679
+
3680
+ if (target) {
3681
+ rootEl.insertBefore(multiDragElement, target);
3682
+ } else {
3683
+ rootEl.appendChild(multiDragElement);
3684
+ }
3685
+ });
3686
+ }
3687
+ /**
3688
+ * Insert multi-drag clones
3689
+ * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
3690
+ * @param {HTMLElement} rootEl
3691
+ */
3692
+
3693
+
3694
+ function insertMultiDragClones(elementsInserted, rootEl) {
3695
+ multiDragClones.forEach(function (clone, i) {
3696
+ var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
3697
+
3698
+ if (target) {
3699
+ rootEl.insertBefore(clone, target);
3700
+ } else {
3701
+ rootEl.appendChild(clone);
3702
+ }
3703
+ });
3704
+ }
3705
+
3706
+ function removeMultiDragElements() {
3707
+ multiDragElements.forEach(function (multiDragElement) {
3708
+ if (multiDragElement === dragEl$1) return;
3709
+ multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
3710
+ });
3711
+ }
3712
+
3713
+ Sortable.mount(new AutoScrollPlugin());
3714
+ Sortable.mount(Remove, Revert);
3715
+
3716
+ Sortable.mount(new SwapPlugin());
3717
+ Sortable.mount(new MultiDragPlugin());
3718
+
3719
+ return Sortable;
3720
+
3721
+ }));