govuk_publishing_components 24.4.1 → 24.7.1

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