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