zartui 2.1.19 → 2.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.js +1 -1
- package/es/media-picker/index.js +91 -59
- package/es/speech-recognizer/index.js +8 -1
- package/lib/index.js +1 -1
- package/lib/media-picker/index.js +91 -59
- package/lib/speech-recognizer/index.js +8 -1
- package/lib/zart.js +3484 -65
- package/lib/zart.min.js +9 -2
- package/package.json +4 -2
package/lib/zart.js
CHANGED
|
@@ -1076,7 +1076,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1076
1076
|
|
|
1077
1077
|
// EXPORTS
|
|
1078
1078
|
__webpack_require__.d(__webpack_exports__, "install", function() { return /* binding */ install; });
|
|
1079
|
-
__webpack_require__.d(__webpack_exports__, "version", function() { return /* binding */
|
|
1079
|
+
__webpack_require__.d(__webpack_exports__, "version", function() { return /* binding */ es_version; });
|
|
1080
1080
|
__webpack_require__.d(__webpack_exports__, "ActionSheet", function() { return /* reexport */ action_sheet; });
|
|
1081
1081
|
__webpack_require__.d(__webpack_exports__, "Area", function() { return /* reexport */ es_area; });
|
|
1082
1082
|
__webpack_require__.d(__webpack_exports__, "Avatar", function() { return /* reexport */ avatar; });
|
|
@@ -16475,7 +16475,7 @@ var modeType = {
|
|
|
16475
16475
|
observer: 'observer'
|
|
16476
16476
|
|
|
16477
16477
|
// CustomEvent polyfill for IE
|
|
16478
|
-
};var
|
|
16478
|
+
};var vue_lazyload_esm_CustomEvent = function () {
|
|
16479
16479
|
if (!inBrowser) return;
|
|
16480
16480
|
// not IE
|
|
16481
16481
|
if (typeof window.CustomEvent === 'function') return window.CustomEvent;
|
|
@@ -17588,7 +17588,7 @@ function Lazy(Vue) {
|
|
|
17588
17588
|
this.options.adapter[state] && this.options.adapter[state](listener, this.options);
|
|
17589
17589
|
|
|
17590
17590
|
if (this.options.dispatchEvent) {
|
|
17591
|
-
var event = new
|
|
17591
|
+
var event = new vue_lazyload_esm_CustomEvent(state, {
|
|
17592
17592
|
detail: listener
|
|
17593
17593
|
});
|
|
17594
17594
|
el.dispatchEvent(event);
|
|
@@ -21166,6 +21166,3386 @@ var wx_util_wxUploadImage = function wxUploadImage(type) {
|
|
|
21166
21166
|
});
|
|
21167
21167
|
});
|
|
21168
21168
|
};
|
|
21169
|
+
// CONCATENATED MODULE: ./node_modules/sortablejs/modular/sortable.esm.js
|
|
21170
|
+
/**!
|
|
21171
|
+
* Sortable 1.15.6
|
|
21172
|
+
* @author RubaXa <trash@rubaxa.org>
|
|
21173
|
+
* @author owenm <owen23355@gmail.com>
|
|
21174
|
+
* @license MIT
|
|
21175
|
+
*/
|
|
21176
|
+
function ownKeys(object, enumerableOnly) {
|
|
21177
|
+
var keys = Object.keys(object);
|
|
21178
|
+
if (Object.getOwnPropertySymbols) {
|
|
21179
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
21180
|
+
if (enumerableOnly) {
|
|
21181
|
+
symbols = symbols.filter(function (sym) {
|
|
21182
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
21183
|
+
});
|
|
21184
|
+
}
|
|
21185
|
+
keys.push.apply(keys, symbols);
|
|
21186
|
+
}
|
|
21187
|
+
return keys;
|
|
21188
|
+
}
|
|
21189
|
+
function _objectSpread2(target) {
|
|
21190
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
21191
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
21192
|
+
if (i % 2) {
|
|
21193
|
+
ownKeys(Object(source), true).forEach(function (key) {
|
|
21194
|
+
_defineProperty(target, key, source[key]);
|
|
21195
|
+
});
|
|
21196
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
21197
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
21198
|
+
} else {
|
|
21199
|
+
ownKeys(Object(source)).forEach(function (key) {
|
|
21200
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
21201
|
+
});
|
|
21202
|
+
}
|
|
21203
|
+
}
|
|
21204
|
+
return target;
|
|
21205
|
+
}
|
|
21206
|
+
function sortable_esm_typeof(obj) {
|
|
21207
|
+
"@babel/helpers - typeof";
|
|
21208
|
+
|
|
21209
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
21210
|
+
sortable_esm_typeof = function (obj) {
|
|
21211
|
+
return typeof obj;
|
|
21212
|
+
};
|
|
21213
|
+
} else {
|
|
21214
|
+
sortable_esm_typeof = function (obj) {
|
|
21215
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
21216
|
+
};
|
|
21217
|
+
}
|
|
21218
|
+
return sortable_esm_typeof(obj);
|
|
21219
|
+
}
|
|
21220
|
+
function _defineProperty(obj, key, value) {
|
|
21221
|
+
if (key in obj) {
|
|
21222
|
+
Object.defineProperty(obj, key, {
|
|
21223
|
+
value: value,
|
|
21224
|
+
enumerable: true,
|
|
21225
|
+
configurable: true,
|
|
21226
|
+
writable: true
|
|
21227
|
+
});
|
|
21228
|
+
} else {
|
|
21229
|
+
obj[key] = value;
|
|
21230
|
+
}
|
|
21231
|
+
return obj;
|
|
21232
|
+
}
|
|
21233
|
+
function sortable_esm_extends() {
|
|
21234
|
+
sortable_esm_extends = Object.assign || function (target) {
|
|
21235
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
21236
|
+
var source = arguments[i];
|
|
21237
|
+
for (var key in source) {
|
|
21238
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
21239
|
+
target[key] = source[key];
|
|
21240
|
+
}
|
|
21241
|
+
}
|
|
21242
|
+
}
|
|
21243
|
+
return target;
|
|
21244
|
+
};
|
|
21245
|
+
return sortable_esm_extends.apply(this, arguments);
|
|
21246
|
+
}
|
|
21247
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
21248
|
+
if (source == null) return {};
|
|
21249
|
+
var target = {};
|
|
21250
|
+
var sourceKeys = Object.keys(source);
|
|
21251
|
+
var key, i;
|
|
21252
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
21253
|
+
key = sourceKeys[i];
|
|
21254
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
21255
|
+
target[key] = source[key];
|
|
21256
|
+
}
|
|
21257
|
+
return target;
|
|
21258
|
+
}
|
|
21259
|
+
function _objectWithoutProperties(source, excluded) {
|
|
21260
|
+
if (source == null) return {};
|
|
21261
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
21262
|
+
var key, i;
|
|
21263
|
+
if (Object.getOwnPropertySymbols) {
|
|
21264
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
21265
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
21266
|
+
key = sourceSymbolKeys[i];
|
|
21267
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
21268
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
21269
|
+
target[key] = source[key];
|
|
21270
|
+
}
|
|
21271
|
+
}
|
|
21272
|
+
return target;
|
|
21273
|
+
}
|
|
21274
|
+
function _toConsumableArray(arr) {
|
|
21275
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
21276
|
+
}
|
|
21277
|
+
function _arrayWithoutHoles(arr) {
|
|
21278
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
21279
|
+
}
|
|
21280
|
+
function _iterableToArray(iter) {
|
|
21281
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
21282
|
+
}
|
|
21283
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
21284
|
+
if (!o) return;
|
|
21285
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
21286
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
21287
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
21288
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
21289
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
21290
|
+
}
|
|
21291
|
+
function _arrayLikeToArray(arr, len) {
|
|
21292
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
21293
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
21294
|
+
return arr2;
|
|
21295
|
+
}
|
|
21296
|
+
function _nonIterableSpread() {
|
|
21297
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
21298
|
+
}
|
|
21299
|
+
|
|
21300
|
+
var version = "1.15.6";
|
|
21301
|
+
|
|
21302
|
+
function userAgent(pattern) {
|
|
21303
|
+
if (typeof window !== 'undefined' && window.navigator) {
|
|
21304
|
+
return !! /*@__PURE__*/navigator.userAgent.match(pattern);
|
|
21305
|
+
}
|
|
21306
|
+
}
|
|
21307
|
+
var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
|
|
21308
|
+
var Edge = userAgent(/Edge/i);
|
|
21309
|
+
var FireFox = userAgent(/firefox/i);
|
|
21310
|
+
var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
|
|
21311
|
+
var IOS = userAgent(/iP(ad|od|hone)/i);
|
|
21312
|
+
var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
|
|
21313
|
+
|
|
21314
|
+
var captureMode = {
|
|
21315
|
+
capture: false,
|
|
21316
|
+
passive: false
|
|
21317
|
+
};
|
|
21318
|
+
function sortable_esm_on(el, event, fn) {
|
|
21319
|
+
el.addEventListener(event, fn, !IE11OrLess && captureMode);
|
|
21320
|
+
}
|
|
21321
|
+
function sortable_esm_off(el, event, fn) {
|
|
21322
|
+
el.removeEventListener(event, fn, !IE11OrLess && captureMode);
|
|
21323
|
+
}
|
|
21324
|
+
function matches( /**HTMLElement*/el, /**String*/selector) {
|
|
21325
|
+
if (!selector) return;
|
|
21326
|
+
selector[0] === '>' && (selector = selector.substring(1));
|
|
21327
|
+
if (el) {
|
|
21328
|
+
try {
|
|
21329
|
+
if (el.matches) {
|
|
21330
|
+
return el.matches(selector);
|
|
21331
|
+
} else if (el.msMatchesSelector) {
|
|
21332
|
+
return el.msMatchesSelector(selector);
|
|
21333
|
+
} else if (el.webkitMatchesSelector) {
|
|
21334
|
+
return el.webkitMatchesSelector(selector);
|
|
21335
|
+
}
|
|
21336
|
+
} catch (_) {
|
|
21337
|
+
return false;
|
|
21338
|
+
}
|
|
21339
|
+
}
|
|
21340
|
+
return false;
|
|
21341
|
+
}
|
|
21342
|
+
function getParentOrHost(el) {
|
|
21343
|
+
return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
|
|
21344
|
+
}
|
|
21345
|
+
function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
|
|
21346
|
+
if (el) {
|
|
21347
|
+
ctx = ctx || document;
|
|
21348
|
+
do {
|
|
21349
|
+
if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
|
|
21350
|
+
return el;
|
|
21351
|
+
}
|
|
21352
|
+
if (el === ctx) break;
|
|
21353
|
+
/* jshint boss:true */
|
|
21354
|
+
} while (el = getParentOrHost(el));
|
|
21355
|
+
}
|
|
21356
|
+
return null;
|
|
21357
|
+
}
|
|
21358
|
+
var R_SPACE = /\s+/g;
|
|
21359
|
+
function toggleClass(el, name, state) {
|
|
21360
|
+
if (el && name) {
|
|
21361
|
+
if (el.classList) {
|
|
21362
|
+
el.classList[state ? 'add' : 'remove'](name);
|
|
21363
|
+
} else {
|
|
21364
|
+
var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
|
|
21365
|
+
el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
|
|
21366
|
+
}
|
|
21367
|
+
}
|
|
21368
|
+
}
|
|
21369
|
+
function sortable_esm_css(el, prop, val) {
|
|
21370
|
+
var style = el && el.style;
|
|
21371
|
+
if (style) {
|
|
21372
|
+
if (val === void 0) {
|
|
21373
|
+
if (document.defaultView && document.defaultView.getComputedStyle) {
|
|
21374
|
+
val = document.defaultView.getComputedStyle(el, '');
|
|
21375
|
+
} else if (el.currentStyle) {
|
|
21376
|
+
val = el.currentStyle;
|
|
21377
|
+
}
|
|
21378
|
+
return prop === void 0 ? val : val[prop];
|
|
21379
|
+
} else {
|
|
21380
|
+
if (!(prop in style) && prop.indexOf('webkit') === -1) {
|
|
21381
|
+
prop = '-webkit-' + prop;
|
|
21382
|
+
}
|
|
21383
|
+
style[prop] = val + (typeof val === 'string' ? '' : 'px');
|
|
21384
|
+
}
|
|
21385
|
+
}
|
|
21386
|
+
}
|
|
21387
|
+
function matrix(el, selfOnly) {
|
|
21388
|
+
var appliedTransforms = '';
|
|
21389
|
+
if (typeof el === 'string') {
|
|
21390
|
+
appliedTransforms = el;
|
|
21391
|
+
} else {
|
|
21392
|
+
do {
|
|
21393
|
+
var transform = sortable_esm_css(el, 'transform');
|
|
21394
|
+
if (transform && transform !== 'none') {
|
|
21395
|
+
appliedTransforms = transform + ' ' + appliedTransforms;
|
|
21396
|
+
}
|
|
21397
|
+
/* jshint boss:true */
|
|
21398
|
+
} while (!selfOnly && (el = el.parentNode));
|
|
21399
|
+
}
|
|
21400
|
+
var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
|
|
21401
|
+
/*jshint -W056 */
|
|
21402
|
+
return matrixFn && new matrixFn(appliedTransforms);
|
|
21403
|
+
}
|
|
21404
|
+
function sortable_esm_find(ctx, tagName, iterator) {
|
|
21405
|
+
if (ctx) {
|
|
21406
|
+
var list = ctx.getElementsByTagName(tagName),
|
|
21407
|
+
i = 0,
|
|
21408
|
+
n = list.length;
|
|
21409
|
+
if (iterator) {
|
|
21410
|
+
for (; i < n; i++) {
|
|
21411
|
+
iterator(list[i], i);
|
|
21412
|
+
}
|
|
21413
|
+
}
|
|
21414
|
+
return list;
|
|
21415
|
+
}
|
|
21416
|
+
return [];
|
|
21417
|
+
}
|
|
21418
|
+
function getWindowScrollingElement() {
|
|
21419
|
+
var scrollingElement = document.scrollingElement;
|
|
21420
|
+
if (scrollingElement) {
|
|
21421
|
+
return scrollingElement;
|
|
21422
|
+
} else {
|
|
21423
|
+
return document.documentElement;
|
|
21424
|
+
}
|
|
21425
|
+
}
|
|
21426
|
+
|
|
21427
|
+
/**
|
|
21428
|
+
* Returns the "bounding client rect" of given element
|
|
21429
|
+
* @param {HTMLElement} el The element whose boundingClientRect is wanted
|
|
21430
|
+
* @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
|
|
21431
|
+
* @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
|
|
21432
|
+
* @param {[Boolean]} undoScale Whether the container's scale() should be undone
|
|
21433
|
+
* @param {[HTMLElement]} container The parent the element will be placed in
|
|
21434
|
+
* @return {Object} The boundingClientRect of el, with specified adjustments
|
|
21435
|
+
*/
|
|
21436
|
+
function sortable_esm_getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
|
|
21437
|
+
if (!el.getBoundingClientRect && el !== window) return;
|
|
21438
|
+
var elRect, top, left, bottom, right, height, width;
|
|
21439
|
+
if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
|
|
21440
|
+
elRect = el.getBoundingClientRect();
|
|
21441
|
+
top = elRect.top;
|
|
21442
|
+
left = elRect.left;
|
|
21443
|
+
bottom = elRect.bottom;
|
|
21444
|
+
right = elRect.right;
|
|
21445
|
+
height = elRect.height;
|
|
21446
|
+
width = elRect.width;
|
|
21447
|
+
} else {
|
|
21448
|
+
top = 0;
|
|
21449
|
+
left = 0;
|
|
21450
|
+
bottom = window.innerHeight;
|
|
21451
|
+
right = window.innerWidth;
|
|
21452
|
+
height = window.innerHeight;
|
|
21453
|
+
width = window.innerWidth;
|
|
21454
|
+
}
|
|
21455
|
+
if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
|
|
21456
|
+
// Adjust for translate()
|
|
21457
|
+
container = container || el.parentNode;
|
|
21458
|
+
|
|
21459
|
+
// solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
|
|
21460
|
+
// Not needed on <= IE11
|
|
21461
|
+
if (!IE11OrLess) {
|
|
21462
|
+
do {
|
|
21463
|
+
if (container && container.getBoundingClientRect && (sortable_esm_css(container, 'transform') !== 'none' || relativeToNonStaticParent && sortable_esm_css(container, 'position') !== 'static')) {
|
|
21464
|
+
var containerRect = container.getBoundingClientRect();
|
|
21465
|
+
|
|
21466
|
+
// Set relative to edges of padding box of container
|
|
21467
|
+
top -= containerRect.top + parseInt(sortable_esm_css(container, 'border-top-width'));
|
|
21468
|
+
left -= containerRect.left + parseInt(sortable_esm_css(container, 'border-left-width'));
|
|
21469
|
+
bottom = top + elRect.height;
|
|
21470
|
+
right = left + elRect.width;
|
|
21471
|
+
break;
|
|
21472
|
+
}
|
|
21473
|
+
/* jshint boss:true */
|
|
21474
|
+
} while (container = container.parentNode);
|
|
21475
|
+
}
|
|
21476
|
+
}
|
|
21477
|
+
if (undoScale && el !== window) {
|
|
21478
|
+
// Adjust for scale()
|
|
21479
|
+
var elMatrix = matrix(container || el),
|
|
21480
|
+
scaleX = elMatrix && elMatrix.a,
|
|
21481
|
+
scaleY = elMatrix && elMatrix.d;
|
|
21482
|
+
if (elMatrix) {
|
|
21483
|
+
top /= scaleY;
|
|
21484
|
+
left /= scaleX;
|
|
21485
|
+
width /= scaleX;
|
|
21486
|
+
height /= scaleY;
|
|
21487
|
+
bottom = top + height;
|
|
21488
|
+
right = left + width;
|
|
21489
|
+
}
|
|
21490
|
+
}
|
|
21491
|
+
return {
|
|
21492
|
+
top: top,
|
|
21493
|
+
left: left,
|
|
21494
|
+
bottom: bottom,
|
|
21495
|
+
right: right,
|
|
21496
|
+
width: width,
|
|
21497
|
+
height: height
|
|
21498
|
+
};
|
|
21499
|
+
}
|
|
21500
|
+
|
|
21501
|
+
/**
|
|
21502
|
+
* Checks if a side of an element is scrolled past a side of its parents
|
|
21503
|
+
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
|
|
21504
|
+
* @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
|
|
21505
|
+
* @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
|
|
21506
|
+
* @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
|
|
21507
|
+
*/
|
|
21508
|
+
function isScrolledPast(el, elSide, parentSide) {
|
|
21509
|
+
var parent = getParentAutoScrollElement(el, true),
|
|
21510
|
+
elSideVal = sortable_esm_getRect(el)[elSide];
|
|
21511
|
+
|
|
21512
|
+
/* jshint boss:true */
|
|
21513
|
+
while (parent) {
|
|
21514
|
+
var parentSideVal = sortable_esm_getRect(parent)[parentSide],
|
|
21515
|
+
visible = void 0;
|
|
21516
|
+
if (parentSide === 'top' || parentSide === 'left') {
|
|
21517
|
+
visible = elSideVal >= parentSideVal;
|
|
21518
|
+
} else {
|
|
21519
|
+
visible = elSideVal <= parentSideVal;
|
|
21520
|
+
}
|
|
21521
|
+
if (!visible) return parent;
|
|
21522
|
+
if (parent === getWindowScrollingElement()) break;
|
|
21523
|
+
parent = getParentAutoScrollElement(parent, false);
|
|
21524
|
+
}
|
|
21525
|
+
return false;
|
|
21526
|
+
}
|
|
21527
|
+
|
|
21528
|
+
/**
|
|
21529
|
+
* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
|
|
21530
|
+
* and non-draggable elements
|
|
21531
|
+
* @param {HTMLElement} el The parent element
|
|
21532
|
+
* @param {Number} childNum The index of the child
|
|
21533
|
+
* @param {Object} options Parent Sortable's options
|
|
21534
|
+
* @return {HTMLElement} The child at index childNum, or null if not found
|
|
21535
|
+
*/
|
|
21536
|
+
function getChild(el, childNum, options, includeDragEl) {
|
|
21537
|
+
var currentChild = 0,
|
|
21538
|
+
i = 0,
|
|
21539
|
+
children = el.children;
|
|
21540
|
+
while (i < children.length) {
|
|
21541
|
+
if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
|
|
21542
|
+
if (currentChild === childNum) {
|
|
21543
|
+
return children[i];
|
|
21544
|
+
}
|
|
21545
|
+
currentChild++;
|
|
21546
|
+
}
|
|
21547
|
+
i++;
|
|
21548
|
+
}
|
|
21549
|
+
return null;
|
|
21550
|
+
}
|
|
21551
|
+
|
|
21552
|
+
/**
|
|
21553
|
+
* Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
|
|
21554
|
+
* @param {HTMLElement} el Parent element
|
|
21555
|
+
* @param {selector} selector Any other elements that should be ignored
|
|
21556
|
+
* @return {HTMLElement} The last child, ignoring ghostEl
|
|
21557
|
+
*/
|
|
21558
|
+
function lastChild(el, selector) {
|
|
21559
|
+
var last = el.lastElementChild;
|
|
21560
|
+
while (last && (last === Sortable.ghost || sortable_esm_css(last, 'display') === 'none' || selector && !matches(last, selector))) {
|
|
21561
|
+
last = last.previousElementSibling;
|
|
21562
|
+
}
|
|
21563
|
+
return last || null;
|
|
21564
|
+
}
|
|
21565
|
+
|
|
21566
|
+
/**
|
|
21567
|
+
* Returns the index of an element within its parent for a selected set of
|
|
21568
|
+
* elements
|
|
21569
|
+
* @param {HTMLElement} el
|
|
21570
|
+
* @param {selector} selector
|
|
21571
|
+
* @return {number}
|
|
21572
|
+
*/
|
|
21573
|
+
function sortable_esm_index(el, selector) {
|
|
21574
|
+
var index = 0;
|
|
21575
|
+
if (!el || !el.parentNode) {
|
|
21576
|
+
return -1;
|
|
21577
|
+
}
|
|
21578
|
+
|
|
21579
|
+
/* jshint boss:true */
|
|
21580
|
+
while (el = el.previousElementSibling) {
|
|
21581
|
+
if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
|
|
21582
|
+
index++;
|
|
21583
|
+
}
|
|
21584
|
+
}
|
|
21585
|
+
return index;
|
|
21586
|
+
}
|
|
21587
|
+
|
|
21588
|
+
/**
|
|
21589
|
+
* Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
|
|
21590
|
+
* The value is returned in real pixels.
|
|
21591
|
+
* @param {HTMLElement} el
|
|
21592
|
+
* @return {Array} Offsets in the format of [left, top]
|
|
21593
|
+
*/
|
|
21594
|
+
function getRelativeScrollOffset(el) {
|
|
21595
|
+
var offsetLeft = 0,
|
|
21596
|
+
offsetTop = 0,
|
|
21597
|
+
winScroller = getWindowScrollingElement();
|
|
21598
|
+
if (el) {
|
|
21599
|
+
do {
|
|
21600
|
+
var elMatrix = matrix(el),
|
|
21601
|
+
scaleX = elMatrix.a,
|
|
21602
|
+
scaleY = elMatrix.d;
|
|
21603
|
+
offsetLeft += el.scrollLeft * scaleX;
|
|
21604
|
+
offsetTop += el.scrollTop * scaleY;
|
|
21605
|
+
} while (el !== winScroller && (el = el.parentNode));
|
|
21606
|
+
}
|
|
21607
|
+
return [offsetLeft, offsetTop];
|
|
21608
|
+
}
|
|
21609
|
+
|
|
21610
|
+
/**
|
|
21611
|
+
* Returns the index of the object within the given array
|
|
21612
|
+
* @param {Array} arr Array that may or may not hold the object
|
|
21613
|
+
* @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
|
|
21614
|
+
* @return {Number} The index of the object in the array, or -1
|
|
21615
|
+
*/
|
|
21616
|
+
function indexOfObject(arr, obj) {
|
|
21617
|
+
for (var i in arr) {
|
|
21618
|
+
if (!arr.hasOwnProperty(i)) continue;
|
|
21619
|
+
for (var key in obj) {
|
|
21620
|
+
if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
|
|
21621
|
+
}
|
|
21622
|
+
}
|
|
21623
|
+
return -1;
|
|
21624
|
+
}
|
|
21625
|
+
function getParentAutoScrollElement(el, includeSelf) {
|
|
21626
|
+
// skip to window
|
|
21627
|
+
if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
|
|
21628
|
+
var elem = el;
|
|
21629
|
+
var gotSelf = false;
|
|
21630
|
+
do {
|
|
21631
|
+
// we don't need to get elem css if it isn't even overflowing in the first place (performance)
|
|
21632
|
+
if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
|
|
21633
|
+
var elemCSS = sortable_esm_css(elem);
|
|
21634
|
+
if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
|
|
21635
|
+
if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
|
|
21636
|
+
if (gotSelf || includeSelf) return elem;
|
|
21637
|
+
gotSelf = true;
|
|
21638
|
+
}
|
|
21639
|
+
}
|
|
21640
|
+
/* jshint boss:true */
|
|
21641
|
+
} while (elem = elem.parentNode);
|
|
21642
|
+
return getWindowScrollingElement();
|
|
21643
|
+
}
|
|
21644
|
+
function extend(dst, src) {
|
|
21645
|
+
if (dst && src) {
|
|
21646
|
+
for (var key in src) {
|
|
21647
|
+
if (src.hasOwnProperty(key)) {
|
|
21648
|
+
dst[key] = src[key];
|
|
21649
|
+
}
|
|
21650
|
+
}
|
|
21651
|
+
}
|
|
21652
|
+
return dst;
|
|
21653
|
+
}
|
|
21654
|
+
function isRectEqual(rect1, rect2) {
|
|
21655
|
+
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);
|
|
21656
|
+
}
|
|
21657
|
+
var _throttleTimeout;
|
|
21658
|
+
function sortable_esm_throttle(callback, ms) {
|
|
21659
|
+
return function () {
|
|
21660
|
+
if (!_throttleTimeout) {
|
|
21661
|
+
var args = arguments,
|
|
21662
|
+
_this = this;
|
|
21663
|
+
if (args.length === 1) {
|
|
21664
|
+
callback.call(_this, args[0]);
|
|
21665
|
+
} else {
|
|
21666
|
+
callback.apply(_this, args);
|
|
21667
|
+
}
|
|
21668
|
+
_throttleTimeout = setTimeout(function () {
|
|
21669
|
+
_throttleTimeout = void 0;
|
|
21670
|
+
}, ms);
|
|
21671
|
+
}
|
|
21672
|
+
};
|
|
21673
|
+
}
|
|
21674
|
+
function cancelThrottle() {
|
|
21675
|
+
clearTimeout(_throttleTimeout);
|
|
21676
|
+
_throttleTimeout = void 0;
|
|
21677
|
+
}
|
|
21678
|
+
function scrollBy(el, x, y) {
|
|
21679
|
+
el.scrollLeft += x;
|
|
21680
|
+
el.scrollTop += y;
|
|
21681
|
+
}
|
|
21682
|
+
function clone(el) {
|
|
21683
|
+
var Polymer = window.Polymer;
|
|
21684
|
+
var $ = window.jQuery || window.Zepto;
|
|
21685
|
+
if (Polymer && Polymer.dom) {
|
|
21686
|
+
return Polymer.dom(el).cloneNode(true);
|
|
21687
|
+
} else if ($) {
|
|
21688
|
+
return $(el).clone(true)[0];
|
|
21689
|
+
} else {
|
|
21690
|
+
return el.cloneNode(true);
|
|
21691
|
+
}
|
|
21692
|
+
}
|
|
21693
|
+
function setRect(el, rect) {
|
|
21694
|
+
sortable_esm_css(el, 'position', 'absolute');
|
|
21695
|
+
sortable_esm_css(el, 'top', rect.top);
|
|
21696
|
+
sortable_esm_css(el, 'left', rect.left);
|
|
21697
|
+
sortable_esm_css(el, 'width', rect.width);
|
|
21698
|
+
sortable_esm_css(el, 'height', rect.height);
|
|
21699
|
+
}
|
|
21700
|
+
function unsetRect(el) {
|
|
21701
|
+
sortable_esm_css(el, 'position', '');
|
|
21702
|
+
sortable_esm_css(el, 'top', '');
|
|
21703
|
+
sortable_esm_css(el, 'left', '');
|
|
21704
|
+
sortable_esm_css(el, 'width', '');
|
|
21705
|
+
sortable_esm_css(el, 'height', '');
|
|
21706
|
+
}
|
|
21707
|
+
function getChildContainingRectFromElement(container, options, ghostEl) {
|
|
21708
|
+
var rect = {};
|
|
21709
|
+
Array.from(container.children).forEach(function (child) {
|
|
21710
|
+
var _rect$left, _rect$top, _rect$right, _rect$bottom;
|
|
21711
|
+
if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
|
|
21712
|
+
var childRect = sortable_esm_getRect(child);
|
|
21713
|
+
rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
|
|
21714
|
+
rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
|
|
21715
|
+
rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
|
|
21716
|
+
rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
|
|
21717
|
+
});
|
|
21718
|
+
rect.width = rect.right - rect.left;
|
|
21719
|
+
rect.height = rect.bottom - rect.top;
|
|
21720
|
+
rect.x = rect.left;
|
|
21721
|
+
rect.y = rect.top;
|
|
21722
|
+
return rect;
|
|
21723
|
+
}
|
|
21724
|
+
var expando = 'Sortable' + new Date().getTime();
|
|
21725
|
+
|
|
21726
|
+
function AnimationStateManager() {
|
|
21727
|
+
var animationStates = [],
|
|
21728
|
+
animationCallbackId;
|
|
21729
|
+
return {
|
|
21730
|
+
captureAnimationState: function captureAnimationState() {
|
|
21731
|
+
animationStates = [];
|
|
21732
|
+
if (!this.options.animation) return;
|
|
21733
|
+
var children = [].slice.call(this.el.children);
|
|
21734
|
+
children.forEach(function (child) {
|
|
21735
|
+
if (sortable_esm_css(child, 'display') === 'none' || child === Sortable.ghost) return;
|
|
21736
|
+
animationStates.push({
|
|
21737
|
+
target: child,
|
|
21738
|
+
rect: sortable_esm_getRect(child)
|
|
21739
|
+
});
|
|
21740
|
+
var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
|
|
21741
|
+
|
|
21742
|
+
// If animating: compensate for current animation
|
|
21743
|
+
if (child.thisAnimationDuration) {
|
|
21744
|
+
var childMatrix = matrix(child, true);
|
|
21745
|
+
if (childMatrix) {
|
|
21746
|
+
fromRect.top -= childMatrix.f;
|
|
21747
|
+
fromRect.left -= childMatrix.e;
|
|
21748
|
+
}
|
|
21749
|
+
}
|
|
21750
|
+
child.fromRect = fromRect;
|
|
21751
|
+
});
|
|
21752
|
+
},
|
|
21753
|
+
addAnimationState: function addAnimationState(state) {
|
|
21754
|
+
animationStates.push(state);
|
|
21755
|
+
},
|
|
21756
|
+
removeAnimationState: function removeAnimationState(target) {
|
|
21757
|
+
animationStates.splice(indexOfObject(animationStates, {
|
|
21758
|
+
target: target
|
|
21759
|
+
}), 1);
|
|
21760
|
+
},
|
|
21761
|
+
animateAll: function animateAll(callback) {
|
|
21762
|
+
var _this = this;
|
|
21763
|
+
if (!this.options.animation) {
|
|
21764
|
+
clearTimeout(animationCallbackId);
|
|
21765
|
+
if (typeof callback === 'function') callback();
|
|
21766
|
+
return;
|
|
21767
|
+
}
|
|
21768
|
+
var animating = false,
|
|
21769
|
+
animationTime = 0;
|
|
21770
|
+
animationStates.forEach(function (state) {
|
|
21771
|
+
var time = 0,
|
|
21772
|
+
target = state.target,
|
|
21773
|
+
fromRect = target.fromRect,
|
|
21774
|
+
toRect = sortable_esm_getRect(target),
|
|
21775
|
+
prevFromRect = target.prevFromRect,
|
|
21776
|
+
prevToRect = target.prevToRect,
|
|
21777
|
+
animatingRect = state.rect,
|
|
21778
|
+
targetMatrix = matrix(target, true);
|
|
21779
|
+
if (targetMatrix) {
|
|
21780
|
+
// Compensate for current animation
|
|
21781
|
+
toRect.top -= targetMatrix.f;
|
|
21782
|
+
toRect.left -= targetMatrix.e;
|
|
21783
|
+
}
|
|
21784
|
+
target.toRect = toRect;
|
|
21785
|
+
if (target.thisAnimationDuration) {
|
|
21786
|
+
// Could also check if animatingRect is between fromRect and toRect
|
|
21787
|
+
if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
|
|
21788
|
+
// Make sure animatingRect is on line between toRect & fromRect
|
|
21789
|
+
(animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
|
|
21790
|
+
// If returning to same place as started from animation and on same axis
|
|
21791
|
+
time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
|
|
21792
|
+
}
|
|
21793
|
+
}
|
|
21794
|
+
|
|
21795
|
+
// if fromRect != toRect: animate
|
|
21796
|
+
if (!isRectEqual(toRect, fromRect)) {
|
|
21797
|
+
target.prevFromRect = fromRect;
|
|
21798
|
+
target.prevToRect = toRect;
|
|
21799
|
+
if (!time) {
|
|
21800
|
+
time = _this.options.animation;
|
|
21801
|
+
}
|
|
21802
|
+
_this.animate(target, animatingRect, toRect, time);
|
|
21803
|
+
}
|
|
21804
|
+
if (time) {
|
|
21805
|
+
animating = true;
|
|
21806
|
+
animationTime = Math.max(animationTime, time);
|
|
21807
|
+
clearTimeout(target.animationResetTimer);
|
|
21808
|
+
target.animationResetTimer = setTimeout(function () {
|
|
21809
|
+
target.animationTime = 0;
|
|
21810
|
+
target.prevFromRect = null;
|
|
21811
|
+
target.fromRect = null;
|
|
21812
|
+
target.prevToRect = null;
|
|
21813
|
+
target.thisAnimationDuration = null;
|
|
21814
|
+
}, time);
|
|
21815
|
+
target.thisAnimationDuration = time;
|
|
21816
|
+
}
|
|
21817
|
+
});
|
|
21818
|
+
clearTimeout(animationCallbackId);
|
|
21819
|
+
if (!animating) {
|
|
21820
|
+
if (typeof callback === 'function') callback();
|
|
21821
|
+
} else {
|
|
21822
|
+
animationCallbackId = setTimeout(function () {
|
|
21823
|
+
if (typeof callback === 'function') callback();
|
|
21824
|
+
}, animationTime);
|
|
21825
|
+
}
|
|
21826
|
+
animationStates = [];
|
|
21827
|
+
},
|
|
21828
|
+
animate: function animate(target, currentRect, toRect, duration) {
|
|
21829
|
+
if (duration) {
|
|
21830
|
+
sortable_esm_css(target, 'transition', '');
|
|
21831
|
+
sortable_esm_css(target, 'transform', '');
|
|
21832
|
+
var elMatrix = matrix(this.el),
|
|
21833
|
+
scaleX = elMatrix && elMatrix.a,
|
|
21834
|
+
scaleY = elMatrix && elMatrix.d,
|
|
21835
|
+
translateX = (currentRect.left - toRect.left) / (scaleX || 1),
|
|
21836
|
+
translateY = (currentRect.top - toRect.top) / (scaleY || 1);
|
|
21837
|
+
target.animatingX = !!translateX;
|
|
21838
|
+
target.animatingY = !!translateY;
|
|
21839
|
+
sortable_esm_css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
|
|
21840
|
+
this.forRepaintDummy = repaint(target); // repaint
|
|
21841
|
+
|
|
21842
|
+
sortable_esm_css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
|
|
21843
|
+
sortable_esm_css(target, 'transform', 'translate3d(0,0,0)');
|
|
21844
|
+
typeof target.animated === 'number' && clearTimeout(target.animated);
|
|
21845
|
+
target.animated = setTimeout(function () {
|
|
21846
|
+
sortable_esm_css(target, 'transition', '');
|
|
21847
|
+
sortable_esm_css(target, 'transform', '');
|
|
21848
|
+
target.animated = false;
|
|
21849
|
+
target.animatingX = false;
|
|
21850
|
+
target.animatingY = false;
|
|
21851
|
+
}, duration);
|
|
21852
|
+
}
|
|
21853
|
+
}
|
|
21854
|
+
};
|
|
21855
|
+
}
|
|
21856
|
+
function repaint(target) {
|
|
21857
|
+
return target.offsetWidth;
|
|
21858
|
+
}
|
|
21859
|
+
function calculateRealTime(animatingRect, fromRect, toRect, options) {
|
|
21860
|
+
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;
|
|
21861
|
+
}
|
|
21862
|
+
|
|
21863
|
+
var plugins = [];
|
|
21864
|
+
var defaults = {
|
|
21865
|
+
initializeByDefault: true
|
|
21866
|
+
};
|
|
21867
|
+
var PluginManager = {
|
|
21868
|
+
mount: function mount(plugin) {
|
|
21869
|
+
// Set default static properties
|
|
21870
|
+
for (var option in defaults) {
|
|
21871
|
+
if (defaults.hasOwnProperty(option) && !(option in plugin)) {
|
|
21872
|
+
plugin[option] = defaults[option];
|
|
21873
|
+
}
|
|
21874
|
+
}
|
|
21875
|
+
plugins.forEach(function (p) {
|
|
21876
|
+
if (p.pluginName === plugin.pluginName) {
|
|
21877
|
+
throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
|
|
21878
|
+
}
|
|
21879
|
+
});
|
|
21880
|
+
plugins.push(plugin);
|
|
21881
|
+
},
|
|
21882
|
+
pluginEvent: function pluginEvent(eventName, sortable, evt) {
|
|
21883
|
+
var _this = this;
|
|
21884
|
+
this.eventCanceled = false;
|
|
21885
|
+
evt.cancel = function () {
|
|
21886
|
+
_this.eventCanceled = true;
|
|
21887
|
+
};
|
|
21888
|
+
var eventNameGlobal = eventName + 'Global';
|
|
21889
|
+
plugins.forEach(function (plugin) {
|
|
21890
|
+
if (!sortable[plugin.pluginName]) return;
|
|
21891
|
+
// Fire global events if it exists in this sortable
|
|
21892
|
+
if (sortable[plugin.pluginName][eventNameGlobal]) {
|
|
21893
|
+
sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
|
|
21894
|
+
sortable: sortable
|
|
21895
|
+
}, evt));
|
|
21896
|
+
}
|
|
21897
|
+
|
|
21898
|
+
// Only fire plugin event if plugin is enabled in this sortable,
|
|
21899
|
+
// and plugin has event defined
|
|
21900
|
+
if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
|
|
21901
|
+
sortable[plugin.pluginName][eventName](_objectSpread2({
|
|
21902
|
+
sortable: sortable
|
|
21903
|
+
}, evt));
|
|
21904
|
+
}
|
|
21905
|
+
});
|
|
21906
|
+
},
|
|
21907
|
+
initializePlugins: function initializePlugins(sortable, el, defaults, options) {
|
|
21908
|
+
plugins.forEach(function (plugin) {
|
|
21909
|
+
var pluginName = plugin.pluginName;
|
|
21910
|
+
if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
|
|
21911
|
+
var initialized = new plugin(sortable, el, sortable.options);
|
|
21912
|
+
initialized.sortable = sortable;
|
|
21913
|
+
initialized.options = sortable.options;
|
|
21914
|
+
sortable[pluginName] = initialized;
|
|
21915
|
+
|
|
21916
|
+
// Add default options from plugin
|
|
21917
|
+
sortable_esm_extends(defaults, initialized.defaults);
|
|
21918
|
+
});
|
|
21919
|
+
for (var option in sortable.options) {
|
|
21920
|
+
if (!sortable.options.hasOwnProperty(option)) continue;
|
|
21921
|
+
var modified = this.modifyOption(sortable, option, sortable.options[option]);
|
|
21922
|
+
if (typeof modified !== 'undefined') {
|
|
21923
|
+
sortable.options[option] = modified;
|
|
21924
|
+
}
|
|
21925
|
+
}
|
|
21926
|
+
},
|
|
21927
|
+
getEventProperties: function getEventProperties(name, sortable) {
|
|
21928
|
+
var eventProperties = {};
|
|
21929
|
+
plugins.forEach(function (plugin) {
|
|
21930
|
+
if (typeof plugin.eventProperties !== 'function') return;
|
|
21931
|
+
sortable_esm_extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
|
|
21932
|
+
});
|
|
21933
|
+
return eventProperties;
|
|
21934
|
+
},
|
|
21935
|
+
modifyOption: function modifyOption(sortable, name, value) {
|
|
21936
|
+
var modifiedValue;
|
|
21937
|
+
plugins.forEach(function (plugin) {
|
|
21938
|
+
// Plugin must exist on the Sortable
|
|
21939
|
+
if (!sortable[plugin.pluginName]) return;
|
|
21940
|
+
|
|
21941
|
+
// If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
|
|
21942
|
+
if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
|
|
21943
|
+
modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
|
|
21944
|
+
}
|
|
21945
|
+
});
|
|
21946
|
+
return modifiedValue;
|
|
21947
|
+
}
|
|
21948
|
+
};
|
|
21949
|
+
|
|
21950
|
+
function dispatchEvent(_ref) {
|
|
21951
|
+
var sortable = _ref.sortable,
|
|
21952
|
+
rootEl = _ref.rootEl,
|
|
21953
|
+
name = _ref.name,
|
|
21954
|
+
targetEl = _ref.targetEl,
|
|
21955
|
+
cloneEl = _ref.cloneEl,
|
|
21956
|
+
toEl = _ref.toEl,
|
|
21957
|
+
fromEl = _ref.fromEl,
|
|
21958
|
+
oldIndex = _ref.oldIndex,
|
|
21959
|
+
newIndex = _ref.newIndex,
|
|
21960
|
+
oldDraggableIndex = _ref.oldDraggableIndex,
|
|
21961
|
+
newDraggableIndex = _ref.newDraggableIndex,
|
|
21962
|
+
originalEvent = _ref.originalEvent,
|
|
21963
|
+
putSortable = _ref.putSortable,
|
|
21964
|
+
extraEventProperties = _ref.extraEventProperties;
|
|
21965
|
+
sortable = sortable || rootEl && rootEl[expando];
|
|
21966
|
+
if (!sortable) return;
|
|
21967
|
+
var evt,
|
|
21968
|
+
options = sortable.options,
|
|
21969
|
+
onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
|
|
21970
|
+
// Support for new CustomEvent feature
|
|
21971
|
+
if (window.CustomEvent && !IE11OrLess && !Edge) {
|
|
21972
|
+
evt = new CustomEvent(name, {
|
|
21973
|
+
bubbles: true,
|
|
21974
|
+
cancelable: true
|
|
21975
|
+
});
|
|
21976
|
+
} else {
|
|
21977
|
+
evt = document.createEvent('Event');
|
|
21978
|
+
evt.initEvent(name, true, true);
|
|
21979
|
+
}
|
|
21980
|
+
evt.to = toEl || rootEl;
|
|
21981
|
+
evt.from = fromEl || rootEl;
|
|
21982
|
+
evt.item = targetEl || rootEl;
|
|
21983
|
+
evt.clone = cloneEl;
|
|
21984
|
+
evt.oldIndex = oldIndex;
|
|
21985
|
+
evt.newIndex = newIndex;
|
|
21986
|
+
evt.oldDraggableIndex = oldDraggableIndex;
|
|
21987
|
+
evt.newDraggableIndex = newDraggableIndex;
|
|
21988
|
+
evt.originalEvent = originalEvent;
|
|
21989
|
+
evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
|
|
21990
|
+
var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
|
|
21991
|
+
for (var option in allEventProperties) {
|
|
21992
|
+
evt[option] = allEventProperties[option];
|
|
21993
|
+
}
|
|
21994
|
+
if (rootEl) {
|
|
21995
|
+
rootEl.dispatchEvent(evt);
|
|
21996
|
+
}
|
|
21997
|
+
if (options[onName]) {
|
|
21998
|
+
options[onName].call(sortable, evt);
|
|
21999
|
+
}
|
|
22000
|
+
}
|
|
22001
|
+
|
|
22002
|
+
var _excluded = ["evt"];
|
|
22003
|
+
var pluginEvent = function pluginEvent(eventName, sortable) {
|
|
22004
|
+
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
22005
|
+
originalEvent = _ref.evt,
|
|
22006
|
+
data = _objectWithoutProperties(_ref, _excluded);
|
|
22007
|
+
PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
|
|
22008
|
+
dragEl: dragEl,
|
|
22009
|
+
parentEl: parentEl,
|
|
22010
|
+
ghostEl: ghostEl,
|
|
22011
|
+
rootEl: rootEl,
|
|
22012
|
+
nextEl: nextEl,
|
|
22013
|
+
lastDownEl: lastDownEl,
|
|
22014
|
+
cloneEl: cloneEl,
|
|
22015
|
+
cloneHidden: cloneHidden,
|
|
22016
|
+
dragStarted: moved,
|
|
22017
|
+
putSortable: putSortable,
|
|
22018
|
+
activeSortable: Sortable.active,
|
|
22019
|
+
originalEvent: originalEvent,
|
|
22020
|
+
oldIndex: oldIndex,
|
|
22021
|
+
oldDraggableIndex: oldDraggableIndex,
|
|
22022
|
+
newIndex: sortable_esm_newIndex,
|
|
22023
|
+
newDraggableIndex: newDraggableIndex,
|
|
22024
|
+
hideGhostForTarget: _hideGhostForTarget,
|
|
22025
|
+
unhideGhostForTarget: _unhideGhostForTarget,
|
|
22026
|
+
cloneNowHidden: function cloneNowHidden() {
|
|
22027
|
+
cloneHidden = true;
|
|
22028
|
+
},
|
|
22029
|
+
cloneNowShown: function cloneNowShown() {
|
|
22030
|
+
cloneHidden = false;
|
|
22031
|
+
},
|
|
22032
|
+
dispatchSortableEvent: function dispatchSortableEvent(name) {
|
|
22033
|
+
_dispatchEvent({
|
|
22034
|
+
sortable: sortable,
|
|
22035
|
+
name: name,
|
|
22036
|
+
originalEvent: originalEvent
|
|
22037
|
+
});
|
|
22038
|
+
}
|
|
22039
|
+
}, data));
|
|
22040
|
+
};
|
|
22041
|
+
function _dispatchEvent(info) {
|
|
22042
|
+
dispatchEvent(_objectSpread2({
|
|
22043
|
+
putSortable: putSortable,
|
|
22044
|
+
cloneEl: cloneEl,
|
|
22045
|
+
targetEl: dragEl,
|
|
22046
|
+
rootEl: rootEl,
|
|
22047
|
+
oldIndex: oldIndex,
|
|
22048
|
+
oldDraggableIndex: oldDraggableIndex,
|
|
22049
|
+
newIndex: sortable_esm_newIndex,
|
|
22050
|
+
newDraggableIndex: newDraggableIndex
|
|
22051
|
+
}, info));
|
|
22052
|
+
}
|
|
22053
|
+
var dragEl,
|
|
22054
|
+
parentEl,
|
|
22055
|
+
ghostEl,
|
|
22056
|
+
rootEl,
|
|
22057
|
+
nextEl,
|
|
22058
|
+
lastDownEl,
|
|
22059
|
+
cloneEl,
|
|
22060
|
+
cloneHidden,
|
|
22061
|
+
oldIndex,
|
|
22062
|
+
sortable_esm_newIndex,
|
|
22063
|
+
oldDraggableIndex,
|
|
22064
|
+
newDraggableIndex,
|
|
22065
|
+
activeGroup,
|
|
22066
|
+
putSortable,
|
|
22067
|
+
awaitingDragStarted = false,
|
|
22068
|
+
ignoreNextClick = false,
|
|
22069
|
+
sortables = [],
|
|
22070
|
+
tapEvt,
|
|
22071
|
+
touchEvt,
|
|
22072
|
+
lastDx,
|
|
22073
|
+
lastDy,
|
|
22074
|
+
tapDistanceLeft,
|
|
22075
|
+
tapDistanceTop,
|
|
22076
|
+
moved,
|
|
22077
|
+
lastTarget,
|
|
22078
|
+
lastDirection,
|
|
22079
|
+
pastFirstInvertThresh = false,
|
|
22080
|
+
isCircumstantialInvert = false,
|
|
22081
|
+
targetMoveDistance,
|
|
22082
|
+
// For positioning ghost absolutely
|
|
22083
|
+
ghostRelativeParent,
|
|
22084
|
+
ghostRelativeParentInitialScroll = [],
|
|
22085
|
+
// (left, top)
|
|
22086
|
+
|
|
22087
|
+
_silent = false,
|
|
22088
|
+
savedInputChecked = [];
|
|
22089
|
+
|
|
22090
|
+
/** @const */
|
|
22091
|
+
var documentExists = typeof document !== 'undefined',
|
|
22092
|
+
PositionGhostAbsolutely = IOS,
|
|
22093
|
+
CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
|
|
22094
|
+
// This will not pass for IE9, because IE9 DnD only works on anchors
|
|
22095
|
+
supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
|
|
22096
|
+
supportCssPointerEvents = function () {
|
|
22097
|
+
if (!documentExists) return;
|
|
22098
|
+
// false when <= IE11
|
|
22099
|
+
if (IE11OrLess) {
|
|
22100
|
+
return false;
|
|
22101
|
+
}
|
|
22102
|
+
var el = document.createElement('x');
|
|
22103
|
+
el.style.cssText = 'pointer-events:auto';
|
|
22104
|
+
return el.style.pointerEvents === 'auto';
|
|
22105
|
+
}(),
|
|
22106
|
+
_detectDirection = function _detectDirection(el, options) {
|
|
22107
|
+
var elCSS = sortable_esm_css(el),
|
|
22108
|
+
elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
|
|
22109
|
+
child1 = getChild(el, 0, options),
|
|
22110
|
+
child2 = getChild(el, 1, options),
|
|
22111
|
+
firstChildCSS = child1 && sortable_esm_css(child1),
|
|
22112
|
+
secondChildCSS = child2 && sortable_esm_css(child2),
|
|
22113
|
+
firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + sortable_esm_getRect(child1).width,
|
|
22114
|
+
secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + sortable_esm_getRect(child2).width;
|
|
22115
|
+
if (elCSS.display === 'flex') {
|
|
22116
|
+
return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
|
|
22117
|
+
}
|
|
22118
|
+
if (elCSS.display === 'grid') {
|
|
22119
|
+
return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
|
|
22120
|
+
}
|
|
22121
|
+
if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
|
|
22122
|
+
var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
|
|
22123
|
+
return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
|
|
22124
|
+
}
|
|
22125
|
+
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';
|
|
22126
|
+
},
|
|
22127
|
+
_dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
|
|
22128
|
+
var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
|
|
22129
|
+
dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
|
|
22130
|
+
dragElOppLength = vertical ? dragRect.width : dragRect.height,
|
|
22131
|
+
targetS1Opp = vertical ? targetRect.left : targetRect.top,
|
|
22132
|
+
targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
|
|
22133
|
+
targetOppLength = vertical ? targetRect.width : targetRect.height;
|
|
22134
|
+
return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
|
|
22135
|
+
},
|
|
22136
|
+
/**
|
|
22137
|
+
* Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
|
|
22138
|
+
* @param {Number} x X position
|
|
22139
|
+
* @param {Number} y Y position
|
|
22140
|
+
* @return {HTMLElement} Element of the first found nearest Sortable
|
|
22141
|
+
*/
|
|
22142
|
+
_detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
|
|
22143
|
+
var ret;
|
|
22144
|
+
sortables.some(function (sortable) {
|
|
22145
|
+
var threshold = sortable[expando].options.emptyInsertThreshold;
|
|
22146
|
+
if (!threshold || lastChild(sortable)) return;
|
|
22147
|
+
var rect = sortable_esm_getRect(sortable),
|
|
22148
|
+
insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
|
|
22149
|
+
insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
|
|
22150
|
+
if (insideHorizontally && insideVertically) {
|
|
22151
|
+
return ret = sortable;
|
|
22152
|
+
}
|
|
22153
|
+
});
|
|
22154
|
+
return ret;
|
|
22155
|
+
},
|
|
22156
|
+
_prepareGroup = function _prepareGroup(options) {
|
|
22157
|
+
function toFn(value, pull) {
|
|
22158
|
+
return function (to, from, dragEl, evt) {
|
|
22159
|
+
var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
|
|
22160
|
+
if (value == null && (pull || sameGroup)) {
|
|
22161
|
+
// Default pull value
|
|
22162
|
+
// Default pull and put value if same group
|
|
22163
|
+
return true;
|
|
22164
|
+
} else if (value == null || value === false) {
|
|
22165
|
+
return false;
|
|
22166
|
+
} else if (pull && value === 'clone') {
|
|
22167
|
+
return value;
|
|
22168
|
+
} else if (typeof value === 'function') {
|
|
22169
|
+
return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
|
|
22170
|
+
} else {
|
|
22171
|
+
var otherGroup = (pull ? to : from).options.group.name;
|
|
22172
|
+
return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
|
|
22173
|
+
}
|
|
22174
|
+
};
|
|
22175
|
+
}
|
|
22176
|
+
var group = {};
|
|
22177
|
+
var originalGroup = options.group;
|
|
22178
|
+
if (!originalGroup || sortable_esm_typeof(originalGroup) != 'object') {
|
|
22179
|
+
originalGroup = {
|
|
22180
|
+
name: originalGroup
|
|
22181
|
+
};
|
|
22182
|
+
}
|
|
22183
|
+
group.name = originalGroup.name;
|
|
22184
|
+
group.checkPull = toFn(originalGroup.pull, true);
|
|
22185
|
+
group.checkPut = toFn(originalGroup.put);
|
|
22186
|
+
group.revertClone = originalGroup.revertClone;
|
|
22187
|
+
options.group = group;
|
|
22188
|
+
},
|
|
22189
|
+
_hideGhostForTarget = function _hideGhostForTarget() {
|
|
22190
|
+
if (!supportCssPointerEvents && ghostEl) {
|
|
22191
|
+
sortable_esm_css(ghostEl, 'display', 'none');
|
|
22192
|
+
}
|
|
22193
|
+
},
|
|
22194
|
+
_unhideGhostForTarget = function _unhideGhostForTarget() {
|
|
22195
|
+
if (!supportCssPointerEvents && ghostEl) {
|
|
22196
|
+
sortable_esm_css(ghostEl, 'display', '');
|
|
22197
|
+
}
|
|
22198
|
+
};
|
|
22199
|
+
|
|
22200
|
+
// #1184 fix - Prevent click event on fallback if dragged but item not changed position
|
|
22201
|
+
if (documentExists && !ChromeForAndroid) {
|
|
22202
|
+
document.addEventListener('click', function (evt) {
|
|
22203
|
+
if (ignoreNextClick) {
|
|
22204
|
+
evt.preventDefault();
|
|
22205
|
+
evt.stopPropagation && evt.stopPropagation();
|
|
22206
|
+
evt.stopImmediatePropagation && evt.stopImmediatePropagation();
|
|
22207
|
+
ignoreNextClick = false;
|
|
22208
|
+
return false;
|
|
22209
|
+
}
|
|
22210
|
+
}, true);
|
|
22211
|
+
}
|
|
22212
|
+
var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
|
|
22213
|
+
if (dragEl) {
|
|
22214
|
+
evt = evt.touches ? evt.touches[0] : evt;
|
|
22215
|
+
var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
|
|
22216
|
+
if (nearest) {
|
|
22217
|
+
// Create imitation event
|
|
22218
|
+
var event = {};
|
|
22219
|
+
for (var i in evt) {
|
|
22220
|
+
if (evt.hasOwnProperty(i)) {
|
|
22221
|
+
event[i] = evt[i];
|
|
22222
|
+
}
|
|
22223
|
+
}
|
|
22224
|
+
event.target = event.rootEl = nearest;
|
|
22225
|
+
event.preventDefault = void 0;
|
|
22226
|
+
event.stopPropagation = void 0;
|
|
22227
|
+
nearest[expando]._onDragOver(event);
|
|
22228
|
+
}
|
|
22229
|
+
}
|
|
22230
|
+
};
|
|
22231
|
+
var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
|
|
22232
|
+
if (dragEl) {
|
|
22233
|
+
dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
|
|
22234
|
+
}
|
|
22235
|
+
};
|
|
22236
|
+
|
|
22237
|
+
/**
|
|
22238
|
+
* @class Sortable
|
|
22239
|
+
* @param {HTMLElement} el
|
|
22240
|
+
* @param {Object} [options]
|
|
22241
|
+
*/
|
|
22242
|
+
function Sortable(el, options) {
|
|
22243
|
+
if (!(el && el.nodeType && el.nodeType === 1)) {
|
|
22244
|
+
throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
|
|
22245
|
+
}
|
|
22246
|
+
this.el = el; // root element
|
|
22247
|
+
this.options = options = sortable_esm_extends({}, options);
|
|
22248
|
+
|
|
22249
|
+
// Export instance
|
|
22250
|
+
el[expando] = this;
|
|
22251
|
+
var defaults = {
|
|
22252
|
+
group: null,
|
|
22253
|
+
sort: true,
|
|
22254
|
+
disabled: false,
|
|
22255
|
+
store: null,
|
|
22256
|
+
handle: null,
|
|
22257
|
+
draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
|
|
22258
|
+
swapThreshold: 1,
|
|
22259
|
+
// percentage; 0 <= x <= 1
|
|
22260
|
+
invertSwap: false,
|
|
22261
|
+
// invert always
|
|
22262
|
+
invertedSwapThreshold: null,
|
|
22263
|
+
// will be set to same as swapThreshold if default
|
|
22264
|
+
removeCloneOnHide: true,
|
|
22265
|
+
direction: function direction() {
|
|
22266
|
+
return _detectDirection(el, this.options);
|
|
22267
|
+
},
|
|
22268
|
+
ghostClass: 'sortable-ghost',
|
|
22269
|
+
chosenClass: 'sortable-chosen',
|
|
22270
|
+
dragClass: 'sortable-drag',
|
|
22271
|
+
ignore: 'a, img',
|
|
22272
|
+
filter: null,
|
|
22273
|
+
preventOnFilter: true,
|
|
22274
|
+
animation: 0,
|
|
22275
|
+
easing: null,
|
|
22276
|
+
setData: function setData(dataTransfer, dragEl) {
|
|
22277
|
+
dataTransfer.setData('Text', dragEl.textContent);
|
|
22278
|
+
},
|
|
22279
|
+
dropBubble: false,
|
|
22280
|
+
dragoverBubble: false,
|
|
22281
|
+
dataIdAttr: 'data-id',
|
|
22282
|
+
delay: 0,
|
|
22283
|
+
delayOnTouchOnly: false,
|
|
22284
|
+
touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
|
|
22285
|
+
forceFallback: false,
|
|
22286
|
+
fallbackClass: 'sortable-fallback',
|
|
22287
|
+
fallbackOnBody: false,
|
|
22288
|
+
fallbackTolerance: 0,
|
|
22289
|
+
fallbackOffset: {
|
|
22290
|
+
x: 0,
|
|
22291
|
+
y: 0
|
|
22292
|
+
},
|
|
22293
|
+
// Disabled on Safari: #1571; Enabled on Safari IOS: #2244
|
|
22294
|
+
supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && (!Safari || IOS),
|
|
22295
|
+
emptyInsertThreshold: 5
|
|
22296
|
+
};
|
|
22297
|
+
PluginManager.initializePlugins(this, el, defaults);
|
|
22298
|
+
|
|
22299
|
+
// Set default options
|
|
22300
|
+
for (var name in defaults) {
|
|
22301
|
+
!(name in options) && (options[name] = defaults[name]);
|
|
22302
|
+
}
|
|
22303
|
+
_prepareGroup(options);
|
|
22304
|
+
|
|
22305
|
+
// Bind all private methods
|
|
22306
|
+
for (var fn in this) {
|
|
22307
|
+
if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
|
|
22308
|
+
this[fn] = this[fn].bind(this);
|
|
22309
|
+
}
|
|
22310
|
+
}
|
|
22311
|
+
|
|
22312
|
+
// Setup drag mode
|
|
22313
|
+
this.nativeDraggable = options.forceFallback ? false : supportDraggable;
|
|
22314
|
+
if (this.nativeDraggable) {
|
|
22315
|
+
// Touch start threshold cannot be greater than the native dragstart threshold
|
|
22316
|
+
this.options.touchStartThreshold = 1;
|
|
22317
|
+
}
|
|
22318
|
+
|
|
22319
|
+
// Bind events
|
|
22320
|
+
if (options.supportPointer) {
|
|
22321
|
+
sortable_esm_on(el, 'pointerdown', this._onTapStart);
|
|
22322
|
+
} else {
|
|
22323
|
+
sortable_esm_on(el, 'mousedown', this._onTapStart);
|
|
22324
|
+
sortable_esm_on(el, 'touchstart', this._onTapStart);
|
|
22325
|
+
}
|
|
22326
|
+
if (this.nativeDraggable) {
|
|
22327
|
+
sortable_esm_on(el, 'dragover', this);
|
|
22328
|
+
sortable_esm_on(el, 'dragenter', this);
|
|
22329
|
+
}
|
|
22330
|
+
sortables.push(this.el);
|
|
22331
|
+
|
|
22332
|
+
// Restore sorting
|
|
22333
|
+
options.store && options.store.get && this.sort(options.store.get(this) || []);
|
|
22334
|
+
|
|
22335
|
+
// Add animation state manager
|
|
22336
|
+
sortable_esm_extends(this, AnimationStateManager());
|
|
22337
|
+
}
|
|
22338
|
+
Sortable.prototype = /** @lends Sortable.prototype */{
|
|
22339
|
+
constructor: Sortable,
|
|
22340
|
+
_isOutsideThisEl: function _isOutsideThisEl(target) {
|
|
22341
|
+
if (!this.el.contains(target) && target !== this.el) {
|
|
22342
|
+
lastTarget = null;
|
|
22343
|
+
}
|
|
22344
|
+
},
|
|
22345
|
+
_getDirection: function _getDirection(evt, target) {
|
|
22346
|
+
return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
|
|
22347
|
+
},
|
|
22348
|
+
_onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
|
|
22349
|
+
if (!evt.cancelable) return;
|
|
22350
|
+
var _this = this,
|
|
22351
|
+
el = this.el,
|
|
22352
|
+
options = this.options,
|
|
22353
|
+
preventOnFilter = options.preventOnFilter,
|
|
22354
|
+
type = evt.type,
|
|
22355
|
+
touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
|
|
22356
|
+
target = (touch || evt).target,
|
|
22357
|
+
originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
|
|
22358
|
+
filter = options.filter;
|
|
22359
|
+
_saveInputCheckedState(el);
|
|
22360
|
+
|
|
22361
|
+
// Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
|
|
22362
|
+
if (dragEl) {
|
|
22363
|
+
return;
|
|
22364
|
+
}
|
|
22365
|
+
if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
|
|
22366
|
+
return; // only left button and enabled
|
|
22367
|
+
}
|
|
22368
|
+
|
|
22369
|
+
// cancel dnd if original target is content editable
|
|
22370
|
+
if (originalTarget.isContentEditable) {
|
|
22371
|
+
return;
|
|
22372
|
+
}
|
|
22373
|
+
|
|
22374
|
+
// Safari ignores further event handling after mousedown
|
|
22375
|
+
if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
|
|
22376
|
+
return;
|
|
22377
|
+
}
|
|
22378
|
+
target = closest(target, options.draggable, el, false);
|
|
22379
|
+
if (target && target.animated) {
|
|
22380
|
+
return;
|
|
22381
|
+
}
|
|
22382
|
+
if (lastDownEl === target) {
|
|
22383
|
+
// Ignoring duplicate `down`
|
|
22384
|
+
return;
|
|
22385
|
+
}
|
|
22386
|
+
|
|
22387
|
+
// Get the index of the dragged element within its parent
|
|
22388
|
+
oldIndex = sortable_esm_index(target);
|
|
22389
|
+
oldDraggableIndex = sortable_esm_index(target, options.draggable);
|
|
22390
|
+
|
|
22391
|
+
// Check filter
|
|
22392
|
+
if (typeof filter === 'function') {
|
|
22393
|
+
if (filter.call(this, evt, target, this)) {
|
|
22394
|
+
_dispatchEvent({
|
|
22395
|
+
sortable: _this,
|
|
22396
|
+
rootEl: originalTarget,
|
|
22397
|
+
name: 'filter',
|
|
22398
|
+
targetEl: target,
|
|
22399
|
+
toEl: el,
|
|
22400
|
+
fromEl: el
|
|
22401
|
+
});
|
|
22402
|
+
pluginEvent('filter', _this, {
|
|
22403
|
+
evt: evt
|
|
22404
|
+
});
|
|
22405
|
+
preventOnFilter && evt.preventDefault();
|
|
22406
|
+
return; // cancel dnd
|
|
22407
|
+
}
|
|
22408
|
+
} else if (filter) {
|
|
22409
|
+
filter = filter.split(',').some(function (criteria) {
|
|
22410
|
+
criteria = closest(originalTarget, criteria.trim(), el, false);
|
|
22411
|
+
if (criteria) {
|
|
22412
|
+
_dispatchEvent({
|
|
22413
|
+
sortable: _this,
|
|
22414
|
+
rootEl: criteria,
|
|
22415
|
+
name: 'filter',
|
|
22416
|
+
targetEl: target,
|
|
22417
|
+
fromEl: el,
|
|
22418
|
+
toEl: el
|
|
22419
|
+
});
|
|
22420
|
+
pluginEvent('filter', _this, {
|
|
22421
|
+
evt: evt
|
|
22422
|
+
});
|
|
22423
|
+
return true;
|
|
22424
|
+
}
|
|
22425
|
+
});
|
|
22426
|
+
if (filter) {
|
|
22427
|
+
preventOnFilter && evt.preventDefault();
|
|
22428
|
+
return; // cancel dnd
|
|
22429
|
+
}
|
|
22430
|
+
}
|
|
22431
|
+
if (options.handle && !closest(originalTarget, options.handle, el, false)) {
|
|
22432
|
+
return;
|
|
22433
|
+
}
|
|
22434
|
+
|
|
22435
|
+
// Prepare `dragstart`
|
|
22436
|
+
this._prepareDragStart(evt, touch, target);
|
|
22437
|
+
},
|
|
22438
|
+
_prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) {
|
|
22439
|
+
var _this = this,
|
|
22440
|
+
el = _this.el,
|
|
22441
|
+
options = _this.options,
|
|
22442
|
+
ownerDocument = el.ownerDocument,
|
|
22443
|
+
dragStartFn;
|
|
22444
|
+
if (target && !dragEl && target.parentNode === el) {
|
|
22445
|
+
var dragRect = sortable_esm_getRect(target);
|
|
22446
|
+
rootEl = el;
|
|
22447
|
+
dragEl = target;
|
|
22448
|
+
parentEl = dragEl.parentNode;
|
|
22449
|
+
nextEl = dragEl.nextSibling;
|
|
22450
|
+
lastDownEl = target;
|
|
22451
|
+
activeGroup = options.group;
|
|
22452
|
+
Sortable.dragged = dragEl;
|
|
22453
|
+
tapEvt = {
|
|
22454
|
+
target: dragEl,
|
|
22455
|
+
clientX: (touch || evt).clientX,
|
|
22456
|
+
clientY: (touch || evt).clientY
|
|
22457
|
+
};
|
|
22458
|
+
tapDistanceLeft = tapEvt.clientX - dragRect.left;
|
|
22459
|
+
tapDistanceTop = tapEvt.clientY - dragRect.top;
|
|
22460
|
+
this._lastX = (touch || evt).clientX;
|
|
22461
|
+
this._lastY = (touch || evt).clientY;
|
|
22462
|
+
dragEl.style['will-change'] = 'all';
|
|
22463
|
+
dragStartFn = function dragStartFn() {
|
|
22464
|
+
pluginEvent('delayEnded', _this, {
|
|
22465
|
+
evt: evt
|
|
22466
|
+
});
|
|
22467
|
+
if (Sortable.eventCanceled) {
|
|
22468
|
+
_this._onDrop();
|
|
22469
|
+
return;
|
|
22470
|
+
}
|
|
22471
|
+
// Delayed drag has been triggered
|
|
22472
|
+
// we can re-enable the events: touchmove/mousemove
|
|
22473
|
+
_this._disableDelayedDragEvents();
|
|
22474
|
+
if (!FireFox && _this.nativeDraggable) {
|
|
22475
|
+
dragEl.draggable = true;
|
|
22476
|
+
}
|
|
22477
|
+
|
|
22478
|
+
// Bind the events: dragstart/dragend
|
|
22479
|
+
_this._triggerDragStart(evt, touch);
|
|
22480
|
+
|
|
22481
|
+
// Drag start event
|
|
22482
|
+
_dispatchEvent({
|
|
22483
|
+
sortable: _this,
|
|
22484
|
+
name: 'choose',
|
|
22485
|
+
originalEvent: evt
|
|
22486
|
+
});
|
|
22487
|
+
|
|
22488
|
+
// Chosen item
|
|
22489
|
+
toggleClass(dragEl, options.chosenClass, true);
|
|
22490
|
+
};
|
|
22491
|
+
|
|
22492
|
+
// Disable "draggable"
|
|
22493
|
+
options.ignore.split(',').forEach(function (criteria) {
|
|
22494
|
+
sortable_esm_find(dragEl, criteria.trim(), _disableDraggable);
|
|
22495
|
+
});
|
|
22496
|
+
sortable_esm_on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
|
|
22497
|
+
sortable_esm_on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
|
|
22498
|
+
sortable_esm_on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
|
|
22499
|
+
if (options.supportPointer) {
|
|
22500
|
+
sortable_esm_on(ownerDocument, 'pointerup', _this._onDrop);
|
|
22501
|
+
// Native D&D triggers pointercancel
|
|
22502
|
+
!this.nativeDraggable && sortable_esm_on(ownerDocument, 'pointercancel', _this._onDrop);
|
|
22503
|
+
} else {
|
|
22504
|
+
sortable_esm_on(ownerDocument, 'mouseup', _this._onDrop);
|
|
22505
|
+
sortable_esm_on(ownerDocument, 'touchend', _this._onDrop);
|
|
22506
|
+
sortable_esm_on(ownerDocument, 'touchcancel', _this._onDrop);
|
|
22507
|
+
}
|
|
22508
|
+
|
|
22509
|
+
// Make dragEl draggable (must be before delay for FireFox)
|
|
22510
|
+
if (FireFox && this.nativeDraggable) {
|
|
22511
|
+
this.options.touchStartThreshold = 4;
|
|
22512
|
+
dragEl.draggable = true;
|
|
22513
|
+
}
|
|
22514
|
+
pluginEvent('delayStart', this, {
|
|
22515
|
+
evt: evt
|
|
22516
|
+
});
|
|
22517
|
+
|
|
22518
|
+
// Delay is impossible for native DnD in Edge or IE
|
|
22519
|
+
if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
|
|
22520
|
+
if (Sortable.eventCanceled) {
|
|
22521
|
+
this._onDrop();
|
|
22522
|
+
return;
|
|
22523
|
+
}
|
|
22524
|
+
// If the user moves the pointer or let go the click or touch
|
|
22525
|
+
// before the delay has been reached:
|
|
22526
|
+
// disable the delayed drag
|
|
22527
|
+
if (options.supportPointer) {
|
|
22528
|
+
sortable_esm_on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
|
|
22529
|
+
sortable_esm_on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
|
|
22530
|
+
} else {
|
|
22531
|
+
sortable_esm_on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
|
|
22532
|
+
sortable_esm_on(ownerDocument, 'touchend', _this._disableDelayedDrag);
|
|
22533
|
+
sortable_esm_on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
|
|
22534
|
+
}
|
|
22535
|
+
sortable_esm_on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
|
|
22536
|
+
sortable_esm_on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
|
|
22537
|
+
options.supportPointer && sortable_esm_on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
|
|
22538
|
+
_this._dragStartTimer = setTimeout(dragStartFn, options.delay);
|
|
22539
|
+
} else {
|
|
22540
|
+
dragStartFn();
|
|
22541
|
+
}
|
|
22542
|
+
}
|
|
22543
|
+
},
|
|
22544
|
+
_delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) {
|
|
22545
|
+
var touch = e.touches ? e.touches[0] : e;
|
|
22546
|
+
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))) {
|
|
22547
|
+
this._disableDelayedDrag();
|
|
22548
|
+
}
|
|
22549
|
+
},
|
|
22550
|
+
_disableDelayedDrag: function _disableDelayedDrag() {
|
|
22551
|
+
dragEl && _disableDraggable(dragEl);
|
|
22552
|
+
clearTimeout(this._dragStartTimer);
|
|
22553
|
+
this._disableDelayedDragEvents();
|
|
22554
|
+
},
|
|
22555
|
+
_disableDelayedDragEvents: function _disableDelayedDragEvents() {
|
|
22556
|
+
var ownerDocument = this.el.ownerDocument;
|
|
22557
|
+
sortable_esm_off(ownerDocument, 'mouseup', this._disableDelayedDrag);
|
|
22558
|
+
sortable_esm_off(ownerDocument, 'touchend', this._disableDelayedDrag);
|
|
22559
|
+
sortable_esm_off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
|
|
22560
|
+
sortable_esm_off(ownerDocument, 'pointerup', this._disableDelayedDrag);
|
|
22561
|
+
sortable_esm_off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
|
|
22562
|
+
sortable_esm_off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
|
|
22563
|
+
sortable_esm_off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
|
|
22564
|
+
sortable_esm_off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
|
|
22565
|
+
},
|
|
22566
|
+
_triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
|
|
22567
|
+
touch = touch || evt.pointerType == 'touch' && evt;
|
|
22568
|
+
if (!this.nativeDraggable || touch) {
|
|
22569
|
+
if (this.options.supportPointer) {
|
|
22570
|
+
sortable_esm_on(document, 'pointermove', this._onTouchMove);
|
|
22571
|
+
} else if (touch) {
|
|
22572
|
+
sortable_esm_on(document, 'touchmove', this._onTouchMove);
|
|
22573
|
+
} else {
|
|
22574
|
+
sortable_esm_on(document, 'mousemove', this._onTouchMove);
|
|
22575
|
+
}
|
|
22576
|
+
} else {
|
|
22577
|
+
sortable_esm_on(dragEl, 'dragend', this);
|
|
22578
|
+
sortable_esm_on(rootEl, 'dragstart', this._onDragStart);
|
|
22579
|
+
}
|
|
22580
|
+
try {
|
|
22581
|
+
if (document.selection) {
|
|
22582
|
+
_nextTick(function () {
|
|
22583
|
+
document.selection.empty();
|
|
22584
|
+
});
|
|
22585
|
+
} else {
|
|
22586
|
+
window.getSelection().removeAllRanges();
|
|
22587
|
+
}
|
|
22588
|
+
} catch (err) {}
|
|
22589
|
+
},
|
|
22590
|
+
_dragStarted: function _dragStarted(fallback, evt) {
|
|
22591
|
+
awaitingDragStarted = false;
|
|
22592
|
+
if (rootEl && dragEl) {
|
|
22593
|
+
pluginEvent('dragStarted', this, {
|
|
22594
|
+
evt: evt
|
|
22595
|
+
});
|
|
22596
|
+
if (this.nativeDraggable) {
|
|
22597
|
+
sortable_esm_on(document, 'dragover', _checkOutsideTargetEl);
|
|
22598
|
+
}
|
|
22599
|
+
var options = this.options;
|
|
22600
|
+
|
|
22601
|
+
// Apply effect
|
|
22602
|
+
!fallback && toggleClass(dragEl, options.dragClass, false);
|
|
22603
|
+
toggleClass(dragEl, options.ghostClass, true);
|
|
22604
|
+
Sortable.active = this;
|
|
22605
|
+
fallback && this._appendGhost();
|
|
22606
|
+
|
|
22607
|
+
// Drag start event
|
|
22608
|
+
_dispatchEvent({
|
|
22609
|
+
sortable: this,
|
|
22610
|
+
name: 'start',
|
|
22611
|
+
originalEvent: evt
|
|
22612
|
+
});
|
|
22613
|
+
} else {
|
|
22614
|
+
this._nulling();
|
|
22615
|
+
}
|
|
22616
|
+
},
|
|
22617
|
+
_emulateDragOver: function _emulateDragOver() {
|
|
22618
|
+
if (touchEvt) {
|
|
22619
|
+
this._lastX = touchEvt.clientX;
|
|
22620
|
+
this._lastY = touchEvt.clientY;
|
|
22621
|
+
_hideGhostForTarget();
|
|
22622
|
+
var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
|
|
22623
|
+
var parent = target;
|
|
22624
|
+
while (target && target.shadowRoot) {
|
|
22625
|
+
target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
|
|
22626
|
+
if (target === parent) break;
|
|
22627
|
+
parent = target;
|
|
22628
|
+
}
|
|
22629
|
+
dragEl.parentNode[expando]._isOutsideThisEl(target);
|
|
22630
|
+
if (parent) {
|
|
22631
|
+
do {
|
|
22632
|
+
if (parent[expando]) {
|
|
22633
|
+
var inserted = void 0;
|
|
22634
|
+
inserted = parent[expando]._onDragOver({
|
|
22635
|
+
clientX: touchEvt.clientX,
|
|
22636
|
+
clientY: touchEvt.clientY,
|
|
22637
|
+
target: target,
|
|
22638
|
+
rootEl: parent
|
|
22639
|
+
});
|
|
22640
|
+
if (inserted && !this.options.dragoverBubble) {
|
|
22641
|
+
break;
|
|
22642
|
+
}
|
|
22643
|
+
}
|
|
22644
|
+
target = parent; // store last element
|
|
22645
|
+
}
|
|
22646
|
+
/* jshint boss:true */ while (parent = getParentOrHost(parent));
|
|
22647
|
+
}
|
|
22648
|
+
_unhideGhostForTarget();
|
|
22649
|
+
}
|
|
22650
|
+
},
|
|
22651
|
+
_onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
|
|
22652
|
+
if (tapEvt) {
|
|
22653
|
+
var options = this.options,
|
|
22654
|
+
fallbackTolerance = options.fallbackTolerance,
|
|
22655
|
+
fallbackOffset = options.fallbackOffset,
|
|
22656
|
+
touch = evt.touches ? evt.touches[0] : evt,
|
|
22657
|
+
ghostMatrix = ghostEl && matrix(ghostEl, true),
|
|
22658
|
+
scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
|
|
22659
|
+
scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
|
|
22660
|
+
relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
|
|
22661
|
+
dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
|
|
22662
|
+
dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
|
|
22663
|
+
|
|
22664
|
+
// only set the status to dragging, when we are actually dragging
|
|
22665
|
+
if (!Sortable.active && !awaitingDragStarted) {
|
|
22666
|
+
if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
|
|
22667
|
+
return;
|
|
22668
|
+
}
|
|
22669
|
+
this._onDragStart(evt, true);
|
|
22670
|
+
}
|
|
22671
|
+
if (ghostEl) {
|
|
22672
|
+
if (ghostMatrix) {
|
|
22673
|
+
ghostMatrix.e += dx - (lastDx || 0);
|
|
22674
|
+
ghostMatrix.f += dy - (lastDy || 0);
|
|
22675
|
+
} else {
|
|
22676
|
+
ghostMatrix = {
|
|
22677
|
+
a: 1,
|
|
22678
|
+
b: 0,
|
|
22679
|
+
c: 0,
|
|
22680
|
+
d: 1,
|
|
22681
|
+
e: dx,
|
|
22682
|
+
f: dy
|
|
22683
|
+
};
|
|
22684
|
+
}
|
|
22685
|
+
var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
|
|
22686
|
+
sortable_esm_css(ghostEl, 'webkitTransform', cssMatrix);
|
|
22687
|
+
sortable_esm_css(ghostEl, 'mozTransform', cssMatrix);
|
|
22688
|
+
sortable_esm_css(ghostEl, 'msTransform', cssMatrix);
|
|
22689
|
+
sortable_esm_css(ghostEl, 'transform', cssMatrix);
|
|
22690
|
+
lastDx = dx;
|
|
22691
|
+
lastDy = dy;
|
|
22692
|
+
touchEvt = touch;
|
|
22693
|
+
}
|
|
22694
|
+
evt.cancelable && evt.preventDefault();
|
|
22695
|
+
}
|
|
22696
|
+
},
|
|
22697
|
+
_appendGhost: function _appendGhost() {
|
|
22698
|
+
// Bug if using scale(): https://stackoverflow.com/questions/2637058
|
|
22699
|
+
// Not being adjusted for
|
|
22700
|
+
if (!ghostEl) {
|
|
22701
|
+
var container = this.options.fallbackOnBody ? document.body : rootEl,
|
|
22702
|
+
rect = sortable_esm_getRect(dragEl, true, PositionGhostAbsolutely, true, container),
|
|
22703
|
+
options = this.options;
|
|
22704
|
+
|
|
22705
|
+
// Position absolutely
|
|
22706
|
+
if (PositionGhostAbsolutely) {
|
|
22707
|
+
// Get relatively positioned parent
|
|
22708
|
+
ghostRelativeParent = container;
|
|
22709
|
+
while (sortable_esm_css(ghostRelativeParent, 'position') === 'static' && sortable_esm_css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
|
|
22710
|
+
ghostRelativeParent = ghostRelativeParent.parentNode;
|
|
22711
|
+
}
|
|
22712
|
+
if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
|
|
22713
|
+
if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
|
|
22714
|
+
rect.top += ghostRelativeParent.scrollTop;
|
|
22715
|
+
rect.left += ghostRelativeParent.scrollLeft;
|
|
22716
|
+
} else {
|
|
22717
|
+
ghostRelativeParent = getWindowScrollingElement();
|
|
22718
|
+
}
|
|
22719
|
+
ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
|
|
22720
|
+
}
|
|
22721
|
+
ghostEl = dragEl.cloneNode(true);
|
|
22722
|
+
toggleClass(ghostEl, options.ghostClass, false);
|
|
22723
|
+
toggleClass(ghostEl, options.fallbackClass, true);
|
|
22724
|
+
toggleClass(ghostEl, options.dragClass, true);
|
|
22725
|
+
sortable_esm_css(ghostEl, 'transition', '');
|
|
22726
|
+
sortable_esm_css(ghostEl, 'transform', '');
|
|
22727
|
+
sortable_esm_css(ghostEl, 'box-sizing', 'border-box');
|
|
22728
|
+
sortable_esm_css(ghostEl, 'margin', 0);
|
|
22729
|
+
sortable_esm_css(ghostEl, 'top', rect.top);
|
|
22730
|
+
sortable_esm_css(ghostEl, 'left', rect.left);
|
|
22731
|
+
sortable_esm_css(ghostEl, 'width', rect.width);
|
|
22732
|
+
sortable_esm_css(ghostEl, 'height', rect.height);
|
|
22733
|
+
sortable_esm_css(ghostEl, 'opacity', '0.8');
|
|
22734
|
+
sortable_esm_css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
|
|
22735
|
+
sortable_esm_css(ghostEl, 'zIndex', '100000');
|
|
22736
|
+
sortable_esm_css(ghostEl, 'pointerEvents', 'none');
|
|
22737
|
+
Sortable.ghost = ghostEl;
|
|
22738
|
+
container.appendChild(ghostEl);
|
|
22739
|
+
|
|
22740
|
+
// Set transform-origin
|
|
22741
|
+
sortable_esm_css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
|
|
22742
|
+
}
|
|
22743
|
+
},
|
|
22744
|
+
_onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) {
|
|
22745
|
+
var _this = this;
|
|
22746
|
+
var dataTransfer = evt.dataTransfer;
|
|
22747
|
+
var options = _this.options;
|
|
22748
|
+
pluginEvent('dragStart', this, {
|
|
22749
|
+
evt: evt
|
|
22750
|
+
});
|
|
22751
|
+
if (Sortable.eventCanceled) {
|
|
22752
|
+
this._onDrop();
|
|
22753
|
+
return;
|
|
22754
|
+
}
|
|
22755
|
+
pluginEvent('setupClone', this);
|
|
22756
|
+
if (!Sortable.eventCanceled) {
|
|
22757
|
+
cloneEl = clone(dragEl);
|
|
22758
|
+
cloneEl.removeAttribute("id");
|
|
22759
|
+
cloneEl.draggable = false;
|
|
22760
|
+
cloneEl.style['will-change'] = '';
|
|
22761
|
+
this._hideClone();
|
|
22762
|
+
toggleClass(cloneEl, this.options.chosenClass, false);
|
|
22763
|
+
Sortable.clone = cloneEl;
|
|
22764
|
+
}
|
|
22765
|
+
|
|
22766
|
+
// #1143: IFrame support workaround
|
|
22767
|
+
_this.cloneId = _nextTick(function () {
|
|
22768
|
+
pluginEvent('clone', _this);
|
|
22769
|
+
if (Sortable.eventCanceled) return;
|
|
22770
|
+
if (!_this.options.removeCloneOnHide) {
|
|
22771
|
+
rootEl.insertBefore(cloneEl, dragEl);
|
|
22772
|
+
}
|
|
22773
|
+
_this._hideClone();
|
|
22774
|
+
_dispatchEvent({
|
|
22775
|
+
sortable: _this,
|
|
22776
|
+
name: 'clone'
|
|
22777
|
+
});
|
|
22778
|
+
});
|
|
22779
|
+
!fallback && toggleClass(dragEl, options.dragClass, true);
|
|
22780
|
+
|
|
22781
|
+
// Set proper drop events
|
|
22782
|
+
if (fallback) {
|
|
22783
|
+
ignoreNextClick = true;
|
|
22784
|
+
_this._loopId = setInterval(_this._emulateDragOver, 50);
|
|
22785
|
+
} else {
|
|
22786
|
+
// Undo what was set in _prepareDragStart before drag started
|
|
22787
|
+
sortable_esm_off(document, 'mouseup', _this._onDrop);
|
|
22788
|
+
sortable_esm_off(document, 'touchend', _this._onDrop);
|
|
22789
|
+
sortable_esm_off(document, 'touchcancel', _this._onDrop);
|
|
22790
|
+
if (dataTransfer) {
|
|
22791
|
+
dataTransfer.effectAllowed = 'move';
|
|
22792
|
+
options.setData && options.setData.call(_this, dataTransfer, dragEl);
|
|
22793
|
+
}
|
|
22794
|
+
sortable_esm_on(document, 'drop', _this);
|
|
22795
|
+
|
|
22796
|
+
// #1276 fix:
|
|
22797
|
+
sortable_esm_css(dragEl, 'transform', 'translateZ(0)');
|
|
22798
|
+
}
|
|
22799
|
+
awaitingDragStarted = true;
|
|
22800
|
+
_this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
|
|
22801
|
+
sortable_esm_on(document, 'selectstart', _this);
|
|
22802
|
+
moved = true;
|
|
22803
|
+
window.getSelection().removeAllRanges();
|
|
22804
|
+
if (Safari) {
|
|
22805
|
+
sortable_esm_css(document.body, 'user-select', 'none');
|
|
22806
|
+
}
|
|
22807
|
+
},
|
|
22808
|
+
// Returns true - if no further action is needed (either inserted or another condition)
|
|
22809
|
+
_onDragOver: function _onDragOver( /**Event*/evt) {
|
|
22810
|
+
var el = this.el,
|
|
22811
|
+
target = evt.target,
|
|
22812
|
+
dragRect,
|
|
22813
|
+
targetRect,
|
|
22814
|
+
revert,
|
|
22815
|
+
options = this.options,
|
|
22816
|
+
group = options.group,
|
|
22817
|
+
activeSortable = Sortable.active,
|
|
22818
|
+
isOwner = activeGroup === group,
|
|
22819
|
+
canSort = options.sort,
|
|
22820
|
+
fromSortable = putSortable || activeSortable,
|
|
22821
|
+
vertical,
|
|
22822
|
+
_this = this,
|
|
22823
|
+
completedFired = false;
|
|
22824
|
+
if (_silent) return;
|
|
22825
|
+
function dragOverEvent(name, extra) {
|
|
22826
|
+
pluginEvent(name, _this, _objectSpread2({
|
|
22827
|
+
evt: evt,
|
|
22828
|
+
isOwner: isOwner,
|
|
22829
|
+
axis: vertical ? 'vertical' : 'horizontal',
|
|
22830
|
+
revert: revert,
|
|
22831
|
+
dragRect: dragRect,
|
|
22832
|
+
targetRect: targetRect,
|
|
22833
|
+
canSort: canSort,
|
|
22834
|
+
fromSortable: fromSortable,
|
|
22835
|
+
target: target,
|
|
22836
|
+
completed: completed,
|
|
22837
|
+
onMove: function onMove(target, after) {
|
|
22838
|
+
return _onMove(rootEl, el, dragEl, dragRect, target, sortable_esm_getRect(target), evt, after);
|
|
22839
|
+
},
|
|
22840
|
+
changed: changed
|
|
22841
|
+
}, extra));
|
|
22842
|
+
}
|
|
22843
|
+
|
|
22844
|
+
// Capture animation state
|
|
22845
|
+
function capture() {
|
|
22846
|
+
dragOverEvent('dragOverAnimationCapture');
|
|
22847
|
+
_this.captureAnimationState();
|
|
22848
|
+
if (_this !== fromSortable) {
|
|
22849
|
+
fromSortable.captureAnimationState();
|
|
22850
|
+
}
|
|
22851
|
+
}
|
|
22852
|
+
|
|
22853
|
+
// Return invocation when dragEl is inserted (or completed)
|
|
22854
|
+
function completed(insertion) {
|
|
22855
|
+
dragOverEvent('dragOverCompleted', {
|
|
22856
|
+
insertion: insertion
|
|
22857
|
+
});
|
|
22858
|
+
if (insertion) {
|
|
22859
|
+
// Clones must be hidden before folding animation to capture dragRectAbsolute properly
|
|
22860
|
+
if (isOwner) {
|
|
22861
|
+
activeSortable._hideClone();
|
|
22862
|
+
} else {
|
|
22863
|
+
activeSortable._showClone(_this);
|
|
22864
|
+
}
|
|
22865
|
+
if (_this !== fromSortable) {
|
|
22866
|
+
// Set ghost class to new sortable's ghost class
|
|
22867
|
+
toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
|
|
22868
|
+
toggleClass(dragEl, options.ghostClass, true);
|
|
22869
|
+
}
|
|
22870
|
+
if (putSortable !== _this && _this !== Sortable.active) {
|
|
22871
|
+
putSortable = _this;
|
|
22872
|
+
} else if (_this === Sortable.active && putSortable) {
|
|
22873
|
+
putSortable = null;
|
|
22874
|
+
}
|
|
22875
|
+
|
|
22876
|
+
// Animation
|
|
22877
|
+
if (fromSortable === _this) {
|
|
22878
|
+
_this._ignoreWhileAnimating = target;
|
|
22879
|
+
}
|
|
22880
|
+
_this.animateAll(function () {
|
|
22881
|
+
dragOverEvent('dragOverAnimationComplete');
|
|
22882
|
+
_this._ignoreWhileAnimating = null;
|
|
22883
|
+
});
|
|
22884
|
+
if (_this !== fromSortable) {
|
|
22885
|
+
fromSortable.animateAll();
|
|
22886
|
+
fromSortable._ignoreWhileAnimating = null;
|
|
22887
|
+
}
|
|
22888
|
+
}
|
|
22889
|
+
|
|
22890
|
+
// Null lastTarget if it is not inside a previously swapped element
|
|
22891
|
+
if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
|
|
22892
|
+
lastTarget = null;
|
|
22893
|
+
}
|
|
22894
|
+
|
|
22895
|
+
// no bubbling and not fallback
|
|
22896
|
+
if (!options.dragoverBubble && !evt.rootEl && target !== document) {
|
|
22897
|
+
dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
|
|
22898
|
+
|
|
22899
|
+
// Do not detect for empty insert if already inserted
|
|
22900
|
+
!insertion && nearestEmptyInsertDetectEvent(evt);
|
|
22901
|
+
}
|
|
22902
|
+
!options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
|
|
22903
|
+
return completedFired = true;
|
|
22904
|
+
}
|
|
22905
|
+
|
|
22906
|
+
// Call when dragEl has been inserted
|
|
22907
|
+
function changed() {
|
|
22908
|
+
sortable_esm_newIndex = sortable_esm_index(dragEl);
|
|
22909
|
+
newDraggableIndex = sortable_esm_index(dragEl, options.draggable);
|
|
22910
|
+
_dispatchEvent({
|
|
22911
|
+
sortable: _this,
|
|
22912
|
+
name: 'change',
|
|
22913
|
+
toEl: el,
|
|
22914
|
+
newIndex: sortable_esm_newIndex,
|
|
22915
|
+
newDraggableIndex: newDraggableIndex,
|
|
22916
|
+
originalEvent: evt
|
|
22917
|
+
});
|
|
22918
|
+
}
|
|
22919
|
+
if (evt.preventDefault !== void 0) {
|
|
22920
|
+
evt.cancelable && evt.preventDefault();
|
|
22921
|
+
}
|
|
22922
|
+
target = closest(target, options.draggable, el, true);
|
|
22923
|
+
dragOverEvent('dragOver');
|
|
22924
|
+
if (Sortable.eventCanceled) return completedFired;
|
|
22925
|
+
if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
|
|
22926
|
+
return completed(false);
|
|
22927
|
+
}
|
|
22928
|
+
ignoreNextClick = false;
|
|
22929
|
+
if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
|
|
22930
|
+
: putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
|
|
22931
|
+
vertical = this._getDirection(evt, target) === 'vertical';
|
|
22932
|
+
dragRect = sortable_esm_getRect(dragEl);
|
|
22933
|
+
dragOverEvent('dragOverValid');
|
|
22934
|
+
if (Sortable.eventCanceled) return completedFired;
|
|
22935
|
+
if (revert) {
|
|
22936
|
+
parentEl = rootEl; // actualization
|
|
22937
|
+
capture();
|
|
22938
|
+
this._hideClone();
|
|
22939
|
+
dragOverEvent('revert');
|
|
22940
|
+
if (!Sortable.eventCanceled) {
|
|
22941
|
+
if (nextEl) {
|
|
22942
|
+
rootEl.insertBefore(dragEl, nextEl);
|
|
22943
|
+
} else {
|
|
22944
|
+
rootEl.appendChild(dragEl);
|
|
22945
|
+
}
|
|
22946
|
+
}
|
|
22947
|
+
return completed(true);
|
|
22948
|
+
}
|
|
22949
|
+
var elLastChild = lastChild(el, options.draggable);
|
|
22950
|
+
if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
|
|
22951
|
+
// Insert to end of list
|
|
22952
|
+
|
|
22953
|
+
// If already at end of list: Do not insert
|
|
22954
|
+
if (elLastChild === dragEl) {
|
|
22955
|
+
return completed(false);
|
|
22956
|
+
}
|
|
22957
|
+
|
|
22958
|
+
// if there is a last element, it is the target
|
|
22959
|
+
if (elLastChild && el === evt.target) {
|
|
22960
|
+
target = elLastChild;
|
|
22961
|
+
}
|
|
22962
|
+
if (target) {
|
|
22963
|
+
targetRect = sortable_esm_getRect(target);
|
|
22964
|
+
}
|
|
22965
|
+
if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
|
|
22966
|
+
capture();
|
|
22967
|
+
if (elLastChild && elLastChild.nextSibling) {
|
|
22968
|
+
// the last draggable element is not the last node
|
|
22969
|
+
el.insertBefore(dragEl, elLastChild.nextSibling);
|
|
22970
|
+
} else {
|
|
22971
|
+
el.appendChild(dragEl);
|
|
22972
|
+
}
|
|
22973
|
+
parentEl = el; // actualization
|
|
22974
|
+
|
|
22975
|
+
changed();
|
|
22976
|
+
return completed(true);
|
|
22977
|
+
}
|
|
22978
|
+
} else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
|
|
22979
|
+
// Insert to start of list
|
|
22980
|
+
var firstChild = getChild(el, 0, options, true);
|
|
22981
|
+
if (firstChild === dragEl) {
|
|
22982
|
+
return completed(false);
|
|
22983
|
+
}
|
|
22984
|
+
target = firstChild;
|
|
22985
|
+
targetRect = sortable_esm_getRect(target);
|
|
22986
|
+
if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
|
|
22987
|
+
capture();
|
|
22988
|
+
el.insertBefore(dragEl, firstChild);
|
|
22989
|
+
parentEl = el; // actualization
|
|
22990
|
+
|
|
22991
|
+
changed();
|
|
22992
|
+
return completed(true);
|
|
22993
|
+
}
|
|
22994
|
+
} else if (target.parentNode === el) {
|
|
22995
|
+
targetRect = sortable_esm_getRect(target);
|
|
22996
|
+
var direction = 0,
|
|
22997
|
+
targetBeforeFirstSwap,
|
|
22998
|
+
differentLevel = dragEl.parentNode !== el,
|
|
22999
|
+
differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
|
|
23000
|
+
side1 = vertical ? 'top' : 'left',
|
|
23001
|
+
scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
|
|
23002
|
+
scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
|
|
23003
|
+
if (lastTarget !== target) {
|
|
23004
|
+
targetBeforeFirstSwap = targetRect[side1];
|
|
23005
|
+
pastFirstInvertThresh = false;
|
|
23006
|
+
isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
|
|
23007
|
+
}
|
|
23008
|
+
direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
|
|
23009
|
+
var sibling;
|
|
23010
|
+
if (direction !== 0) {
|
|
23011
|
+
// Check if target is beside dragEl in respective direction (ignoring hidden elements)
|
|
23012
|
+
var dragIndex = sortable_esm_index(dragEl);
|
|
23013
|
+
do {
|
|
23014
|
+
dragIndex -= direction;
|
|
23015
|
+
sibling = parentEl.children[dragIndex];
|
|
23016
|
+
} while (sibling && (sortable_esm_css(sibling, 'display') === 'none' || sibling === ghostEl));
|
|
23017
|
+
}
|
|
23018
|
+
// If dragEl is already beside target: Do not insert
|
|
23019
|
+
if (direction === 0 || sibling === target) {
|
|
23020
|
+
return completed(false);
|
|
23021
|
+
}
|
|
23022
|
+
lastTarget = target;
|
|
23023
|
+
lastDirection = direction;
|
|
23024
|
+
var nextSibling = target.nextElementSibling,
|
|
23025
|
+
after = false;
|
|
23026
|
+
after = direction === 1;
|
|
23027
|
+
var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
|
|
23028
|
+
if (moveVector !== false) {
|
|
23029
|
+
if (moveVector === 1 || moveVector === -1) {
|
|
23030
|
+
after = moveVector === 1;
|
|
23031
|
+
}
|
|
23032
|
+
_silent = true;
|
|
23033
|
+
setTimeout(_unsilent, 30);
|
|
23034
|
+
capture();
|
|
23035
|
+
if (after && !nextSibling) {
|
|
23036
|
+
el.appendChild(dragEl);
|
|
23037
|
+
} else {
|
|
23038
|
+
target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
|
|
23039
|
+
}
|
|
23040
|
+
|
|
23041
|
+
// Undo chrome's scroll adjustment (has no effect on other browsers)
|
|
23042
|
+
if (scrolledPastTop) {
|
|
23043
|
+
scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
|
|
23044
|
+
}
|
|
23045
|
+
parentEl = dragEl.parentNode; // actualization
|
|
23046
|
+
|
|
23047
|
+
// must be done before animation
|
|
23048
|
+
if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
|
|
23049
|
+
targetMoveDistance = Math.abs(targetBeforeFirstSwap - sortable_esm_getRect(target)[side1]);
|
|
23050
|
+
}
|
|
23051
|
+
changed();
|
|
23052
|
+
return completed(true);
|
|
23053
|
+
}
|
|
23054
|
+
}
|
|
23055
|
+
if (el.contains(dragEl)) {
|
|
23056
|
+
return completed(false);
|
|
23057
|
+
}
|
|
23058
|
+
}
|
|
23059
|
+
return false;
|
|
23060
|
+
},
|
|
23061
|
+
_ignoreWhileAnimating: null,
|
|
23062
|
+
_offMoveEvents: function _offMoveEvents() {
|
|
23063
|
+
sortable_esm_off(document, 'mousemove', this._onTouchMove);
|
|
23064
|
+
sortable_esm_off(document, 'touchmove', this._onTouchMove);
|
|
23065
|
+
sortable_esm_off(document, 'pointermove', this._onTouchMove);
|
|
23066
|
+
sortable_esm_off(document, 'dragover', nearestEmptyInsertDetectEvent);
|
|
23067
|
+
sortable_esm_off(document, 'mousemove', nearestEmptyInsertDetectEvent);
|
|
23068
|
+
sortable_esm_off(document, 'touchmove', nearestEmptyInsertDetectEvent);
|
|
23069
|
+
},
|
|
23070
|
+
_offUpEvents: function _offUpEvents() {
|
|
23071
|
+
var ownerDocument = this.el.ownerDocument;
|
|
23072
|
+
sortable_esm_off(ownerDocument, 'mouseup', this._onDrop);
|
|
23073
|
+
sortable_esm_off(ownerDocument, 'touchend', this._onDrop);
|
|
23074
|
+
sortable_esm_off(ownerDocument, 'pointerup', this._onDrop);
|
|
23075
|
+
sortable_esm_off(ownerDocument, 'pointercancel', this._onDrop);
|
|
23076
|
+
sortable_esm_off(ownerDocument, 'touchcancel', this._onDrop);
|
|
23077
|
+
sortable_esm_off(document, 'selectstart', this);
|
|
23078
|
+
},
|
|
23079
|
+
_onDrop: function _onDrop( /**Event*/evt) {
|
|
23080
|
+
var el = this.el,
|
|
23081
|
+
options = this.options;
|
|
23082
|
+
|
|
23083
|
+
// Get the index of the dragged element within its parent
|
|
23084
|
+
sortable_esm_newIndex = sortable_esm_index(dragEl);
|
|
23085
|
+
newDraggableIndex = sortable_esm_index(dragEl, options.draggable);
|
|
23086
|
+
pluginEvent('drop', this, {
|
|
23087
|
+
evt: evt
|
|
23088
|
+
});
|
|
23089
|
+
parentEl = dragEl && dragEl.parentNode;
|
|
23090
|
+
|
|
23091
|
+
// Get again after plugin event
|
|
23092
|
+
sortable_esm_newIndex = sortable_esm_index(dragEl);
|
|
23093
|
+
newDraggableIndex = sortable_esm_index(dragEl, options.draggable);
|
|
23094
|
+
if (Sortable.eventCanceled) {
|
|
23095
|
+
this._nulling();
|
|
23096
|
+
return;
|
|
23097
|
+
}
|
|
23098
|
+
awaitingDragStarted = false;
|
|
23099
|
+
isCircumstantialInvert = false;
|
|
23100
|
+
pastFirstInvertThresh = false;
|
|
23101
|
+
clearInterval(this._loopId);
|
|
23102
|
+
clearTimeout(this._dragStartTimer);
|
|
23103
|
+
_cancelNextTick(this.cloneId);
|
|
23104
|
+
_cancelNextTick(this._dragStartId);
|
|
23105
|
+
|
|
23106
|
+
// Unbind events
|
|
23107
|
+
if (this.nativeDraggable) {
|
|
23108
|
+
sortable_esm_off(document, 'drop', this);
|
|
23109
|
+
sortable_esm_off(el, 'dragstart', this._onDragStart);
|
|
23110
|
+
}
|
|
23111
|
+
this._offMoveEvents();
|
|
23112
|
+
this._offUpEvents();
|
|
23113
|
+
if (Safari) {
|
|
23114
|
+
sortable_esm_css(document.body, 'user-select', '');
|
|
23115
|
+
}
|
|
23116
|
+
sortable_esm_css(dragEl, 'transform', '');
|
|
23117
|
+
if (evt) {
|
|
23118
|
+
if (moved) {
|
|
23119
|
+
evt.cancelable && evt.preventDefault();
|
|
23120
|
+
!options.dropBubble && evt.stopPropagation();
|
|
23121
|
+
}
|
|
23122
|
+
ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
|
|
23123
|
+
if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
|
|
23124
|
+
// Remove clone(s)
|
|
23125
|
+
cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
|
|
23126
|
+
}
|
|
23127
|
+
if (dragEl) {
|
|
23128
|
+
if (this.nativeDraggable) {
|
|
23129
|
+
sortable_esm_off(dragEl, 'dragend', this);
|
|
23130
|
+
}
|
|
23131
|
+
_disableDraggable(dragEl);
|
|
23132
|
+
dragEl.style['will-change'] = '';
|
|
23133
|
+
|
|
23134
|
+
// Remove classes
|
|
23135
|
+
// ghostClass is added in dragStarted
|
|
23136
|
+
if (moved && !awaitingDragStarted) {
|
|
23137
|
+
toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
|
|
23138
|
+
}
|
|
23139
|
+
toggleClass(dragEl, this.options.chosenClass, false);
|
|
23140
|
+
|
|
23141
|
+
// Drag stop event
|
|
23142
|
+
_dispatchEvent({
|
|
23143
|
+
sortable: this,
|
|
23144
|
+
name: 'unchoose',
|
|
23145
|
+
toEl: parentEl,
|
|
23146
|
+
newIndex: null,
|
|
23147
|
+
newDraggableIndex: null,
|
|
23148
|
+
originalEvent: evt
|
|
23149
|
+
});
|
|
23150
|
+
if (rootEl !== parentEl) {
|
|
23151
|
+
if (sortable_esm_newIndex >= 0) {
|
|
23152
|
+
// Add event
|
|
23153
|
+
_dispatchEvent({
|
|
23154
|
+
rootEl: parentEl,
|
|
23155
|
+
name: 'add',
|
|
23156
|
+
toEl: parentEl,
|
|
23157
|
+
fromEl: rootEl,
|
|
23158
|
+
originalEvent: evt
|
|
23159
|
+
});
|
|
23160
|
+
|
|
23161
|
+
// Remove event
|
|
23162
|
+
_dispatchEvent({
|
|
23163
|
+
sortable: this,
|
|
23164
|
+
name: 'remove',
|
|
23165
|
+
toEl: parentEl,
|
|
23166
|
+
originalEvent: evt
|
|
23167
|
+
});
|
|
23168
|
+
|
|
23169
|
+
// drag from one list and drop into another
|
|
23170
|
+
_dispatchEvent({
|
|
23171
|
+
rootEl: parentEl,
|
|
23172
|
+
name: 'sort',
|
|
23173
|
+
toEl: parentEl,
|
|
23174
|
+
fromEl: rootEl,
|
|
23175
|
+
originalEvent: evt
|
|
23176
|
+
});
|
|
23177
|
+
_dispatchEvent({
|
|
23178
|
+
sortable: this,
|
|
23179
|
+
name: 'sort',
|
|
23180
|
+
toEl: parentEl,
|
|
23181
|
+
originalEvent: evt
|
|
23182
|
+
});
|
|
23183
|
+
}
|
|
23184
|
+
putSortable && putSortable.save();
|
|
23185
|
+
} else {
|
|
23186
|
+
if (sortable_esm_newIndex !== oldIndex) {
|
|
23187
|
+
if (sortable_esm_newIndex >= 0) {
|
|
23188
|
+
// drag & drop within the same list
|
|
23189
|
+
_dispatchEvent({
|
|
23190
|
+
sortable: this,
|
|
23191
|
+
name: 'update',
|
|
23192
|
+
toEl: parentEl,
|
|
23193
|
+
originalEvent: evt
|
|
23194
|
+
});
|
|
23195
|
+
_dispatchEvent({
|
|
23196
|
+
sortable: this,
|
|
23197
|
+
name: 'sort',
|
|
23198
|
+
toEl: parentEl,
|
|
23199
|
+
originalEvent: evt
|
|
23200
|
+
});
|
|
23201
|
+
}
|
|
23202
|
+
}
|
|
23203
|
+
}
|
|
23204
|
+
if (Sortable.active) {
|
|
23205
|
+
/* jshint eqnull:true */
|
|
23206
|
+
if (sortable_esm_newIndex == null || sortable_esm_newIndex === -1) {
|
|
23207
|
+
sortable_esm_newIndex = oldIndex;
|
|
23208
|
+
newDraggableIndex = oldDraggableIndex;
|
|
23209
|
+
}
|
|
23210
|
+
_dispatchEvent({
|
|
23211
|
+
sortable: this,
|
|
23212
|
+
name: 'end',
|
|
23213
|
+
toEl: parentEl,
|
|
23214
|
+
originalEvent: evt
|
|
23215
|
+
});
|
|
23216
|
+
|
|
23217
|
+
// Save sorting
|
|
23218
|
+
this.save();
|
|
23219
|
+
}
|
|
23220
|
+
}
|
|
23221
|
+
}
|
|
23222
|
+
this._nulling();
|
|
23223
|
+
},
|
|
23224
|
+
_nulling: function _nulling() {
|
|
23225
|
+
pluginEvent('nulling', this);
|
|
23226
|
+
rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = sortable_esm_newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
|
|
23227
|
+
savedInputChecked.forEach(function (el) {
|
|
23228
|
+
el.checked = true;
|
|
23229
|
+
});
|
|
23230
|
+
savedInputChecked.length = lastDx = lastDy = 0;
|
|
23231
|
+
},
|
|
23232
|
+
handleEvent: function handleEvent( /**Event*/evt) {
|
|
23233
|
+
switch (evt.type) {
|
|
23234
|
+
case 'drop':
|
|
23235
|
+
case 'dragend':
|
|
23236
|
+
this._onDrop(evt);
|
|
23237
|
+
break;
|
|
23238
|
+
case 'dragenter':
|
|
23239
|
+
case 'dragover':
|
|
23240
|
+
if (dragEl) {
|
|
23241
|
+
this._onDragOver(evt);
|
|
23242
|
+
_globalDragOver(evt);
|
|
23243
|
+
}
|
|
23244
|
+
break;
|
|
23245
|
+
case 'selectstart':
|
|
23246
|
+
evt.preventDefault();
|
|
23247
|
+
break;
|
|
23248
|
+
}
|
|
23249
|
+
},
|
|
23250
|
+
/**
|
|
23251
|
+
* Serializes the item into an array of string.
|
|
23252
|
+
* @returns {String[]}
|
|
23253
|
+
*/
|
|
23254
|
+
toArray: function toArray() {
|
|
23255
|
+
var order = [],
|
|
23256
|
+
el,
|
|
23257
|
+
children = this.el.children,
|
|
23258
|
+
i = 0,
|
|
23259
|
+
n = children.length,
|
|
23260
|
+
options = this.options;
|
|
23261
|
+
for (; i < n; i++) {
|
|
23262
|
+
el = children[i];
|
|
23263
|
+
if (closest(el, options.draggable, this.el, false)) {
|
|
23264
|
+
order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
|
|
23265
|
+
}
|
|
23266
|
+
}
|
|
23267
|
+
return order;
|
|
23268
|
+
},
|
|
23269
|
+
/**
|
|
23270
|
+
* Sorts the elements according to the array.
|
|
23271
|
+
* @param {String[]} order order of the items
|
|
23272
|
+
*/
|
|
23273
|
+
sort: function sort(order, useAnimation) {
|
|
23274
|
+
var items = {},
|
|
23275
|
+
rootEl = this.el;
|
|
23276
|
+
this.toArray().forEach(function (id, i) {
|
|
23277
|
+
var el = rootEl.children[i];
|
|
23278
|
+
if (closest(el, this.options.draggable, rootEl, false)) {
|
|
23279
|
+
items[id] = el;
|
|
23280
|
+
}
|
|
23281
|
+
}, this);
|
|
23282
|
+
useAnimation && this.captureAnimationState();
|
|
23283
|
+
order.forEach(function (id) {
|
|
23284
|
+
if (items[id]) {
|
|
23285
|
+
rootEl.removeChild(items[id]);
|
|
23286
|
+
rootEl.appendChild(items[id]);
|
|
23287
|
+
}
|
|
23288
|
+
});
|
|
23289
|
+
useAnimation && this.animateAll();
|
|
23290
|
+
},
|
|
23291
|
+
/**
|
|
23292
|
+
* Save the current sorting
|
|
23293
|
+
*/
|
|
23294
|
+
save: function save() {
|
|
23295
|
+
var store = this.options.store;
|
|
23296
|
+
store && store.set && store.set(this);
|
|
23297
|
+
},
|
|
23298
|
+
/**
|
|
23299
|
+
* 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.
|
|
23300
|
+
* @param {HTMLElement} el
|
|
23301
|
+
* @param {String} [selector] default: `options.draggable`
|
|
23302
|
+
* @returns {HTMLElement|null}
|
|
23303
|
+
*/
|
|
23304
|
+
closest: function closest$1(el, selector) {
|
|
23305
|
+
return closest(el, selector || this.options.draggable, this.el, false);
|
|
23306
|
+
},
|
|
23307
|
+
/**
|
|
23308
|
+
* Set/get option
|
|
23309
|
+
* @param {string} name
|
|
23310
|
+
* @param {*} [value]
|
|
23311
|
+
* @returns {*}
|
|
23312
|
+
*/
|
|
23313
|
+
option: function option(name, value) {
|
|
23314
|
+
var options = this.options;
|
|
23315
|
+
if (value === void 0) {
|
|
23316
|
+
return options[name];
|
|
23317
|
+
} else {
|
|
23318
|
+
var modifiedValue = PluginManager.modifyOption(this, name, value);
|
|
23319
|
+
if (typeof modifiedValue !== 'undefined') {
|
|
23320
|
+
options[name] = modifiedValue;
|
|
23321
|
+
} else {
|
|
23322
|
+
options[name] = value;
|
|
23323
|
+
}
|
|
23324
|
+
if (name === 'group') {
|
|
23325
|
+
_prepareGroup(options);
|
|
23326
|
+
}
|
|
23327
|
+
}
|
|
23328
|
+
},
|
|
23329
|
+
/**
|
|
23330
|
+
* Destroy
|
|
23331
|
+
*/
|
|
23332
|
+
destroy: function destroy() {
|
|
23333
|
+
pluginEvent('destroy', this);
|
|
23334
|
+
var el = this.el;
|
|
23335
|
+
el[expando] = null;
|
|
23336
|
+
sortable_esm_off(el, 'mousedown', this._onTapStart);
|
|
23337
|
+
sortable_esm_off(el, 'touchstart', this._onTapStart);
|
|
23338
|
+
sortable_esm_off(el, 'pointerdown', this._onTapStart);
|
|
23339
|
+
if (this.nativeDraggable) {
|
|
23340
|
+
sortable_esm_off(el, 'dragover', this);
|
|
23341
|
+
sortable_esm_off(el, 'dragenter', this);
|
|
23342
|
+
}
|
|
23343
|
+
// Remove draggable attributes
|
|
23344
|
+
Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
|
|
23345
|
+
el.removeAttribute('draggable');
|
|
23346
|
+
});
|
|
23347
|
+
this._onDrop();
|
|
23348
|
+
this._disableDelayedDragEvents();
|
|
23349
|
+
sortables.splice(sortables.indexOf(this.el), 1);
|
|
23350
|
+
this.el = el = null;
|
|
23351
|
+
},
|
|
23352
|
+
_hideClone: function _hideClone() {
|
|
23353
|
+
if (!cloneHidden) {
|
|
23354
|
+
pluginEvent('hideClone', this);
|
|
23355
|
+
if (Sortable.eventCanceled) return;
|
|
23356
|
+
sortable_esm_css(cloneEl, 'display', 'none');
|
|
23357
|
+
if (this.options.removeCloneOnHide && cloneEl.parentNode) {
|
|
23358
|
+
cloneEl.parentNode.removeChild(cloneEl);
|
|
23359
|
+
}
|
|
23360
|
+
cloneHidden = true;
|
|
23361
|
+
}
|
|
23362
|
+
},
|
|
23363
|
+
_showClone: function _showClone(putSortable) {
|
|
23364
|
+
if (putSortable.lastPutMode !== 'clone') {
|
|
23365
|
+
this._hideClone();
|
|
23366
|
+
return;
|
|
23367
|
+
}
|
|
23368
|
+
if (cloneHidden) {
|
|
23369
|
+
pluginEvent('showClone', this);
|
|
23370
|
+
if (Sortable.eventCanceled) return;
|
|
23371
|
+
|
|
23372
|
+
// show clone at dragEl or original position
|
|
23373
|
+
if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
|
|
23374
|
+
rootEl.insertBefore(cloneEl, dragEl);
|
|
23375
|
+
} else if (nextEl) {
|
|
23376
|
+
rootEl.insertBefore(cloneEl, nextEl);
|
|
23377
|
+
} else {
|
|
23378
|
+
rootEl.appendChild(cloneEl);
|
|
23379
|
+
}
|
|
23380
|
+
if (this.options.group.revertClone) {
|
|
23381
|
+
this.animate(dragEl, cloneEl);
|
|
23382
|
+
}
|
|
23383
|
+
sortable_esm_css(cloneEl, 'display', '');
|
|
23384
|
+
cloneHidden = false;
|
|
23385
|
+
}
|
|
23386
|
+
}
|
|
23387
|
+
};
|
|
23388
|
+
function _globalDragOver( /**Event*/evt) {
|
|
23389
|
+
if (evt.dataTransfer) {
|
|
23390
|
+
evt.dataTransfer.dropEffect = 'move';
|
|
23391
|
+
}
|
|
23392
|
+
evt.cancelable && evt.preventDefault();
|
|
23393
|
+
}
|
|
23394
|
+
function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
|
|
23395
|
+
var evt,
|
|
23396
|
+
sortable = fromEl[expando],
|
|
23397
|
+
onMoveFn = sortable.options.onMove,
|
|
23398
|
+
retVal;
|
|
23399
|
+
// Support for new CustomEvent feature
|
|
23400
|
+
if (window.CustomEvent && !IE11OrLess && !Edge) {
|
|
23401
|
+
evt = new CustomEvent('move', {
|
|
23402
|
+
bubbles: true,
|
|
23403
|
+
cancelable: true
|
|
23404
|
+
});
|
|
23405
|
+
} else {
|
|
23406
|
+
evt = document.createEvent('Event');
|
|
23407
|
+
evt.initEvent('move', true, true);
|
|
23408
|
+
}
|
|
23409
|
+
evt.to = toEl;
|
|
23410
|
+
evt.from = fromEl;
|
|
23411
|
+
evt.dragged = dragEl;
|
|
23412
|
+
evt.draggedRect = dragRect;
|
|
23413
|
+
evt.related = targetEl || toEl;
|
|
23414
|
+
evt.relatedRect = targetRect || sortable_esm_getRect(toEl);
|
|
23415
|
+
evt.willInsertAfter = willInsertAfter;
|
|
23416
|
+
evt.originalEvent = originalEvent;
|
|
23417
|
+
fromEl.dispatchEvent(evt);
|
|
23418
|
+
if (onMoveFn) {
|
|
23419
|
+
retVal = onMoveFn.call(sortable, evt, originalEvent);
|
|
23420
|
+
}
|
|
23421
|
+
return retVal;
|
|
23422
|
+
}
|
|
23423
|
+
function _disableDraggable(el) {
|
|
23424
|
+
el.draggable = false;
|
|
23425
|
+
}
|
|
23426
|
+
function _unsilent() {
|
|
23427
|
+
_silent = false;
|
|
23428
|
+
}
|
|
23429
|
+
function _ghostIsFirst(evt, vertical, sortable) {
|
|
23430
|
+
var firstElRect = sortable_esm_getRect(getChild(sortable.el, 0, sortable.options, true));
|
|
23431
|
+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
|
|
23432
|
+
var spacer = 10;
|
|
23433
|
+
return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
|
|
23434
|
+
}
|
|
23435
|
+
function _ghostIsLast(evt, vertical, sortable) {
|
|
23436
|
+
var lastElRect = sortable_esm_getRect(lastChild(sortable.el, sortable.options.draggable));
|
|
23437
|
+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
|
|
23438
|
+
var spacer = 10;
|
|
23439
|
+
return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
|
|
23440
|
+
}
|
|
23441
|
+
function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
|
|
23442
|
+
var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
|
|
23443
|
+
targetLength = vertical ? targetRect.height : targetRect.width,
|
|
23444
|
+
targetS1 = vertical ? targetRect.top : targetRect.left,
|
|
23445
|
+
targetS2 = vertical ? targetRect.bottom : targetRect.right,
|
|
23446
|
+
invert = false;
|
|
23447
|
+
if (!invertSwap) {
|
|
23448
|
+
// Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
|
|
23449
|
+
if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
|
|
23450
|
+
// multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
|
|
23451
|
+
// check if past first invert threshold on side opposite of lastDirection
|
|
23452
|
+
if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
|
|
23453
|
+
// past first invert threshold, do not restrict inverted threshold to dragEl shadow
|
|
23454
|
+
pastFirstInvertThresh = true;
|
|
23455
|
+
}
|
|
23456
|
+
if (!pastFirstInvertThresh) {
|
|
23457
|
+
// dragEl shadow (target move distance shadow)
|
|
23458
|
+
if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
|
|
23459
|
+
: mouseOnAxis > targetS2 - targetMoveDistance) {
|
|
23460
|
+
return -lastDirection;
|
|
23461
|
+
}
|
|
23462
|
+
} else {
|
|
23463
|
+
invert = true;
|
|
23464
|
+
}
|
|
23465
|
+
} else {
|
|
23466
|
+
// Regular
|
|
23467
|
+
if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
|
|
23468
|
+
return _getInsertDirection(target);
|
|
23469
|
+
}
|
|
23470
|
+
}
|
|
23471
|
+
}
|
|
23472
|
+
invert = invert || invertSwap;
|
|
23473
|
+
if (invert) {
|
|
23474
|
+
// Invert of regular
|
|
23475
|
+
if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
|
|
23476
|
+
return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
|
|
23477
|
+
}
|
|
23478
|
+
}
|
|
23479
|
+
return 0;
|
|
23480
|
+
}
|
|
23481
|
+
|
|
23482
|
+
/**
|
|
23483
|
+
* Gets the direction dragEl must be swapped relative to target in order to make it
|
|
23484
|
+
* seem that dragEl has been "inserted" into that element's position
|
|
23485
|
+
* @param {HTMLElement} target The target whose position dragEl is being inserted at
|
|
23486
|
+
* @return {Number} Direction dragEl must be swapped
|
|
23487
|
+
*/
|
|
23488
|
+
function _getInsertDirection(target) {
|
|
23489
|
+
if (sortable_esm_index(dragEl) < sortable_esm_index(target)) {
|
|
23490
|
+
return 1;
|
|
23491
|
+
} else {
|
|
23492
|
+
return -1;
|
|
23493
|
+
}
|
|
23494
|
+
}
|
|
23495
|
+
|
|
23496
|
+
/**
|
|
23497
|
+
* Generate id
|
|
23498
|
+
* @param {HTMLElement} el
|
|
23499
|
+
* @returns {String}
|
|
23500
|
+
* @private
|
|
23501
|
+
*/
|
|
23502
|
+
function _generateId(el) {
|
|
23503
|
+
var str = el.tagName + el.className + el.src + el.href + el.textContent,
|
|
23504
|
+
i = str.length,
|
|
23505
|
+
sum = 0;
|
|
23506
|
+
while (i--) {
|
|
23507
|
+
sum += str.charCodeAt(i);
|
|
23508
|
+
}
|
|
23509
|
+
return sum.toString(36);
|
|
23510
|
+
}
|
|
23511
|
+
function _saveInputCheckedState(root) {
|
|
23512
|
+
savedInputChecked.length = 0;
|
|
23513
|
+
var inputs = root.getElementsByTagName('input');
|
|
23514
|
+
var idx = inputs.length;
|
|
23515
|
+
while (idx--) {
|
|
23516
|
+
var el = inputs[idx];
|
|
23517
|
+
el.checked && savedInputChecked.push(el);
|
|
23518
|
+
}
|
|
23519
|
+
}
|
|
23520
|
+
function _nextTick(fn) {
|
|
23521
|
+
return setTimeout(fn, 0);
|
|
23522
|
+
}
|
|
23523
|
+
function _cancelNextTick(id) {
|
|
23524
|
+
return clearTimeout(id);
|
|
23525
|
+
}
|
|
23526
|
+
|
|
23527
|
+
// Fixed #973:
|
|
23528
|
+
if (documentExists) {
|
|
23529
|
+
sortable_esm_on(document, 'touchmove', function (evt) {
|
|
23530
|
+
if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
|
|
23531
|
+
evt.preventDefault();
|
|
23532
|
+
}
|
|
23533
|
+
});
|
|
23534
|
+
}
|
|
23535
|
+
|
|
23536
|
+
// Export utils
|
|
23537
|
+
Sortable.utils = {
|
|
23538
|
+
on: sortable_esm_on,
|
|
23539
|
+
off: sortable_esm_off,
|
|
23540
|
+
css: sortable_esm_css,
|
|
23541
|
+
find: sortable_esm_find,
|
|
23542
|
+
is: function is(el, selector) {
|
|
23543
|
+
return !!closest(el, selector, el, false);
|
|
23544
|
+
},
|
|
23545
|
+
extend: extend,
|
|
23546
|
+
throttle: sortable_esm_throttle,
|
|
23547
|
+
closest: closest,
|
|
23548
|
+
toggleClass: toggleClass,
|
|
23549
|
+
clone: clone,
|
|
23550
|
+
index: sortable_esm_index,
|
|
23551
|
+
nextTick: _nextTick,
|
|
23552
|
+
cancelNextTick: _cancelNextTick,
|
|
23553
|
+
detectDirection: _detectDirection,
|
|
23554
|
+
getChild: getChild,
|
|
23555
|
+
expando: expando
|
|
23556
|
+
};
|
|
23557
|
+
|
|
23558
|
+
/**
|
|
23559
|
+
* Get the Sortable instance of an element
|
|
23560
|
+
* @param {HTMLElement} element The element
|
|
23561
|
+
* @return {Sortable|undefined} The instance of Sortable
|
|
23562
|
+
*/
|
|
23563
|
+
Sortable.get = function (element) {
|
|
23564
|
+
return element[expando];
|
|
23565
|
+
};
|
|
23566
|
+
|
|
23567
|
+
/**
|
|
23568
|
+
* Mount a plugin to Sortable
|
|
23569
|
+
* @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
|
|
23570
|
+
*/
|
|
23571
|
+
Sortable.mount = function () {
|
|
23572
|
+
for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23573
|
+
plugins[_key] = arguments[_key];
|
|
23574
|
+
}
|
|
23575
|
+
if (plugins[0].constructor === Array) plugins = plugins[0];
|
|
23576
|
+
plugins.forEach(function (plugin) {
|
|
23577
|
+
if (!plugin.prototype || !plugin.prototype.constructor) {
|
|
23578
|
+
throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
|
|
23579
|
+
}
|
|
23580
|
+
if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
|
|
23581
|
+
PluginManager.mount(plugin);
|
|
23582
|
+
});
|
|
23583
|
+
};
|
|
23584
|
+
|
|
23585
|
+
/**
|
|
23586
|
+
* Create sortable instance
|
|
23587
|
+
* @param {HTMLElement} el
|
|
23588
|
+
* @param {Object} [options]
|
|
23589
|
+
*/
|
|
23590
|
+
Sortable.create = function (el, options) {
|
|
23591
|
+
return new Sortable(el, options);
|
|
23592
|
+
};
|
|
23593
|
+
|
|
23594
|
+
// Export
|
|
23595
|
+
Sortable.version = version;
|
|
23596
|
+
|
|
23597
|
+
var autoScrolls = [],
|
|
23598
|
+
sortable_esm_scrollEl,
|
|
23599
|
+
scrollRootEl,
|
|
23600
|
+
scrolling = false,
|
|
23601
|
+
lastAutoScrollX,
|
|
23602
|
+
lastAutoScrollY,
|
|
23603
|
+
touchEvt$1,
|
|
23604
|
+
pointerElemChangedInterval;
|
|
23605
|
+
function AutoScrollPlugin() {
|
|
23606
|
+
function AutoScroll() {
|
|
23607
|
+
this.defaults = {
|
|
23608
|
+
scroll: true,
|
|
23609
|
+
forceAutoScrollFallback: false,
|
|
23610
|
+
scrollSensitivity: 30,
|
|
23611
|
+
scrollSpeed: 10,
|
|
23612
|
+
bubbleScroll: true
|
|
23613
|
+
};
|
|
23614
|
+
|
|
23615
|
+
// Bind all private methods
|
|
23616
|
+
for (var fn in this) {
|
|
23617
|
+
if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
|
|
23618
|
+
this[fn] = this[fn].bind(this);
|
|
23619
|
+
}
|
|
23620
|
+
}
|
|
23621
|
+
}
|
|
23622
|
+
AutoScroll.prototype = {
|
|
23623
|
+
dragStarted: function dragStarted(_ref) {
|
|
23624
|
+
var originalEvent = _ref.originalEvent;
|
|
23625
|
+
if (this.sortable.nativeDraggable) {
|
|
23626
|
+
sortable_esm_on(document, 'dragover', this._handleAutoScroll);
|
|
23627
|
+
} else {
|
|
23628
|
+
if (this.options.supportPointer) {
|
|
23629
|
+
sortable_esm_on(document, 'pointermove', this._handleFallbackAutoScroll);
|
|
23630
|
+
} else if (originalEvent.touches) {
|
|
23631
|
+
sortable_esm_on(document, 'touchmove', this._handleFallbackAutoScroll);
|
|
23632
|
+
} else {
|
|
23633
|
+
sortable_esm_on(document, 'mousemove', this._handleFallbackAutoScroll);
|
|
23634
|
+
}
|
|
23635
|
+
}
|
|
23636
|
+
},
|
|
23637
|
+
dragOverCompleted: function dragOverCompleted(_ref2) {
|
|
23638
|
+
var originalEvent = _ref2.originalEvent;
|
|
23639
|
+
// For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
|
|
23640
|
+
if (!this.options.dragOverBubble && !originalEvent.rootEl) {
|
|
23641
|
+
this._handleAutoScroll(originalEvent);
|
|
23642
|
+
}
|
|
23643
|
+
},
|
|
23644
|
+
drop: function drop() {
|
|
23645
|
+
if (this.sortable.nativeDraggable) {
|
|
23646
|
+
sortable_esm_off(document, 'dragover', this._handleAutoScroll);
|
|
23647
|
+
} else {
|
|
23648
|
+
sortable_esm_off(document, 'pointermove', this._handleFallbackAutoScroll);
|
|
23649
|
+
sortable_esm_off(document, 'touchmove', this._handleFallbackAutoScroll);
|
|
23650
|
+
sortable_esm_off(document, 'mousemove', this._handleFallbackAutoScroll);
|
|
23651
|
+
}
|
|
23652
|
+
clearPointerElemChangedInterval();
|
|
23653
|
+
clearAutoScrolls();
|
|
23654
|
+
cancelThrottle();
|
|
23655
|
+
},
|
|
23656
|
+
nulling: function nulling() {
|
|
23657
|
+
touchEvt$1 = scrollRootEl = sortable_esm_scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
|
|
23658
|
+
autoScrolls.length = 0;
|
|
23659
|
+
},
|
|
23660
|
+
_handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
|
|
23661
|
+
this._handleAutoScroll(evt, true);
|
|
23662
|
+
},
|
|
23663
|
+
_handleAutoScroll: function _handleAutoScroll(evt, fallback) {
|
|
23664
|
+
var _this = this;
|
|
23665
|
+
var x = (evt.touches ? evt.touches[0] : evt).clientX,
|
|
23666
|
+
y = (evt.touches ? evt.touches[0] : evt).clientY,
|
|
23667
|
+
elem = document.elementFromPoint(x, y);
|
|
23668
|
+
touchEvt$1 = evt;
|
|
23669
|
+
|
|
23670
|
+
// IE does not seem to have native autoscroll,
|
|
23671
|
+
// Edge's autoscroll seems too conditional,
|
|
23672
|
+
// MACOS Safari does not have autoscroll,
|
|
23673
|
+
// Firefox and Chrome are good
|
|
23674
|
+
if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
|
|
23675
|
+
autoScroll(evt, this.options, elem, fallback);
|
|
23676
|
+
|
|
23677
|
+
// Listener for pointer element change
|
|
23678
|
+
var ogElemScroller = getParentAutoScrollElement(elem, true);
|
|
23679
|
+
if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
|
|
23680
|
+
pointerElemChangedInterval && clearPointerElemChangedInterval();
|
|
23681
|
+
// Detect for pointer elem change, emulating native DnD behaviour
|
|
23682
|
+
pointerElemChangedInterval = setInterval(function () {
|
|
23683
|
+
var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
|
|
23684
|
+
if (newElem !== ogElemScroller) {
|
|
23685
|
+
ogElemScroller = newElem;
|
|
23686
|
+
clearAutoScrolls();
|
|
23687
|
+
}
|
|
23688
|
+
autoScroll(evt, _this.options, newElem, fallback);
|
|
23689
|
+
}, 10);
|
|
23690
|
+
lastAutoScrollX = x;
|
|
23691
|
+
lastAutoScrollY = y;
|
|
23692
|
+
}
|
|
23693
|
+
} else {
|
|
23694
|
+
// if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
|
|
23695
|
+
if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
|
|
23696
|
+
clearAutoScrolls();
|
|
23697
|
+
return;
|
|
23698
|
+
}
|
|
23699
|
+
autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
|
|
23700
|
+
}
|
|
23701
|
+
}
|
|
23702
|
+
};
|
|
23703
|
+
return sortable_esm_extends(AutoScroll, {
|
|
23704
|
+
pluginName: 'scroll',
|
|
23705
|
+
initializeByDefault: true
|
|
23706
|
+
});
|
|
23707
|
+
}
|
|
23708
|
+
function clearAutoScrolls() {
|
|
23709
|
+
autoScrolls.forEach(function (autoScroll) {
|
|
23710
|
+
clearInterval(autoScroll.pid);
|
|
23711
|
+
});
|
|
23712
|
+
autoScrolls = [];
|
|
23713
|
+
}
|
|
23714
|
+
function clearPointerElemChangedInterval() {
|
|
23715
|
+
clearInterval(pointerElemChangedInterval);
|
|
23716
|
+
}
|
|
23717
|
+
var autoScroll = sortable_esm_throttle(function (evt, options, rootEl, isFallback) {
|
|
23718
|
+
// Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
|
|
23719
|
+
if (!options.scroll) return;
|
|
23720
|
+
var x = (evt.touches ? evt.touches[0] : evt).clientX,
|
|
23721
|
+
y = (evt.touches ? evt.touches[0] : evt).clientY,
|
|
23722
|
+
sens = options.scrollSensitivity,
|
|
23723
|
+
speed = options.scrollSpeed,
|
|
23724
|
+
winScroller = getWindowScrollingElement();
|
|
23725
|
+
var scrollThisInstance = false,
|
|
23726
|
+
scrollCustomFn;
|
|
23727
|
+
|
|
23728
|
+
// New scroll root, set scrollEl
|
|
23729
|
+
if (scrollRootEl !== rootEl) {
|
|
23730
|
+
scrollRootEl = rootEl;
|
|
23731
|
+
clearAutoScrolls();
|
|
23732
|
+
sortable_esm_scrollEl = options.scroll;
|
|
23733
|
+
scrollCustomFn = options.scrollFn;
|
|
23734
|
+
if (sortable_esm_scrollEl === true) {
|
|
23735
|
+
sortable_esm_scrollEl = getParentAutoScrollElement(rootEl, true);
|
|
23736
|
+
}
|
|
23737
|
+
}
|
|
23738
|
+
var layersOut = 0;
|
|
23739
|
+
var currentParent = sortable_esm_scrollEl;
|
|
23740
|
+
do {
|
|
23741
|
+
var el = currentParent,
|
|
23742
|
+
rect = sortable_esm_getRect(el),
|
|
23743
|
+
top = rect.top,
|
|
23744
|
+
bottom = rect.bottom,
|
|
23745
|
+
left = rect.left,
|
|
23746
|
+
right = rect.right,
|
|
23747
|
+
width = rect.width,
|
|
23748
|
+
height = rect.height,
|
|
23749
|
+
canScrollX = void 0,
|
|
23750
|
+
canScrollY = void 0,
|
|
23751
|
+
scrollWidth = el.scrollWidth,
|
|
23752
|
+
scrollHeight = el.scrollHeight,
|
|
23753
|
+
elCSS = sortable_esm_css(el),
|
|
23754
|
+
scrollPosX = el.scrollLeft,
|
|
23755
|
+
scrollPosY = el.scrollTop;
|
|
23756
|
+
if (el === winScroller) {
|
|
23757
|
+
canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
|
|
23758
|
+
canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
|
|
23759
|
+
} else {
|
|
23760
|
+
canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
|
|
23761
|
+
canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
|
|
23762
|
+
}
|
|
23763
|
+
var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
|
|
23764
|
+
var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
|
|
23765
|
+
if (!autoScrolls[layersOut]) {
|
|
23766
|
+
for (var i = 0; i <= layersOut; i++) {
|
|
23767
|
+
if (!autoScrolls[i]) {
|
|
23768
|
+
autoScrolls[i] = {};
|
|
23769
|
+
}
|
|
23770
|
+
}
|
|
23771
|
+
}
|
|
23772
|
+
if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
|
|
23773
|
+
autoScrolls[layersOut].el = el;
|
|
23774
|
+
autoScrolls[layersOut].vx = vx;
|
|
23775
|
+
autoScrolls[layersOut].vy = vy;
|
|
23776
|
+
clearInterval(autoScrolls[layersOut].pid);
|
|
23777
|
+
if (vx != 0 || vy != 0) {
|
|
23778
|
+
scrollThisInstance = true;
|
|
23779
|
+
/* jshint loopfunc:true */
|
|
23780
|
+
autoScrolls[layersOut].pid = setInterval(function () {
|
|
23781
|
+
// emulate drag over during autoscroll (fallback), emulating native DnD behaviour
|
|
23782
|
+
if (isFallback && this.layer === 0) {
|
|
23783
|
+
Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
|
|
23784
|
+
}
|
|
23785
|
+
var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
|
|
23786
|
+
var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
|
|
23787
|
+
if (typeof scrollCustomFn === 'function') {
|
|
23788
|
+
if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
|
|
23789
|
+
return;
|
|
23790
|
+
}
|
|
23791
|
+
}
|
|
23792
|
+
scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
|
|
23793
|
+
}.bind({
|
|
23794
|
+
layer: layersOut
|
|
23795
|
+
}), 24);
|
|
23796
|
+
}
|
|
23797
|
+
}
|
|
23798
|
+
layersOut++;
|
|
23799
|
+
} while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
|
|
23800
|
+
scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
|
|
23801
|
+
}, 30);
|
|
23802
|
+
|
|
23803
|
+
var drop = function drop(_ref) {
|
|
23804
|
+
var originalEvent = _ref.originalEvent,
|
|
23805
|
+
putSortable = _ref.putSortable,
|
|
23806
|
+
dragEl = _ref.dragEl,
|
|
23807
|
+
activeSortable = _ref.activeSortable,
|
|
23808
|
+
dispatchSortableEvent = _ref.dispatchSortableEvent,
|
|
23809
|
+
hideGhostForTarget = _ref.hideGhostForTarget,
|
|
23810
|
+
unhideGhostForTarget = _ref.unhideGhostForTarget;
|
|
23811
|
+
if (!originalEvent) return;
|
|
23812
|
+
var toSortable = putSortable || activeSortable;
|
|
23813
|
+
hideGhostForTarget();
|
|
23814
|
+
var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
|
|
23815
|
+
var target = document.elementFromPoint(touch.clientX, touch.clientY);
|
|
23816
|
+
unhideGhostForTarget();
|
|
23817
|
+
if (toSortable && !toSortable.el.contains(target)) {
|
|
23818
|
+
dispatchSortableEvent('spill');
|
|
23819
|
+
this.onSpill({
|
|
23820
|
+
dragEl: dragEl,
|
|
23821
|
+
putSortable: putSortable
|
|
23822
|
+
});
|
|
23823
|
+
}
|
|
23824
|
+
};
|
|
23825
|
+
function Revert() {}
|
|
23826
|
+
Revert.prototype = {
|
|
23827
|
+
startIndex: null,
|
|
23828
|
+
dragStart: function dragStart(_ref2) {
|
|
23829
|
+
var oldDraggableIndex = _ref2.oldDraggableIndex;
|
|
23830
|
+
this.startIndex = oldDraggableIndex;
|
|
23831
|
+
},
|
|
23832
|
+
onSpill: function onSpill(_ref3) {
|
|
23833
|
+
var dragEl = _ref3.dragEl,
|
|
23834
|
+
putSortable = _ref3.putSortable;
|
|
23835
|
+
this.sortable.captureAnimationState();
|
|
23836
|
+
if (putSortable) {
|
|
23837
|
+
putSortable.captureAnimationState();
|
|
23838
|
+
}
|
|
23839
|
+
var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
|
|
23840
|
+
if (nextSibling) {
|
|
23841
|
+
this.sortable.el.insertBefore(dragEl, nextSibling);
|
|
23842
|
+
} else {
|
|
23843
|
+
this.sortable.el.appendChild(dragEl);
|
|
23844
|
+
}
|
|
23845
|
+
this.sortable.animateAll();
|
|
23846
|
+
if (putSortable) {
|
|
23847
|
+
putSortable.animateAll();
|
|
23848
|
+
}
|
|
23849
|
+
},
|
|
23850
|
+
drop: drop
|
|
23851
|
+
};
|
|
23852
|
+
sortable_esm_extends(Revert, {
|
|
23853
|
+
pluginName: 'revertOnSpill'
|
|
23854
|
+
});
|
|
23855
|
+
function Remove() {}
|
|
23856
|
+
Remove.prototype = {
|
|
23857
|
+
onSpill: function onSpill(_ref4) {
|
|
23858
|
+
var dragEl = _ref4.dragEl,
|
|
23859
|
+
putSortable = _ref4.putSortable;
|
|
23860
|
+
var parentSortable = putSortable || this.sortable;
|
|
23861
|
+
parentSortable.captureAnimationState();
|
|
23862
|
+
dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
|
|
23863
|
+
parentSortable.animateAll();
|
|
23864
|
+
},
|
|
23865
|
+
drop: drop
|
|
23866
|
+
};
|
|
23867
|
+
sortable_esm_extends(Remove, {
|
|
23868
|
+
pluginName: 'removeOnSpill'
|
|
23869
|
+
});
|
|
23870
|
+
|
|
23871
|
+
var lastSwapEl;
|
|
23872
|
+
function SwapPlugin() {
|
|
23873
|
+
function Swap() {
|
|
23874
|
+
this.defaults = {
|
|
23875
|
+
swapClass: 'sortable-swap-highlight'
|
|
23876
|
+
};
|
|
23877
|
+
}
|
|
23878
|
+
Swap.prototype = {
|
|
23879
|
+
dragStart: function dragStart(_ref) {
|
|
23880
|
+
var dragEl = _ref.dragEl;
|
|
23881
|
+
lastSwapEl = dragEl;
|
|
23882
|
+
},
|
|
23883
|
+
dragOverValid: function dragOverValid(_ref2) {
|
|
23884
|
+
var completed = _ref2.completed,
|
|
23885
|
+
target = _ref2.target,
|
|
23886
|
+
onMove = _ref2.onMove,
|
|
23887
|
+
activeSortable = _ref2.activeSortable,
|
|
23888
|
+
changed = _ref2.changed,
|
|
23889
|
+
cancel = _ref2.cancel;
|
|
23890
|
+
if (!activeSortable.options.swap) return;
|
|
23891
|
+
var el = this.sortable.el,
|
|
23892
|
+
options = this.options;
|
|
23893
|
+
if (target && target !== el) {
|
|
23894
|
+
var prevSwapEl = lastSwapEl;
|
|
23895
|
+
if (onMove(target) !== false) {
|
|
23896
|
+
toggleClass(target, options.swapClass, true);
|
|
23897
|
+
lastSwapEl = target;
|
|
23898
|
+
} else {
|
|
23899
|
+
lastSwapEl = null;
|
|
23900
|
+
}
|
|
23901
|
+
if (prevSwapEl && prevSwapEl !== lastSwapEl) {
|
|
23902
|
+
toggleClass(prevSwapEl, options.swapClass, false);
|
|
23903
|
+
}
|
|
23904
|
+
}
|
|
23905
|
+
changed();
|
|
23906
|
+
completed(true);
|
|
23907
|
+
cancel();
|
|
23908
|
+
},
|
|
23909
|
+
drop: function drop(_ref3) {
|
|
23910
|
+
var activeSortable = _ref3.activeSortable,
|
|
23911
|
+
putSortable = _ref3.putSortable,
|
|
23912
|
+
dragEl = _ref3.dragEl;
|
|
23913
|
+
var toSortable = putSortable || this.sortable;
|
|
23914
|
+
var options = this.options;
|
|
23915
|
+
lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
|
|
23916
|
+
if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
|
|
23917
|
+
if (dragEl !== lastSwapEl) {
|
|
23918
|
+
toSortable.captureAnimationState();
|
|
23919
|
+
if (toSortable !== activeSortable) activeSortable.captureAnimationState();
|
|
23920
|
+
swapNodes(dragEl, lastSwapEl);
|
|
23921
|
+
toSortable.animateAll();
|
|
23922
|
+
if (toSortable !== activeSortable) activeSortable.animateAll();
|
|
23923
|
+
}
|
|
23924
|
+
}
|
|
23925
|
+
},
|
|
23926
|
+
nulling: function nulling() {
|
|
23927
|
+
lastSwapEl = null;
|
|
23928
|
+
}
|
|
23929
|
+
};
|
|
23930
|
+
return sortable_esm_extends(Swap, {
|
|
23931
|
+
pluginName: 'swap',
|
|
23932
|
+
eventProperties: function eventProperties() {
|
|
23933
|
+
return {
|
|
23934
|
+
swapItem: lastSwapEl
|
|
23935
|
+
};
|
|
23936
|
+
}
|
|
23937
|
+
});
|
|
23938
|
+
}
|
|
23939
|
+
function swapNodes(n1, n2) {
|
|
23940
|
+
var p1 = n1.parentNode,
|
|
23941
|
+
p2 = n2.parentNode,
|
|
23942
|
+
i1,
|
|
23943
|
+
i2;
|
|
23944
|
+
if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
|
|
23945
|
+
i1 = sortable_esm_index(n1);
|
|
23946
|
+
i2 = sortable_esm_index(n2);
|
|
23947
|
+
if (p1.isEqualNode(p2) && i1 < i2) {
|
|
23948
|
+
i2++;
|
|
23949
|
+
}
|
|
23950
|
+
p1.insertBefore(n2, p1.children[i1]);
|
|
23951
|
+
p2.insertBefore(n1, p2.children[i2]);
|
|
23952
|
+
}
|
|
23953
|
+
|
|
23954
|
+
var multiDragElements = [],
|
|
23955
|
+
multiDragClones = [],
|
|
23956
|
+
lastMultiDragSelect,
|
|
23957
|
+
// for selection with modifier key down (SHIFT)
|
|
23958
|
+
multiDragSortable,
|
|
23959
|
+
initialFolding = false,
|
|
23960
|
+
// Initial multi-drag fold when drag started
|
|
23961
|
+
folding = false,
|
|
23962
|
+
// Folding any other time
|
|
23963
|
+
dragStarted = false,
|
|
23964
|
+
dragEl$1,
|
|
23965
|
+
clonesFromRect,
|
|
23966
|
+
clonesHidden;
|
|
23967
|
+
function MultiDragPlugin() {
|
|
23968
|
+
function MultiDrag(sortable) {
|
|
23969
|
+
// Bind all private methods
|
|
23970
|
+
for (var fn in this) {
|
|
23971
|
+
if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
|
|
23972
|
+
this[fn] = this[fn].bind(this);
|
|
23973
|
+
}
|
|
23974
|
+
}
|
|
23975
|
+
if (!sortable.options.avoidImplicitDeselect) {
|
|
23976
|
+
if (sortable.options.supportPointer) {
|
|
23977
|
+
sortable_esm_on(document, 'pointerup', this._deselectMultiDrag);
|
|
23978
|
+
} else {
|
|
23979
|
+
sortable_esm_on(document, 'mouseup', this._deselectMultiDrag);
|
|
23980
|
+
sortable_esm_on(document, 'touchend', this._deselectMultiDrag);
|
|
23981
|
+
}
|
|
23982
|
+
}
|
|
23983
|
+
sortable_esm_on(document, 'keydown', this._checkKeyDown);
|
|
23984
|
+
sortable_esm_on(document, 'keyup', this._checkKeyUp);
|
|
23985
|
+
this.defaults = {
|
|
23986
|
+
selectedClass: 'sortable-selected',
|
|
23987
|
+
multiDragKey: null,
|
|
23988
|
+
avoidImplicitDeselect: false,
|
|
23989
|
+
setData: function setData(dataTransfer, dragEl) {
|
|
23990
|
+
var data = '';
|
|
23991
|
+
if (multiDragElements.length && multiDragSortable === sortable) {
|
|
23992
|
+
multiDragElements.forEach(function (multiDragElement, i) {
|
|
23993
|
+
data += (!i ? '' : ', ') + multiDragElement.textContent;
|
|
23994
|
+
});
|
|
23995
|
+
} else {
|
|
23996
|
+
data = dragEl.textContent;
|
|
23997
|
+
}
|
|
23998
|
+
dataTransfer.setData('Text', data);
|
|
23999
|
+
}
|
|
24000
|
+
};
|
|
24001
|
+
}
|
|
24002
|
+
MultiDrag.prototype = {
|
|
24003
|
+
multiDragKeyDown: false,
|
|
24004
|
+
isMultiDrag: false,
|
|
24005
|
+
delayStartGlobal: function delayStartGlobal(_ref) {
|
|
24006
|
+
var dragged = _ref.dragEl;
|
|
24007
|
+
dragEl$1 = dragged;
|
|
24008
|
+
},
|
|
24009
|
+
delayEnded: function delayEnded() {
|
|
24010
|
+
this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
|
|
24011
|
+
},
|
|
24012
|
+
setupClone: function setupClone(_ref2) {
|
|
24013
|
+
var sortable = _ref2.sortable,
|
|
24014
|
+
cancel = _ref2.cancel;
|
|
24015
|
+
if (!this.isMultiDrag) return;
|
|
24016
|
+
for (var i = 0; i < multiDragElements.length; i++) {
|
|
24017
|
+
multiDragClones.push(clone(multiDragElements[i]));
|
|
24018
|
+
multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
|
|
24019
|
+
multiDragClones[i].draggable = false;
|
|
24020
|
+
multiDragClones[i].style['will-change'] = '';
|
|
24021
|
+
toggleClass(multiDragClones[i], this.options.selectedClass, false);
|
|
24022
|
+
multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
|
|
24023
|
+
}
|
|
24024
|
+
sortable._hideClone();
|
|
24025
|
+
cancel();
|
|
24026
|
+
},
|
|
24027
|
+
clone: function clone(_ref3) {
|
|
24028
|
+
var sortable = _ref3.sortable,
|
|
24029
|
+
rootEl = _ref3.rootEl,
|
|
24030
|
+
dispatchSortableEvent = _ref3.dispatchSortableEvent,
|
|
24031
|
+
cancel = _ref3.cancel;
|
|
24032
|
+
if (!this.isMultiDrag) return;
|
|
24033
|
+
if (!this.options.removeCloneOnHide) {
|
|
24034
|
+
if (multiDragElements.length && multiDragSortable === sortable) {
|
|
24035
|
+
insertMultiDragClones(true, rootEl);
|
|
24036
|
+
dispatchSortableEvent('clone');
|
|
24037
|
+
cancel();
|
|
24038
|
+
}
|
|
24039
|
+
}
|
|
24040
|
+
},
|
|
24041
|
+
showClone: function showClone(_ref4) {
|
|
24042
|
+
var cloneNowShown = _ref4.cloneNowShown,
|
|
24043
|
+
rootEl = _ref4.rootEl,
|
|
24044
|
+
cancel = _ref4.cancel;
|
|
24045
|
+
if (!this.isMultiDrag) return;
|
|
24046
|
+
insertMultiDragClones(false, rootEl);
|
|
24047
|
+
multiDragClones.forEach(function (clone) {
|
|
24048
|
+
sortable_esm_css(clone, 'display', '');
|
|
24049
|
+
});
|
|
24050
|
+
cloneNowShown();
|
|
24051
|
+
clonesHidden = false;
|
|
24052
|
+
cancel();
|
|
24053
|
+
},
|
|
24054
|
+
hideClone: function hideClone(_ref5) {
|
|
24055
|
+
var _this = this;
|
|
24056
|
+
var sortable = _ref5.sortable,
|
|
24057
|
+
cloneNowHidden = _ref5.cloneNowHidden,
|
|
24058
|
+
cancel = _ref5.cancel;
|
|
24059
|
+
if (!this.isMultiDrag) return;
|
|
24060
|
+
multiDragClones.forEach(function (clone) {
|
|
24061
|
+
sortable_esm_css(clone, 'display', 'none');
|
|
24062
|
+
if (_this.options.removeCloneOnHide && clone.parentNode) {
|
|
24063
|
+
clone.parentNode.removeChild(clone);
|
|
24064
|
+
}
|
|
24065
|
+
});
|
|
24066
|
+
cloneNowHidden();
|
|
24067
|
+
clonesHidden = true;
|
|
24068
|
+
cancel();
|
|
24069
|
+
},
|
|
24070
|
+
dragStartGlobal: function dragStartGlobal(_ref6) {
|
|
24071
|
+
var sortable = _ref6.sortable;
|
|
24072
|
+
if (!this.isMultiDrag && multiDragSortable) {
|
|
24073
|
+
multiDragSortable.multiDrag._deselectMultiDrag();
|
|
24074
|
+
}
|
|
24075
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24076
|
+
multiDragElement.sortableIndex = sortable_esm_index(multiDragElement);
|
|
24077
|
+
});
|
|
24078
|
+
|
|
24079
|
+
// Sort multi-drag elements
|
|
24080
|
+
multiDragElements = multiDragElements.sort(function (a, b) {
|
|
24081
|
+
return a.sortableIndex - b.sortableIndex;
|
|
24082
|
+
});
|
|
24083
|
+
dragStarted = true;
|
|
24084
|
+
},
|
|
24085
|
+
dragStarted: function dragStarted(_ref7) {
|
|
24086
|
+
var _this2 = this;
|
|
24087
|
+
var sortable = _ref7.sortable;
|
|
24088
|
+
if (!this.isMultiDrag) return;
|
|
24089
|
+
if (this.options.sort) {
|
|
24090
|
+
// Capture rects,
|
|
24091
|
+
// hide multi drag elements (by positioning them absolute),
|
|
24092
|
+
// set multi drag elements rects to dragRect,
|
|
24093
|
+
// show multi drag elements,
|
|
24094
|
+
// animate to rects,
|
|
24095
|
+
// unset rects & remove from DOM
|
|
24096
|
+
|
|
24097
|
+
sortable.captureAnimationState();
|
|
24098
|
+
if (this.options.animation) {
|
|
24099
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24100
|
+
if (multiDragElement === dragEl$1) return;
|
|
24101
|
+
sortable_esm_css(multiDragElement, 'position', 'absolute');
|
|
24102
|
+
});
|
|
24103
|
+
var dragRect = sortable_esm_getRect(dragEl$1, false, true, true);
|
|
24104
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24105
|
+
if (multiDragElement === dragEl$1) return;
|
|
24106
|
+
setRect(multiDragElement, dragRect);
|
|
24107
|
+
});
|
|
24108
|
+
folding = true;
|
|
24109
|
+
initialFolding = true;
|
|
24110
|
+
}
|
|
24111
|
+
}
|
|
24112
|
+
sortable.animateAll(function () {
|
|
24113
|
+
folding = false;
|
|
24114
|
+
initialFolding = false;
|
|
24115
|
+
if (_this2.options.animation) {
|
|
24116
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24117
|
+
unsetRect(multiDragElement);
|
|
24118
|
+
});
|
|
24119
|
+
}
|
|
24120
|
+
|
|
24121
|
+
// Remove all auxiliary multidrag items from el, if sorting enabled
|
|
24122
|
+
if (_this2.options.sort) {
|
|
24123
|
+
removeMultiDragElements();
|
|
24124
|
+
}
|
|
24125
|
+
});
|
|
24126
|
+
},
|
|
24127
|
+
dragOver: function dragOver(_ref8) {
|
|
24128
|
+
var target = _ref8.target,
|
|
24129
|
+
completed = _ref8.completed,
|
|
24130
|
+
cancel = _ref8.cancel;
|
|
24131
|
+
if (folding && ~multiDragElements.indexOf(target)) {
|
|
24132
|
+
completed(false);
|
|
24133
|
+
cancel();
|
|
24134
|
+
}
|
|
24135
|
+
},
|
|
24136
|
+
revert: function revert(_ref9) {
|
|
24137
|
+
var fromSortable = _ref9.fromSortable,
|
|
24138
|
+
rootEl = _ref9.rootEl,
|
|
24139
|
+
sortable = _ref9.sortable,
|
|
24140
|
+
dragRect = _ref9.dragRect;
|
|
24141
|
+
if (multiDragElements.length > 1) {
|
|
24142
|
+
// Setup unfold animation
|
|
24143
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24144
|
+
sortable.addAnimationState({
|
|
24145
|
+
target: multiDragElement,
|
|
24146
|
+
rect: folding ? sortable_esm_getRect(multiDragElement) : dragRect
|
|
24147
|
+
});
|
|
24148
|
+
unsetRect(multiDragElement);
|
|
24149
|
+
multiDragElement.fromRect = dragRect;
|
|
24150
|
+
fromSortable.removeAnimationState(multiDragElement);
|
|
24151
|
+
});
|
|
24152
|
+
folding = false;
|
|
24153
|
+
insertMultiDragElements(!this.options.removeCloneOnHide, rootEl);
|
|
24154
|
+
}
|
|
24155
|
+
},
|
|
24156
|
+
dragOverCompleted: function dragOverCompleted(_ref10) {
|
|
24157
|
+
var sortable = _ref10.sortable,
|
|
24158
|
+
isOwner = _ref10.isOwner,
|
|
24159
|
+
insertion = _ref10.insertion,
|
|
24160
|
+
activeSortable = _ref10.activeSortable,
|
|
24161
|
+
parentEl = _ref10.parentEl,
|
|
24162
|
+
putSortable = _ref10.putSortable;
|
|
24163
|
+
var options = this.options;
|
|
24164
|
+
if (insertion) {
|
|
24165
|
+
// Clones must be hidden before folding animation to capture dragRectAbsolute properly
|
|
24166
|
+
if (isOwner) {
|
|
24167
|
+
activeSortable._hideClone();
|
|
24168
|
+
}
|
|
24169
|
+
initialFolding = false;
|
|
24170
|
+
// If leaving sort:false root, or already folding - Fold to new location
|
|
24171
|
+
if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
|
|
24172
|
+
// Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
|
|
24173
|
+
var dragRectAbsolute = sortable_esm_getRect(dragEl$1, false, true, true);
|
|
24174
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24175
|
+
if (multiDragElement === dragEl$1) return;
|
|
24176
|
+
setRect(multiDragElement, dragRectAbsolute);
|
|
24177
|
+
|
|
24178
|
+
// Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
|
|
24179
|
+
// while folding, and so that we can capture them again because old sortable will no longer be fromSortable
|
|
24180
|
+
parentEl.appendChild(multiDragElement);
|
|
24181
|
+
});
|
|
24182
|
+
folding = true;
|
|
24183
|
+
}
|
|
24184
|
+
|
|
24185
|
+
// Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
|
|
24186
|
+
if (!isOwner) {
|
|
24187
|
+
// Only remove if not folding (folding will remove them anyways)
|
|
24188
|
+
if (!folding) {
|
|
24189
|
+
removeMultiDragElements();
|
|
24190
|
+
}
|
|
24191
|
+
if (multiDragElements.length > 1) {
|
|
24192
|
+
var clonesHiddenBefore = clonesHidden;
|
|
24193
|
+
activeSortable._showClone(sortable);
|
|
24194
|
+
|
|
24195
|
+
// Unfold animation for clones if showing from hidden
|
|
24196
|
+
if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
|
|
24197
|
+
multiDragClones.forEach(function (clone) {
|
|
24198
|
+
activeSortable.addAnimationState({
|
|
24199
|
+
target: clone,
|
|
24200
|
+
rect: clonesFromRect
|
|
24201
|
+
});
|
|
24202
|
+
clone.fromRect = clonesFromRect;
|
|
24203
|
+
clone.thisAnimationDuration = null;
|
|
24204
|
+
});
|
|
24205
|
+
}
|
|
24206
|
+
} else {
|
|
24207
|
+
activeSortable._showClone(sortable);
|
|
24208
|
+
}
|
|
24209
|
+
}
|
|
24210
|
+
}
|
|
24211
|
+
},
|
|
24212
|
+
dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
|
|
24213
|
+
var dragRect = _ref11.dragRect,
|
|
24214
|
+
isOwner = _ref11.isOwner,
|
|
24215
|
+
activeSortable = _ref11.activeSortable;
|
|
24216
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24217
|
+
multiDragElement.thisAnimationDuration = null;
|
|
24218
|
+
});
|
|
24219
|
+
if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
|
|
24220
|
+
clonesFromRect = sortable_esm_extends({}, dragRect);
|
|
24221
|
+
var dragMatrix = matrix(dragEl$1, true);
|
|
24222
|
+
clonesFromRect.top -= dragMatrix.f;
|
|
24223
|
+
clonesFromRect.left -= dragMatrix.e;
|
|
24224
|
+
}
|
|
24225
|
+
},
|
|
24226
|
+
dragOverAnimationComplete: function dragOverAnimationComplete() {
|
|
24227
|
+
if (folding) {
|
|
24228
|
+
folding = false;
|
|
24229
|
+
removeMultiDragElements();
|
|
24230
|
+
}
|
|
24231
|
+
},
|
|
24232
|
+
drop: function drop(_ref12) {
|
|
24233
|
+
var evt = _ref12.originalEvent,
|
|
24234
|
+
rootEl = _ref12.rootEl,
|
|
24235
|
+
parentEl = _ref12.parentEl,
|
|
24236
|
+
sortable = _ref12.sortable,
|
|
24237
|
+
dispatchSortableEvent = _ref12.dispatchSortableEvent,
|
|
24238
|
+
oldIndex = _ref12.oldIndex,
|
|
24239
|
+
putSortable = _ref12.putSortable;
|
|
24240
|
+
var toSortable = putSortable || this.sortable;
|
|
24241
|
+
if (!evt) return;
|
|
24242
|
+
var options = this.options,
|
|
24243
|
+
children = parentEl.children;
|
|
24244
|
+
|
|
24245
|
+
// Multi-drag selection
|
|
24246
|
+
if (!dragStarted) {
|
|
24247
|
+
if (options.multiDragKey && !this.multiDragKeyDown) {
|
|
24248
|
+
this._deselectMultiDrag();
|
|
24249
|
+
}
|
|
24250
|
+
toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
|
|
24251
|
+
if (!~multiDragElements.indexOf(dragEl$1)) {
|
|
24252
|
+
multiDragElements.push(dragEl$1);
|
|
24253
|
+
dispatchEvent({
|
|
24254
|
+
sortable: sortable,
|
|
24255
|
+
rootEl: rootEl,
|
|
24256
|
+
name: 'select',
|
|
24257
|
+
targetEl: dragEl$1,
|
|
24258
|
+
originalEvent: evt
|
|
24259
|
+
});
|
|
24260
|
+
|
|
24261
|
+
// Modifier activated, select from last to dragEl
|
|
24262
|
+
if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
|
|
24263
|
+
var lastIndex = sortable_esm_index(lastMultiDragSelect),
|
|
24264
|
+
currentIndex = sortable_esm_index(dragEl$1);
|
|
24265
|
+
if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
|
|
24266
|
+
(function () {
|
|
24267
|
+
// Must include lastMultiDragSelect (select it), in case modified selection from no selection
|
|
24268
|
+
// (but previous selection existed)
|
|
24269
|
+
var n, i;
|
|
24270
|
+
if (currentIndex > lastIndex) {
|
|
24271
|
+
i = lastIndex;
|
|
24272
|
+
n = currentIndex;
|
|
24273
|
+
} else {
|
|
24274
|
+
i = currentIndex;
|
|
24275
|
+
n = lastIndex + 1;
|
|
24276
|
+
}
|
|
24277
|
+
var filter = options.filter;
|
|
24278
|
+
for (; i < n; i++) {
|
|
24279
|
+
if (~multiDragElements.indexOf(children[i])) continue;
|
|
24280
|
+
// Check if element is draggable
|
|
24281
|
+
if (!closest(children[i], options.draggable, parentEl, false)) continue;
|
|
24282
|
+
// Check if element is filtered
|
|
24283
|
+
var filtered = filter && (typeof filter === 'function' ? filter.call(sortable, evt, children[i], sortable) : filter.split(',').some(function (criteria) {
|
|
24284
|
+
return closest(children[i], criteria.trim(), parentEl, false);
|
|
24285
|
+
}));
|
|
24286
|
+
if (filtered) continue;
|
|
24287
|
+
toggleClass(children[i], options.selectedClass, true);
|
|
24288
|
+
multiDragElements.push(children[i]);
|
|
24289
|
+
dispatchEvent({
|
|
24290
|
+
sortable: sortable,
|
|
24291
|
+
rootEl: rootEl,
|
|
24292
|
+
name: 'select',
|
|
24293
|
+
targetEl: children[i],
|
|
24294
|
+
originalEvent: evt
|
|
24295
|
+
});
|
|
24296
|
+
}
|
|
24297
|
+
})();
|
|
24298
|
+
}
|
|
24299
|
+
} else {
|
|
24300
|
+
lastMultiDragSelect = dragEl$1;
|
|
24301
|
+
}
|
|
24302
|
+
multiDragSortable = toSortable;
|
|
24303
|
+
} else {
|
|
24304
|
+
multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
|
|
24305
|
+
lastMultiDragSelect = null;
|
|
24306
|
+
dispatchEvent({
|
|
24307
|
+
sortable: sortable,
|
|
24308
|
+
rootEl: rootEl,
|
|
24309
|
+
name: 'deselect',
|
|
24310
|
+
targetEl: dragEl$1,
|
|
24311
|
+
originalEvent: evt
|
|
24312
|
+
});
|
|
24313
|
+
}
|
|
24314
|
+
}
|
|
24315
|
+
|
|
24316
|
+
// Multi-drag drop
|
|
24317
|
+
if (dragStarted && this.isMultiDrag) {
|
|
24318
|
+
folding = false;
|
|
24319
|
+
// Do not "unfold" after around dragEl if reverted
|
|
24320
|
+
if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
|
|
24321
|
+
var dragRect = sortable_esm_getRect(dragEl$1),
|
|
24322
|
+
multiDragIndex = sortable_esm_index(dragEl$1, ':not(.' + this.options.selectedClass + ')');
|
|
24323
|
+
if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
|
|
24324
|
+
toSortable.captureAnimationState();
|
|
24325
|
+
if (!initialFolding) {
|
|
24326
|
+
if (options.animation) {
|
|
24327
|
+
dragEl$1.fromRect = dragRect;
|
|
24328
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24329
|
+
multiDragElement.thisAnimationDuration = null;
|
|
24330
|
+
if (multiDragElement !== dragEl$1) {
|
|
24331
|
+
var rect = folding ? sortable_esm_getRect(multiDragElement) : dragRect;
|
|
24332
|
+
multiDragElement.fromRect = rect;
|
|
24333
|
+
|
|
24334
|
+
// Prepare unfold animation
|
|
24335
|
+
toSortable.addAnimationState({
|
|
24336
|
+
target: multiDragElement,
|
|
24337
|
+
rect: rect
|
|
24338
|
+
});
|
|
24339
|
+
}
|
|
24340
|
+
});
|
|
24341
|
+
}
|
|
24342
|
+
|
|
24343
|
+
// Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
|
|
24344
|
+
// properly they must all be removed
|
|
24345
|
+
removeMultiDragElements();
|
|
24346
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24347
|
+
if (children[multiDragIndex]) {
|
|
24348
|
+
parentEl.insertBefore(multiDragElement, children[multiDragIndex]);
|
|
24349
|
+
} else {
|
|
24350
|
+
parentEl.appendChild(multiDragElement);
|
|
24351
|
+
}
|
|
24352
|
+
multiDragIndex++;
|
|
24353
|
+
});
|
|
24354
|
+
|
|
24355
|
+
// If initial folding is done, the elements may have changed position because they are now
|
|
24356
|
+
// unfolding around dragEl, even though dragEl may not have his index changed, so update event
|
|
24357
|
+
// must be fired here as Sortable will not.
|
|
24358
|
+
if (oldIndex === sortable_esm_index(dragEl$1)) {
|
|
24359
|
+
var update = false;
|
|
24360
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24361
|
+
if (multiDragElement.sortableIndex !== sortable_esm_index(multiDragElement)) {
|
|
24362
|
+
update = true;
|
|
24363
|
+
return;
|
|
24364
|
+
}
|
|
24365
|
+
});
|
|
24366
|
+
if (update) {
|
|
24367
|
+
dispatchSortableEvent('update');
|
|
24368
|
+
dispatchSortableEvent('sort');
|
|
24369
|
+
}
|
|
24370
|
+
}
|
|
24371
|
+
}
|
|
24372
|
+
|
|
24373
|
+
// Must be done after capturing individual rects (scroll bar)
|
|
24374
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24375
|
+
unsetRect(multiDragElement);
|
|
24376
|
+
});
|
|
24377
|
+
toSortable.animateAll();
|
|
24378
|
+
}
|
|
24379
|
+
multiDragSortable = toSortable;
|
|
24380
|
+
}
|
|
24381
|
+
|
|
24382
|
+
// Remove clones if necessary
|
|
24383
|
+
if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
|
|
24384
|
+
multiDragClones.forEach(function (clone) {
|
|
24385
|
+
clone.parentNode && clone.parentNode.removeChild(clone);
|
|
24386
|
+
});
|
|
24387
|
+
}
|
|
24388
|
+
},
|
|
24389
|
+
nullingGlobal: function nullingGlobal() {
|
|
24390
|
+
this.isMultiDrag = dragStarted = false;
|
|
24391
|
+
multiDragClones.length = 0;
|
|
24392
|
+
},
|
|
24393
|
+
destroyGlobal: function destroyGlobal() {
|
|
24394
|
+
this._deselectMultiDrag();
|
|
24395
|
+
sortable_esm_off(document, 'pointerup', this._deselectMultiDrag);
|
|
24396
|
+
sortable_esm_off(document, 'mouseup', this._deselectMultiDrag);
|
|
24397
|
+
sortable_esm_off(document, 'touchend', this._deselectMultiDrag);
|
|
24398
|
+
sortable_esm_off(document, 'keydown', this._checkKeyDown);
|
|
24399
|
+
sortable_esm_off(document, 'keyup', this._checkKeyUp);
|
|
24400
|
+
},
|
|
24401
|
+
_deselectMultiDrag: function _deselectMultiDrag(evt) {
|
|
24402
|
+
if (typeof dragStarted !== "undefined" && dragStarted) return;
|
|
24403
|
+
|
|
24404
|
+
// Only deselect if selection is in this sortable
|
|
24405
|
+
if (multiDragSortable !== this.sortable) return;
|
|
24406
|
+
|
|
24407
|
+
// Only deselect if target is not item in this sortable
|
|
24408
|
+
if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return;
|
|
24409
|
+
|
|
24410
|
+
// Only deselect if left click
|
|
24411
|
+
if (evt && evt.button !== 0) return;
|
|
24412
|
+
while (multiDragElements.length) {
|
|
24413
|
+
var el = multiDragElements[0];
|
|
24414
|
+
toggleClass(el, this.options.selectedClass, false);
|
|
24415
|
+
multiDragElements.shift();
|
|
24416
|
+
dispatchEvent({
|
|
24417
|
+
sortable: this.sortable,
|
|
24418
|
+
rootEl: this.sortable.el,
|
|
24419
|
+
name: 'deselect',
|
|
24420
|
+
targetEl: el,
|
|
24421
|
+
originalEvent: evt
|
|
24422
|
+
});
|
|
24423
|
+
}
|
|
24424
|
+
},
|
|
24425
|
+
_checkKeyDown: function _checkKeyDown(evt) {
|
|
24426
|
+
if (evt.key === this.options.multiDragKey) {
|
|
24427
|
+
this.multiDragKeyDown = true;
|
|
24428
|
+
}
|
|
24429
|
+
},
|
|
24430
|
+
_checkKeyUp: function _checkKeyUp(evt) {
|
|
24431
|
+
if (evt.key === this.options.multiDragKey) {
|
|
24432
|
+
this.multiDragKeyDown = false;
|
|
24433
|
+
}
|
|
24434
|
+
}
|
|
24435
|
+
};
|
|
24436
|
+
return sortable_esm_extends(MultiDrag, {
|
|
24437
|
+
// Static methods & properties
|
|
24438
|
+
pluginName: 'multiDrag',
|
|
24439
|
+
utils: {
|
|
24440
|
+
/**
|
|
24441
|
+
* Selects the provided multi-drag item
|
|
24442
|
+
* @param {HTMLElement} el The element to be selected
|
|
24443
|
+
*/
|
|
24444
|
+
select: function select(el) {
|
|
24445
|
+
var sortable = el.parentNode[expando];
|
|
24446
|
+
if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return;
|
|
24447
|
+
if (multiDragSortable && multiDragSortable !== sortable) {
|
|
24448
|
+
multiDragSortable.multiDrag._deselectMultiDrag();
|
|
24449
|
+
multiDragSortable = sortable;
|
|
24450
|
+
}
|
|
24451
|
+
toggleClass(el, sortable.options.selectedClass, true);
|
|
24452
|
+
multiDragElements.push(el);
|
|
24453
|
+
},
|
|
24454
|
+
/**
|
|
24455
|
+
* Deselects the provided multi-drag item
|
|
24456
|
+
* @param {HTMLElement} el The element to be deselected
|
|
24457
|
+
*/
|
|
24458
|
+
deselect: function deselect(el) {
|
|
24459
|
+
var sortable = el.parentNode[expando],
|
|
24460
|
+
index = multiDragElements.indexOf(el);
|
|
24461
|
+
if (!sortable || !sortable.options.multiDrag || !~index) return;
|
|
24462
|
+
toggleClass(el, sortable.options.selectedClass, false);
|
|
24463
|
+
multiDragElements.splice(index, 1);
|
|
24464
|
+
}
|
|
24465
|
+
},
|
|
24466
|
+
eventProperties: function eventProperties() {
|
|
24467
|
+
var _this3 = this;
|
|
24468
|
+
var oldIndicies = [],
|
|
24469
|
+
newIndicies = [];
|
|
24470
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24471
|
+
oldIndicies.push({
|
|
24472
|
+
multiDragElement: multiDragElement,
|
|
24473
|
+
index: multiDragElement.sortableIndex
|
|
24474
|
+
});
|
|
24475
|
+
|
|
24476
|
+
// multiDragElements will already be sorted if folding
|
|
24477
|
+
var newIndex;
|
|
24478
|
+
if (folding && multiDragElement !== dragEl$1) {
|
|
24479
|
+
newIndex = -1;
|
|
24480
|
+
} else if (folding) {
|
|
24481
|
+
newIndex = sortable_esm_index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')');
|
|
24482
|
+
} else {
|
|
24483
|
+
newIndex = sortable_esm_index(multiDragElement);
|
|
24484
|
+
}
|
|
24485
|
+
newIndicies.push({
|
|
24486
|
+
multiDragElement: multiDragElement,
|
|
24487
|
+
index: newIndex
|
|
24488
|
+
});
|
|
24489
|
+
});
|
|
24490
|
+
return {
|
|
24491
|
+
items: _toConsumableArray(multiDragElements),
|
|
24492
|
+
clones: [].concat(multiDragClones),
|
|
24493
|
+
oldIndicies: oldIndicies,
|
|
24494
|
+
newIndicies: newIndicies
|
|
24495
|
+
};
|
|
24496
|
+
},
|
|
24497
|
+
optionListeners: {
|
|
24498
|
+
multiDragKey: function multiDragKey(key) {
|
|
24499
|
+
key = key.toLowerCase();
|
|
24500
|
+
if (key === 'ctrl') {
|
|
24501
|
+
key = 'Control';
|
|
24502
|
+
} else if (key.length > 1) {
|
|
24503
|
+
key = key.charAt(0).toUpperCase() + key.substr(1);
|
|
24504
|
+
}
|
|
24505
|
+
return key;
|
|
24506
|
+
}
|
|
24507
|
+
}
|
|
24508
|
+
});
|
|
24509
|
+
}
|
|
24510
|
+
function insertMultiDragElements(clonesInserted, rootEl) {
|
|
24511
|
+
multiDragElements.forEach(function (multiDragElement, i) {
|
|
24512
|
+
var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
|
|
24513
|
+
if (target) {
|
|
24514
|
+
rootEl.insertBefore(multiDragElement, target);
|
|
24515
|
+
} else {
|
|
24516
|
+
rootEl.appendChild(multiDragElement);
|
|
24517
|
+
}
|
|
24518
|
+
});
|
|
24519
|
+
}
|
|
24520
|
+
|
|
24521
|
+
/**
|
|
24522
|
+
* Insert multi-drag clones
|
|
24523
|
+
* @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
|
|
24524
|
+
* @param {HTMLElement} rootEl
|
|
24525
|
+
*/
|
|
24526
|
+
function insertMultiDragClones(elementsInserted, rootEl) {
|
|
24527
|
+
multiDragClones.forEach(function (clone, i) {
|
|
24528
|
+
var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
|
|
24529
|
+
if (target) {
|
|
24530
|
+
rootEl.insertBefore(clone, target);
|
|
24531
|
+
} else {
|
|
24532
|
+
rootEl.appendChild(clone);
|
|
24533
|
+
}
|
|
24534
|
+
});
|
|
24535
|
+
}
|
|
24536
|
+
function removeMultiDragElements() {
|
|
24537
|
+
multiDragElements.forEach(function (multiDragElement) {
|
|
24538
|
+
if (multiDragElement === dragEl$1) return;
|
|
24539
|
+
multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
|
|
24540
|
+
});
|
|
24541
|
+
}
|
|
24542
|
+
|
|
24543
|
+
Sortable.mount(new AutoScrollPlugin());
|
|
24544
|
+
Sortable.mount(Remove, Revert);
|
|
24545
|
+
|
|
24546
|
+
/* harmony default export */ var sortable_esm = (Sortable);
|
|
24547
|
+
|
|
24548
|
+
|
|
21169
24549
|
// CONCATENATED MODULE: ./es/media-picker/index.js
|
|
21170
24550
|
|
|
21171
24551
|
|
|
@@ -21207,6 +24587,7 @@ var wx_util_wxUploadImage = function wxUploadImage(type) {
|
|
|
21207
24587
|
|
|
21208
24588
|
|
|
21209
24589
|
|
|
24590
|
+
|
|
21210
24591
|
|
|
21211
24592
|
// 单个文件最大限制,单位为M(目前限制是100M)
|
|
21212
24593
|
var FILE_SIZE_LIMIT = 100;
|
|
@@ -21351,6 +24732,10 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21351
24732
|
default: function _default() {
|
|
21352
24733
|
return {};
|
|
21353
24734
|
}
|
|
24735
|
+
},
|
|
24736
|
+
sortable: {
|
|
24737
|
+
type: Boolean,
|
|
24738
|
+
default: false
|
|
21354
24739
|
}
|
|
21355
24740
|
},
|
|
21356
24741
|
model: {
|
|
@@ -21364,7 +24749,8 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21364
24749
|
actionVisible: false,
|
|
21365
24750
|
mediaPlayerVisible: false,
|
|
21366
24751
|
mediaTypeToPlay: '',
|
|
21367
|
-
mediaUrlToPlay: ''
|
|
24752
|
+
mediaUrlToPlay: '',
|
|
24753
|
+
sort: undefined
|
|
21368
24754
|
};
|
|
21369
24755
|
},
|
|
21370
24756
|
computed: {
|
|
@@ -21412,11 +24798,36 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21412
24798
|
}
|
|
21413
24799
|
}];
|
|
21414
24800
|
}
|
|
24801
|
+
},
|
|
24802
|
+
showPreview: function showPreview() {
|
|
24803
|
+
return this.mediaList.length > 0 && this.pickerMode !== "certificate";
|
|
24804
|
+
}
|
|
24805
|
+
},
|
|
24806
|
+
watch: {
|
|
24807
|
+
showPreview: function showPreview() {
|
|
24808
|
+
var _this$$refs$grid,
|
|
24809
|
+
_this2 = this;
|
|
24810
|
+
if (this.sort || !this.sortable) return;
|
|
24811
|
+
this.sort = sortable_esm.create((_this$$refs$grid = this.$refs.grid) == null ? void 0 : _this$$refs$grid.$el, {
|
|
24812
|
+
animation: 200,
|
|
24813
|
+
handle: ".zt2-grid-item",
|
|
24814
|
+
onEnd: function onEnd(evt) {
|
|
24815
|
+
var raws = _this2.exchangeArrayIndex(_this2.mediaList, evt.oldIndex, evt.newIndex);
|
|
24816
|
+
_this2.$emit('input', raws);
|
|
24817
|
+
}
|
|
24818
|
+
});
|
|
21415
24819
|
}
|
|
21416
24820
|
},
|
|
21417
24821
|
methods: {
|
|
24822
|
+
exchangeArrayIndex: function exchangeArrayIndex(list, index, newIndex) {
|
|
24823
|
+
var raws = [].concat(list);
|
|
24824
|
+
var raw = raws[index];
|
|
24825
|
+
raws.splice(index, 1);
|
|
24826
|
+
raws.splice(newIndex, 0, raw);
|
|
24827
|
+
return [].concat(raws);
|
|
24828
|
+
},
|
|
21418
24829
|
mediaPick: function mediaPick(mediaType, mediaAddType) {
|
|
21419
|
-
var
|
|
24830
|
+
var _this3 = this;
|
|
21420
24831
|
if (this.disabled) {
|
|
21421
24832
|
return;
|
|
21422
24833
|
}
|
|
@@ -21438,7 +24849,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21438
24849
|
if (this.useWx && isWeixin() && window.wx) {
|
|
21439
24850
|
var type = mediaAddType === MediaAddType.TAKE ? 'camera' : 'album';
|
|
21440
24851
|
wx_util_wxUploadImage(type).then(function (newMedias) {
|
|
21441
|
-
|
|
24852
|
+
_this3.$emit('input', [].concat(_this3.mediaList, newMedias));
|
|
21442
24853
|
});
|
|
21443
24854
|
} else {
|
|
21444
24855
|
if (mediaAddType === MediaAddType.TAKE) {
|
|
@@ -21513,7 +24924,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21513
24924
|
}
|
|
21514
24925
|
},
|
|
21515
24926
|
handleInputFiles: function handleInputFiles(event) {
|
|
21516
|
-
var
|
|
24927
|
+
var _this4 = this;
|
|
21517
24928
|
return _asyncToGenerator(/*#__PURE__*/regenerator_default.a.mark(function _callee() {
|
|
21518
24929
|
var files, response, data;
|
|
21519
24930
|
return regenerator_default.a.wrap(function _callee$(_context) {
|
|
@@ -21526,29 +24937,29 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21526
24937
|
}
|
|
21527
24938
|
return _context.abrupt("return");
|
|
21528
24939
|
case 3:
|
|
21529
|
-
if (
|
|
24940
|
+
if (_this4.pickerMode === "certificate") {
|
|
21530
24941
|
files = [files[0]];
|
|
21531
24942
|
}
|
|
21532
|
-
files =
|
|
24943
|
+
files = _this4.filterValidFiles(files);
|
|
21533
24944
|
if (!(files.length === 0)) {
|
|
21534
24945
|
_context.next = 7;
|
|
21535
24946
|
break;
|
|
21536
24947
|
}
|
|
21537
24948
|
return _context.abrupt("return");
|
|
21538
24949
|
case 7:
|
|
21539
|
-
if (
|
|
24950
|
+
if (_this4.checkFileCountAfterAdd(files)) {
|
|
21540
24951
|
_context.next = 9;
|
|
21541
24952
|
break;
|
|
21542
24953
|
}
|
|
21543
24954
|
return _context.abrupt("return");
|
|
21544
24955
|
case 9:
|
|
21545
|
-
if (!
|
|
24956
|
+
if (!_this4.beforeRead) {
|
|
21546
24957
|
_context.next = 24;
|
|
21547
24958
|
break;
|
|
21548
24959
|
}
|
|
21549
24960
|
_context.prev = 10;
|
|
21550
24961
|
_context.next = 13;
|
|
21551
|
-
return
|
|
24962
|
+
return _this4.beforeRead(files);
|
|
21552
24963
|
case 13:
|
|
21553
24964
|
response = _context.sent;
|
|
21554
24965
|
if (response) {
|
|
@@ -21561,9 +24972,9 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21561
24972
|
data = response.filter(function (item) {
|
|
21562
24973
|
return !!item;
|
|
21563
24974
|
});
|
|
21564
|
-
|
|
24975
|
+
_this4.readFiles(data);
|
|
21565
24976
|
} else {
|
|
21566
|
-
|
|
24977
|
+
_this4.readFiles(files);
|
|
21567
24978
|
}
|
|
21568
24979
|
_context.next = 22;
|
|
21569
24980
|
break;
|
|
@@ -21575,7 +24986,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21575
24986
|
_context.next = 25;
|
|
21576
24987
|
break;
|
|
21577
24988
|
case 24:
|
|
21578
|
-
|
|
24989
|
+
_this4.readFiles(files);
|
|
21579
24990
|
case 25:
|
|
21580
24991
|
case "end":
|
|
21581
24992
|
return _context.stop();
|
|
@@ -21584,12 +24995,12 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21584
24995
|
}))();
|
|
21585
24996
|
},
|
|
21586
24997
|
readFiles: function readFiles(files) {
|
|
21587
|
-
var
|
|
24998
|
+
var _this5 = this;
|
|
21588
24999
|
// 处理非图片
|
|
21589
25000
|
var notImages = files.filter(function (f) {
|
|
21590
25001
|
return !isImageType(f);
|
|
21591
25002
|
}).map(function (f) {
|
|
21592
|
-
return
|
|
25003
|
+
return _this5.transformNotImageFile(f);
|
|
21593
25004
|
});
|
|
21594
25005
|
var newMedias = [];
|
|
21595
25006
|
if (notImages.length > 0) {
|
|
@@ -21610,13 +25021,13 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21610
25021
|
newMedias = newMedias.concat(medias);
|
|
21611
25022
|
}
|
|
21612
25023
|
}).finally(function () {
|
|
21613
|
-
if (
|
|
21614
|
-
|
|
25024
|
+
if (_this5.pickerMode === "certificate") {
|
|
25025
|
+
_this5.$emit('input', [].concat(newMedias));
|
|
21615
25026
|
} else {
|
|
21616
|
-
|
|
25027
|
+
_this5.$emit('input', [].concat(_this5.mediaList, newMedias));
|
|
21617
25028
|
}
|
|
21618
|
-
if (
|
|
21619
|
-
|
|
25029
|
+
if (_this5.afterRead) {
|
|
25030
|
+
_this5.afterRead(newMedias);
|
|
21620
25031
|
}
|
|
21621
25032
|
});
|
|
21622
25033
|
},
|
|
@@ -21704,24 +25115,24 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21704
25115
|
* @return {Promise<[Media]>}
|
|
21705
25116
|
*/
|
|
21706
25117
|
transformImageFiles: function transformImageFiles(files) {
|
|
21707
|
-
var
|
|
25118
|
+
var _this6 = this;
|
|
21708
25119
|
var promisesTodo = [];
|
|
21709
25120
|
var resizeOptions = new ResizeOptions(this.maxImageSideLength);
|
|
21710
25121
|
var compressOptions = new CompressOptions(this.maxImageFileSize);
|
|
21711
25122
|
var _loop = function _loop() {
|
|
21712
25123
|
var inputFile = files[i];
|
|
21713
|
-
var watermarkEnabled =
|
|
25124
|
+
var watermarkEnabled = _this6.watermarkOptions && _this6.watermarkOptions.watermarkConfigString && checkWatermarkConfigSupported(_this6.watermarkOptions.watermarkConfigString);
|
|
21714
25125
|
var watermarkOpt;
|
|
21715
25126
|
if (watermarkEnabled) {
|
|
21716
25127
|
watermarkOpt = new WatermarkOptions({
|
|
21717
25128
|
enabled: true,
|
|
21718
|
-
watermarkConfigString: watermarkEnabled ?
|
|
25129
|
+
watermarkConfigString: watermarkEnabled ? _this6.watermarkOptions.watermarkConfigString : '',
|
|
21719
25130
|
context: {
|
|
21720
|
-
address:
|
|
21721
|
-
humanName:
|
|
21722
|
-
projectName:
|
|
21723
|
-
logo:
|
|
21724
|
-
applicationName:
|
|
25131
|
+
address: _this6.watermarkOptions.address || "",
|
|
25132
|
+
humanName: _this6.watermarkOptions.humanName || _this6.watermarkOptions.humanname || "",
|
|
25133
|
+
projectName: _this6.watermarkOptions.projectName || "",
|
|
25134
|
+
logo: _this6.watermarkOptions.logo || "",
|
|
25135
|
+
applicationName: _this6.watermarkOptions.applicationName || "",
|
|
21725
25136
|
watermarkTime: new Date()
|
|
21726
25137
|
}
|
|
21727
25138
|
});
|
|
@@ -21861,18 +25272,18 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21861
25272
|
}
|
|
21862
25273
|
},
|
|
21863
25274
|
onDelete: function onDelete(media, index) {
|
|
21864
|
-
var
|
|
25275
|
+
var _this7 = this;
|
|
21865
25276
|
return _asyncToGenerator(/*#__PURE__*/regenerator_default.a.mark(function _callee2() {
|
|
21866
25277
|
var response;
|
|
21867
25278
|
return regenerator_default.a.wrap(function _callee2$(_context2) {
|
|
21868
25279
|
while (1) switch (_context2.prev = _context2.next) {
|
|
21869
25280
|
case 0:
|
|
21870
|
-
if (!
|
|
25281
|
+
if (!_this7.beforeDelete) {
|
|
21871
25282
|
_context2.next = 6;
|
|
21872
25283
|
break;
|
|
21873
25284
|
}
|
|
21874
25285
|
_context2.next = 3;
|
|
21875
|
-
return
|
|
25286
|
+
return _this7.beforeDelete(media);
|
|
21876
25287
|
case 3:
|
|
21877
25288
|
response = _context2.sent;
|
|
21878
25289
|
if (response) {
|
|
@@ -21881,7 +25292,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21881
25292
|
}
|
|
21882
25293
|
return _context2.abrupt("return");
|
|
21883
25294
|
case 6:
|
|
21884
|
-
|
|
25295
|
+
_this7.deleteMedia(media, index);
|
|
21885
25296
|
case 7:
|
|
21886
25297
|
case "end":
|
|
21887
25298
|
return _context2.stop();
|
|
@@ -21896,7 +25307,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21896
25307
|
this.$emit('delete', media, index);
|
|
21897
25308
|
},
|
|
21898
25309
|
hiddenInput: function hiddenInput() {
|
|
21899
|
-
var
|
|
25310
|
+
var _this8 = this;
|
|
21900
25311
|
var h = this.$createElement;
|
|
21901
25312
|
return [h("input", {
|
|
21902
25313
|
"attrs": {
|
|
@@ -21909,7 +25320,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21909
25320
|
"on": {
|
|
21910
25321
|
"change": this.handleInputFiles,
|
|
21911
25322
|
"click": function click() {
|
|
21912
|
-
return
|
|
25323
|
+
return _this8.resetInput(MediaType.PHOTO, MediaAddType.TAKE);
|
|
21913
25324
|
}
|
|
21914
25325
|
},
|
|
21915
25326
|
"class": media_picker_bem('hidden')
|
|
@@ -21923,7 +25334,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21923
25334
|
"on": {
|
|
21924
25335
|
"change": this.handleInputFiles,
|
|
21925
25336
|
"click": function click() {
|
|
21926
|
-
return
|
|
25337
|
+
return _this8.resetInput(MediaType.PHOTO, MediaAddType.PICK);
|
|
21927
25338
|
}
|
|
21928
25339
|
},
|
|
21929
25340
|
"class": media_picker_bem('hidden')
|
|
@@ -21937,7 +25348,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21937
25348
|
"on": {
|
|
21938
25349
|
"change": this.handleInputFiles,
|
|
21939
25350
|
"click": function click() {
|
|
21940
|
-
return
|
|
25351
|
+
return _this8.resetInput(MediaType.VIDEO, MediaAddType.TAKE);
|
|
21941
25352
|
}
|
|
21942
25353
|
},
|
|
21943
25354
|
"class": media_picker_bem('hidden')
|
|
@@ -21950,7 +25361,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21950
25361
|
"on": {
|
|
21951
25362
|
"change": this.handleInputFiles,
|
|
21952
25363
|
"click": function click() {
|
|
21953
|
-
return
|
|
25364
|
+
return _this8.resetInput(MediaType.VIDEO, MediaAddType.PICK);
|
|
21954
25365
|
}
|
|
21955
25366
|
},
|
|
21956
25367
|
"class": media_picker_bem('hidden')
|
|
@@ -21964,7 +25375,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21964
25375
|
"on": {
|
|
21965
25376
|
"change": this.handleInputFiles,
|
|
21966
25377
|
"click": function click() {
|
|
21967
|
-
return
|
|
25378
|
+
return _this8.resetInput(MediaType.AUDIO, MediaAddType.TAKE);
|
|
21968
25379
|
}
|
|
21969
25380
|
},
|
|
21970
25381
|
"class": media_picker_bem('hidden')
|
|
@@ -21977,7 +25388,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21977
25388
|
"on": {
|
|
21978
25389
|
"change": this.handleInputFiles,
|
|
21979
25390
|
"click": function click() {
|
|
21980
|
-
return
|
|
25391
|
+
return _this8.resetInput(MediaType.AUDIO, MediaAddType.PICK);
|
|
21981
25392
|
}
|
|
21982
25393
|
},
|
|
21983
25394
|
"class": media_picker_bem('hidden')
|
|
@@ -21990,14 +25401,14 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
21990
25401
|
"on": {
|
|
21991
25402
|
"change": this.handleInputFiles,
|
|
21992
25403
|
"click": function click() {
|
|
21993
|
-
return
|
|
25404
|
+
return _this8.resetInput(MediaType.FILE, MediaAddType.PICK);
|
|
21994
25405
|
}
|
|
21995
25406
|
},
|
|
21996
25407
|
"class": media_picker_bem('hidden')
|
|
21997
25408
|
})];
|
|
21998
25409
|
},
|
|
21999
25410
|
renderIcon: function renderIcon(mediaType, mediaAddType) {
|
|
22000
|
-
var
|
|
25411
|
+
var _this9 = this;
|
|
22001
25412
|
var h = this.$createElement;
|
|
22002
25413
|
if (mediaType === MediaType.PHOTO) {
|
|
22003
25414
|
if (mediaAddType === MediaAddType.TAKE) {
|
|
@@ -22005,7 +25416,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22005
25416
|
"class": media_picker_bem('button'),
|
|
22006
25417
|
"on": {
|
|
22007
25418
|
"click": function click() {
|
|
22008
|
-
return
|
|
25419
|
+
return _this9.mediaPick(mediaType, mediaAddType);
|
|
22009
25420
|
}
|
|
22010
25421
|
}
|
|
22011
25422
|
});
|
|
@@ -22014,7 +25425,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22014
25425
|
"class": media_picker_bem('button'),
|
|
22015
25426
|
"on": {
|
|
22016
25427
|
"click": function click() {
|
|
22017
|
-
return
|
|
25428
|
+
return _this9.mediaPick(mediaType, mediaAddType);
|
|
22018
25429
|
}
|
|
22019
25430
|
}
|
|
22020
25431
|
});
|
|
@@ -22024,7 +25435,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22024
25435
|
"class": media_picker_bem('button'),
|
|
22025
25436
|
"on": {
|
|
22026
25437
|
"click": function click() {
|
|
22027
|
-
return
|
|
25438
|
+
return _this9.mediaPick(mediaType, mediaAddType);
|
|
22028
25439
|
}
|
|
22029
25440
|
}
|
|
22030
25441
|
});
|
|
@@ -22033,7 +25444,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22033
25444
|
"class": media_picker_bem('button'),
|
|
22034
25445
|
"on": {
|
|
22035
25446
|
"click": function click() {
|
|
22036
|
-
return
|
|
25447
|
+
return _this9.mediaPick(mediaType, mediaAddType);
|
|
22037
25448
|
}
|
|
22038
25449
|
}
|
|
22039
25450
|
});
|
|
@@ -22042,7 +25453,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22042
25453
|
"class": media_picker_bem('button'),
|
|
22043
25454
|
"on": {
|
|
22044
25455
|
"click": function click() {
|
|
22045
|
-
return
|
|
25456
|
+
return _this9.mediaPick(mediaType, mediaAddType);
|
|
22046
25457
|
}
|
|
22047
25458
|
}
|
|
22048
25459
|
});
|
|
@@ -22083,7 +25494,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22083
25494
|
}
|
|
22084
25495
|
},
|
|
22085
25496
|
renderCertificates: function renderCertificates() {
|
|
22086
|
-
var
|
|
25497
|
+
var _this10 = this;
|
|
22087
25498
|
var h = this.$createElement;
|
|
22088
25499
|
if (this.mediaList && this.mediaList.length) {
|
|
22089
25500
|
var media = this.mediaList[0];
|
|
@@ -22093,8 +25504,8 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22093
25504
|
"on": {
|
|
22094
25505
|
"click": function click(event) {
|
|
22095
25506
|
event.stopPropagation();
|
|
22096
|
-
|
|
22097
|
-
|
|
25507
|
+
_this10.onDelete(media, 0);
|
|
25508
|
+
_this10.mediaPick(MediaType.PHOTO, MediaAddType.PICK);
|
|
22098
25509
|
}
|
|
22099
25510
|
}
|
|
22100
25511
|
}, [h(ReUpload, {
|
|
@@ -22112,7 +25523,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22112
25523
|
"click": function click(event) {
|
|
22113
25524
|
event.stopPropagation();
|
|
22114
25525
|
// 证件照模式只有一张图片
|
|
22115
|
-
|
|
25526
|
+
_this10.previewMedia(media, 0);
|
|
22116
25527
|
}
|
|
22117
25528
|
}
|
|
22118
25529
|
}, [reUpload]);
|
|
@@ -22247,7 +25658,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22247
25658
|
}
|
|
22248
25659
|
},
|
|
22249
25660
|
renderMediaList: function renderMediaList() {
|
|
22250
|
-
var
|
|
25661
|
+
var _this11 = this;
|
|
22251
25662
|
var h = this.$createElement;
|
|
22252
25663
|
return this.mediaList.map(function (media, index) {
|
|
22253
25664
|
var showDelete = media.deletable && media.status !== MediaUploadStatus.UPLOADING;
|
|
@@ -22256,7 +25667,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22256
25667
|
"on": {
|
|
22257
25668
|
"click": function click(event) {
|
|
22258
25669
|
event.stopPropagation();
|
|
22259
|
-
|
|
25670
|
+
_this11.onDelete(media, index);
|
|
22260
25671
|
}
|
|
22261
25672
|
}
|
|
22262
25673
|
});
|
|
@@ -22265,10 +25676,10 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22265
25676
|
"on": {
|
|
22266
25677
|
"click": function click(event) {
|
|
22267
25678
|
event.stopPropagation();
|
|
22268
|
-
|
|
25679
|
+
_this11.previewMedia(media, index);
|
|
22269
25680
|
}
|
|
22270
25681
|
}
|
|
22271
|
-
}, [
|
|
25682
|
+
}, [_this11.renderMediaBox(media), _this11.genThumbnailMask(media), deleteIcon]);
|
|
22272
25683
|
});
|
|
22273
25684
|
},
|
|
22274
25685
|
selectAction: function selectAction(action) {
|
|
@@ -22277,7 +25688,7 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22277
25688
|
}
|
|
22278
25689
|
},
|
|
22279
25690
|
render: function render() {
|
|
22280
|
-
var
|
|
25691
|
+
var _this12 = this;
|
|
22281
25692
|
var h = arguments[0];
|
|
22282
25693
|
var title = this.showTitle && h("div", {
|
|
22283
25694
|
"class": media_picker_bem('title')
|
|
@@ -22290,9 +25701,9 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22290
25701
|
"mediaUrl": this.mediaUrlToPlay
|
|
22291
25702
|
}, this.mediaPlayerProps),
|
|
22292
25703
|
"model": {
|
|
22293
|
-
value:
|
|
25704
|
+
value: _this12.mediaPlayerVisible,
|
|
22294
25705
|
callback: function callback($$v) {
|
|
22295
|
-
|
|
25706
|
+
_this12.mediaPlayerVisible = $$v;
|
|
22296
25707
|
}
|
|
22297
25708
|
}
|
|
22298
25709
|
}), h(action_sheet, {
|
|
@@ -22306,9 +25717,9 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22306
25717
|
"select": this.selectAction
|
|
22307
25718
|
},
|
|
22308
25719
|
"model": {
|
|
22309
|
-
value:
|
|
25720
|
+
value: _this12.actionVisible,
|
|
22310
25721
|
callback: function callback($$v) {
|
|
22311
|
-
|
|
25722
|
+
_this12.actionVisible = $$v;
|
|
22312
25723
|
}
|
|
22313
25724
|
}
|
|
22314
25725
|
}), this.pickerMode === "certificate" ? h("div", {
|
|
@@ -22319,9 +25730,10 @@ var media_picker_createNamespace = Object(utils["b" /* createNamespace */])('med
|
|
|
22319
25730
|
}, [this.renderCertificates()]) : h("div", {
|
|
22320
25731
|
"class": media_picker_bem('line')
|
|
22321
25732
|
}, [this.renderButtons(), this.slots('extend')]), h(grid, {
|
|
25733
|
+
"ref": "grid",
|
|
22322
25734
|
"directives": [{
|
|
22323
25735
|
name: "show",
|
|
22324
|
-
value: this.
|
|
25736
|
+
value: this.showPreview
|
|
22325
25737
|
}],
|
|
22326
25738
|
"attrs": {
|
|
22327
25739
|
"column-num": '3',
|
|
@@ -28837,7 +32249,8 @@ var speech_recognizer_createNamespace = Object(utils["b" /* createNamespace */])
|
|
|
28837
32249
|
closeOnClickOverlay: {
|
|
28838
32250
|
type: Boolean,
|
|
28839
32251
|
default: true
|
|
28840
|
-
}
|
|
32252
|
+
},
|
|
32253
|
+
type: String
|
|
28841
32254
|
}),
|
|
28842
32255
|
data: function data() {
|
|
28843
32256
|
return {
|
|
@@ -28907,6 +32320,10 @@ var speech_recognizer_createNamespace = Object(utils["b" /* createNamespace */])
|
|
|
28907
32320
|
_this2.mediaRecorder.ondataavailable = function (event) {
|
|
28908
32321
|
if (event.data && event.data.size > 0) {
|
|
28909
32322
|
_this2.recordedBlobs.push(event.data);
|
|
32323
|
+
if (_this2.type === "raw") {
|
|
32324
|
+
_this2.$emit("change", _this2.recordedBlobs);
|
|
32325
|
+
return;
|
|
32326
|
+
}
|
|
28910
32327
|
var blob = new Blob(_this2.recordedBlobs, {
|
|
28911
32328
|
type: "audio/wav"
|
|
28912
32329
|
});
|
|
@@ -28930,12 +32347,14 @@ var speech_recognizer_createNamespace = Object(utils["b" /* createNamespace */])
|
|
|
28930
32347
|
this.mediaRecorder = undefined;
|
|
28931
32348
|
},
|
|
28932
32349
|
onTouchstart: function onTouchstart() {
|
|
32350
|
+
this.$emit("onTouchstart");
|
|
28933
32351
|
this.isPlaying = true;
|
|
28934
32352
|
this.startRecording();
|
|
28935
32353
|
},
|
|
28936
32354
|
onTouchend: function onTouchend() {
|
|
28937
32355
|
this.isPlaying = false;
|
|
28938
32356
|
this.stopRecording();
|
|
32357
|
+
this.$emit("onTouchend");
|
|
28939
32358
|
},
|
|
28940
32359
|
onInput: function onInput(value) {
|
|
28941
32360
|
this.$emit('update:value', value);
|
|
@@ -31651,7 +35070,7 @@ var uploader_createNamespace = Object(utils["b" /* createNamespace */])('uploade
|
|
|
31651
35070
|
|
|
31652
35071
|
|
|
31653
35072
|
|
|
31654
|
-
var
|
|
35073
|
+
var es_version = '2.1.21';
|
|
31655
35074
|
function install(Vue) {
|
|
31656
35075
|
var components = [action_sheet, es_area, avatar, back_top, badge, es_button, calendar, cascader, cell, cell_group, es_checkbox, checkbox_group, col, collapse, collapse_item, count_down, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, fold_dialog, es_form, grid, grid_item, hierarchy_select, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, lazyload, es_list, es_loading, locale["a" /* default */], media_picker, media_player, multiple_picker, nav_bar, notice_bar, number_keyboard, es_overlay, password_input, es_picker, popover, popup, pull_refresh, es_radio, radio_group, rate, row, search, signature, skeleton, slider, speech_recognizer, es_step, stepper, steps, es_sticky, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, table, tabs, es_tag, text_ellipsis, timeline, es_toast, uploader];
|
|
31657
35076
|
components.forEach(function (item) {
|
|
@@ -31668,7 +35087,7 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|
|
31668
35087
|
|
|
31669
35088
|
/* harmony default export */ var es = __webpack_exports__["default"] = ({
|
|
31670
35089
|
install: install,
|
|
31671
|
-
version:
|
|
35090
|
+
version: es_version
|
|
31672
35091
|
});
|
|
31673
35092
|
|
|
31674
35093
|
/***/ })
|