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