imatrix-ui 2.8.97-dw-tmp2 → 2.8.97-dw-tmp4

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