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