@leo1998work/fuzzy-ui 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,10 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tool = require('../tool-663a06ba.js');
5
+ var tool = require('../tool-4ee81ec1.js');
6
6
  var ElementPlus = require('element-plus');
7
7
  var vue = require('vue');
8
8
  var dayjs = require('dayjs');
9
+ var Sortable = require('sortablejs');
9
10
 
10
11
  /*! Element Plus v2.13.6 */
11
12
 
@@ -7469,2657 +7470,6 @@ function useTableAttrs(attrs, template, showSelectionIndex) {
7469
7470
  });
7470
7471
  }
7471
7472
 
7472
- /**!
7473
- * Sortable 1.15.7
7474
- * @author RubaXa <trash@rubaxa.org>
7475
- * @author owenm <owen23355@gmail.com>
7476
- * @license MIT
7477
- */
7478
- function _defineProperty(e, r, t) {
7479
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
7480
- value: t,
7481
- enumerable: !0,
7482
- configurable: !0,
7483
- writable: !0
7484
- }) : e[r] = t, e;
7485
- }
7486
- function _extends() {
7487
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
7488
- for (var e = 1; e < arguments.length; e++) {
7489
- var t = arguments[e];
7490
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
7491
- }
7492
- return n;
7493
- }, _extends.apply(null, arguments);
7494
- }
7495
- function ownKeys(e, r) {
7496
- var t = Object.keys(e);
7497
- if (Object.getOwnPropertySymbols) {
7498
- var o = Object.getOwnPropertySymbols(e);
7499
- r && (o = o.filter(function (r) {
7500
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
7501
- })), t.push.apply(t, o);
7502
- }
7503
- return t;
7504
- }
7505
- function _objectSpread2(e) {
7506
- for (var r = 1; r < arguments.length; r++) {
7507
- var t = null != arguments[r] ? arguments[r] : {};
7508
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
7509
- _defineProperty(e, r, t[r]);
7510
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
7511
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
7512
- });
7513
- }
7514
- return e;
7515
- }
7516
- function _objectWithoutProperties(e, t) {
7517
- if (null == e) return {};
7518
- var o,
7519
- r,
7520
- i = _objectWithoutPropertiesLoose(e, t);
7521
- if (Object.getOwnPropertySymbols) {
7522
- var n = Object.getOwnPropertySymbols(e);
7523
- for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
7524
- }
7525
- return i;
7526
- }
7527
- function _objectWithoutPropertiesLoose(r, e) {
7528
- if (null == r) return {};
7529
- var t = {};
7530
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
7531
- if (-1 !== e.indexOf(n)) continue;
7532
- t[n] = r[n];
7533
- }
7534
- return t;
7535
- }
7536
- function _toPrimitive(t, r) {
7537
- if ("object" != typeof t || !t) return t;
7538
- var e = t[Symbol.toPrimitive];
7539
- if (void 0 !== e) {
7540
- var i = e.call(t, r || "default");
7541
- if ("object" != typeof i) return i;
7542
- throw new TypeError("@@toPrimitive must return a primitive value.");
7543
- }
7544
- return ("string" === r ? String : Number)(t);
7545
- }
7546
- function _toPropertyKey(t) {
7547
- var i = _toPrimitive(t, "string");
7548
- return "symbol" == typeof i ? i : i + "";
7549
- }
7550
- function _typeof(o) {
7551
- "@babel/helpers - typeof";
7552
-
7553
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
7554
- return typeof o;
7555
- } : function (o) {
7556
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
7557
- }, _typeof(o);
7558
- }
7559
-
7560
- var version = "1.15.7";
7561
-
7562
- function userAgent(pattern) {
7563
- if (typeof window !== 'undefined' && window.navigator) {
7564
- return !! /*@__PURE__*/navigator.userAgent.match(pattern);
7565
- }
7566
- }
7567
- var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
7568
- var Edge = userAgent(/Edge/i);
7569
- var FireFox = userAgent(/firefox/i);
7570
- var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
7571
- var IOS = userAgent(/iP(ad|od|hone)/i);
7572
- var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
7573
-
7574
- var captureMode = {
7575
- capture: false,
7576
- passive: false
7577
- };
7578
- function on(el, event, fn) {
7579
- el.addEventListener(event, fn, !IE11OrLess && captureMode);
7580
- }
7581
- function off(el, event, fn) {
7582
- el.removeEventListener(event, fn, !IE11OrLess && captureMode);
7583
- }
7584
- function matches( /**HTMLElement*/el, /**String*/selector) {
7585
- if (!selector) return;
7586
- selector[0] === '>' && (selector = selector.substring(1));
7587
- if (el) {
7588
- try {
7589
- if (el.matches) {
7590
- return el.matches(selector);
7591
- } else if (el.msMatchesSelector) {
7592
- return el.msMatchesSelector(selector);
7593
- } else if (el.webkitMatchesSelector) {
7594
- return el.webkitMatchesSelector(selector);
7595
- }
7596
- } catch (_) {
7597
- return false;
7598
- }
7599
- }
7600
- return false;
7601
- }
7602
- function getParentOrHost(el) {
7603
- return el.host && el !== document && el.host.nodeType && el.host !== el ? el.host : el.parentNode;
7604
- }
7605
- function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
7606
- if (el) {
7607
- ctx = ctx || document;
7608
- do {
7609
- if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
7610
- return el;
7611
- }
7612
- if (el === ctx) break;
7613
- /* jshint boss:true */
7614
- } while (el = getParentOrHost(el));
7615
- }
7616
- return null;
7617
- }
7618
- var R_SPACE = /\s+/g;
7619
- function toggleClass(el, name, state) {
7620
- if (el && name) {
7621
- if (el.classList) {
7622
- el.classList[state ? 'add' : 'remove'](name);
7623
- } else {
7624
- var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
7625
- el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
7626
- }
7627
- }
7628
- }
7629
- function css(el, prop, val) {
7630
- var style = el && el.style;
7631
- if (style) {
7632
- if (val === void 0) {
7633
- if (document.defaultView && document.defaultView.getComputedStyle) {
7634
- val = document.defaultView.getComputedStyle(el, '');
7635
- } else if (el.currentStyle) {
7636
- val = el.currentStyle;
7637
- }
7638
- return prop === void 0 ? val : val[prop];
7639
- } else {
7640
- if (!(prop in style) && prop.indexOf('webkit') === -1) {
7641
- prop = '-webkit-' + prop;
7642
- }
7643
- style[prop] = val + (typeof val === 'string' ? '' : 'px');
7644
- }
7645
- }
7646
- }
7647
- function matrix(el, selfOnly) {
7648
- var appliedTransforms = '';
7649
- if (typeof el === 'string') {
7650
- appliedTransforms = el;
7651
- } else {
7652
- do {
7653
- var transform = css(el, 'transform');
7654
- if (transform && transform !== 'none') {
7655
- appliedTransforms = transform + ' ' + appliedTransforms;
7656
- }
7657
- /* jshint boss:true */
7658
- } while (!selfOnly && (el = el.parentNode));
7659
- }
7660
- var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
7661
- /*jshint -W056 */
7662
- return matrixFn && new matrixFn(appliedTransforms);
7663
- }
7664
- function find(ctx, tagName, iterator) {
7665
- if (ctx) {
7666
- var list = ctx.getElementsByTagName(tagName),
7667
- i = 0,
7668
- n = list.length;
7669
- if (iterator) {
7670
- for (; i < n; i++) {
7671
- iterator(list[i], i);
7672
- }
7673
- }
7674
- return list;
7675
- }
7676
- return [];
7677
- }
7678
- function getWindowScrollingElement() {
7679
- var scrollingElement = document.scrollingElement;
7680
- if (scrollingElement) {
7681
- return scrollingElement;
7682
- } else {
7683
- return document.documentElement;
7684
- }
7685
- }
7686
-
7687
- /**
7688
- * Returns the "bounding client rect" of given element
7689
- * @param {HTMLElement} el The element whose boundingClientRect is wanted
7690
- * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
7691
- * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
7692
- * @param {[Boolean]} undoScale Whether the container's scale() should be undone
7693
- * @param {[HTMLElement]} container The parent the element will be placed in
7694
- * @return {Object} The boundingClientRect of el, with specified adjustments
7695
- */
7696
- function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
7697
- if (!el.getBoundingClientRect && el !== window) return;
7698
- var elRect, top, left, bottom, right, height, width;
7699
- if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
7700
- elRect = el.getBoundingClientRect();
7701
- top = elRect.top;
7702
- left = elRect.left;
7703
- bottom = elRect.bottom;
7704
- right = elRect.right;
7705
- height = elRect.height;
7706
- width = elRect.width;
7707
- } else {
7708
- top = 0;
7709
- left = 0;
7710
- bottom = window.innerHeight;
7711
- right = window.innerWidth;
7712
- height = window.innerHeight;
7713
- width = window.innerWidth;
7714
- }
7715
- if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
7716
- // Adjust for translate()
7717
- container = container || el.parentNode;
7718
-
7719
- // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
7720
- // Not needed on <= IE11
7721
- if (!IE11OrLess) {
7722
- do {
7723
- if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
7724
- var containerRect = container.getBoundingClientRect();
7725
-
7726
- // Set relative to edges of padding box of container
7727
- top -= containerRect.top + parseInt(css(container, 'border-top-width'));
7728
- left -= containerRect.left + parseInt(css(container, 'border-left-width'));
7729
- bottom = top + elRect.height;
7730
- right = left + elRect.width;
7731
- break;
7732
- }
7733
- /* jshint boss:true */
7734
- } while (container = container.parentNode);
7735
- }
7736
- }
7737
- if (undoScale && el !== window) {
7738
- // Adjust for scale()
7739
- var elMatrix = matrix(container || el),
7740
- scaleX = elMatrix && elMatrix.a,
7741
- scaleY = elMatrix && elMatrix.d;
7742
- if (elMatrix) {
7743
- top /= scaleY;
7744
- left /= scaleX;
7745
- width /= scaleX;
7746
- height /= scaleY;
7747
- bottom = top + height;
7748
- right = left + width;
7749
- }
7750
- }
7751
- return {
7752
- top: top,
7753
- left: left,
7754
- bottom: bottom,
7755
- right: right,
7756
- width: width,
7757
- height: height
7758
- };
7759
- }
7760
-
7761
- /**
7762
- * Checks if a side of an element is scrolled past a side of its parents
7763
- * @param {HTMLElement} el The element who's side being scrolled out of view is in question
7764
- * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
7765
- * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
7766
- * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
7767
- */
7768
- function isScrolledPast(el, elSide, parentSide) {
7769
- var parent = getParentAutoScrollElement(el, true),
7770
- elSideVal = getRect(el)[elSide];
7771
-
7772
- /* jshint boss:true */
7773
- while (parent) {
7774
- var parentSideVal = getRect(parent)[parentSide],
7775
- visible = void 0;
7776
- if (parentSide === 'top' || parentSide === 'left') {
7777
- visible = elSideVal >= parentSideVal;
7778
- } else {
7779
- visible = elSideVal <= parentSideVal;
7780
- }
7781
- if (!visible) return parent;
7782
- if (parent === getWindowScrollingElement()) break;
7783
- parent = getParentAutoScrollElement(parent, false);
7784
- }
7785
- return false;
7786
- }
7787
-
7788
- /**
7789
- * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
7790
- * and non-draggable elements
7791
- * @param {HTMLElement} el The parent element
7792
- * @param {Number} childNum The index of the child
7793
- * @param {Object} options Parent Sortable's options
7794
- * @return {HTMLElement} The child at index childNum, or null if not found
7795
- */
7796
- function getChild(el, childNum, options, includeDragEl) {
7797
- var currentChild = 0,
7798
- i = 0,
7799
- children = el.children;
7800
- while (i < children.length) {
7801
- if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
7802
- if (currentChild === childNum) {
7803
- return children[i];
7804
- }
7805
- currentChild++;
7806
- }
7807
- i++;
7808
- }
7809
- return null;
7810
- }
7811
-
7812
- /**
7813
- * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
7814
- * @param {HTMLElement} el Parent element
7815
- * @param {selector} selector Any other elements that should be ignored
7816
- * @return {HTMLElement} The last child, ignoring ghostEl
7817
- */
7818
- function lastChild(el, selector) {
7819
- var last = el.lastElementChild;
7820
- while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
7821
- last = last.previousElementSibling;
7822
- }
7823
- return last || null;
7824
- }
7825
-
7826
- /**
7827
- * Returns the index of an element within its parent for a selected set of
7828
- * elements
7829
- * @param {HTMLElement} el
7830
- * @param {selector} selector
7831
- * @return {number}
7832
- */
7833
- function index$1(el, selector) {
7834
- var index = 0;
7835
- if (!el || !el.parentNode) {
7836
- return -1;
7837
- }
7838
-
7839
- /* jshint boss:true */
7840
- while (el = el.previousElementSibling) {
7841
- if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
7842
- index++;
7843
- }
7844
- }
7845
- return index;
7846
- }
7847
-
7848
- /**
7849
- * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
7850
- * The value is returned in real pixels.
7851
- * @param {HTMLElement} el
7852
- * @return {Array} Offsets in the format of [left, top]
7853
- */
7854
- function getRelativeScrollOffset(el) {
7855
- var offsetLeft = 0,
7856
- offsetTop = 0,
7857
- winScroller = getWindowScrollingElement();
7858
- if (el) {
7859
- do {
7860
- var elMatrix = matrix(el),
7861
- scaleX = elMatrix.a,
7862
- scaleY = elMatrix.d;
7863
- offsetLeft += el.scrollLeft * scaleX;
7864
- offsetTop += el.scrollTop * scaleY;
7865
- } while (el !== winScroller && (el = el.parentNode));
7866
- }
7867
- return [offsetLeft, offsetTop];
7868
- }
7869
-
7870
- /**
7871
- * Returns the index of the object within the given array
7872
- * @param {Array} arr Array that may or may not hold the object
7873
- * @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
7874
- * @return {Number} The index of the object in the array, or -1
7875
- */
7876
- function indexOfObject(arr, obj) {
7877
- for (var i in arr) {
7878
- if (!arr.hasOwnProperty(i)) continue;
7879
- for (var key in obj) {
7880
- if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
7881
- }
7882
- }
7883
- return -1;
7884
- }
7885
- function getParentAutoScrollElement(el, includeSelf) {
7886
- // skip to window
7887
- if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
7888
- var elem = el;
7889
- var gotSelf = false;
7890
- do {
7891
- // we don't need to get elem css if it isn't even overflowing in the first place (performance)
7892
- if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
7893
- var elemCSS = css(elem);
7894
- if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
7895
- if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
7896
- if (gotSelf || includeSelf) return elem;
7897
- gotSelf = true;
7898
- }
7899
- }
7900
- /* jshint boss:true */
7901
- } while (elem = elem.parentNode);
7902
- return getWindowScrollingElement();
7903
- }
7904
- function extend(dst, src) {
7905
- if (dst && src) {
7906
- for (var key in src) {
7907
- if (src.hasOwnProperty(key)) {
7908
- dst[key] = src[key];
7909
- }
7910
- }
7911
- }
7912
- return dst;
7913
- }
7914
- function isRectEqual(rect1, rect2) {
7915
- 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);
7916
- }
7917
- var _throttleTimeout;
7918
- function throttle(callback, ms) {
7919
- return function () {
7920
- if (!_throttleTimeout) {
7921
- var args = arguments,
7922
- _this = this;
7923
- if (args.length === 1) {
7924
- callback.call(_this, args[0]);
7925
- } else {
7926
- callback.apply(_this, args);
7927
- }
7928
- _throttleTimeout = setTimeout(function () {
7929
- _throttleTimeout = void 0;
7930
- }, ms);
7931
- }
7932
- };
7933
- }
7934
- function cancelThrottle() {
7935
- clearTimeout(_throttleTimeout);
7936
- _throttleTimeout = void 0;
7937
- }
7938
- function scrollBy(el, x, y) {
7939
- el.scrollLeft += x;
7940
- el.scrollTop += y;
7941
- }
7942
- function clone(el) {
7943
- var Polymer = window.Polymer;
7944
- var $ = window.jQuery || window.Zepto;
7945
- if (Polymer && Polymer.dom) {
7946
- return Polymer.dom(el).cloneNode(true);
7947
- } else if ($) {
7948
- return $(el).clone(true)[0];
7949
- } else {
7950
- return el.cloneNode(true);
7951
- }
7952
- }
7953
- function getChildContainingRectFromElement(container, options, ghostEl) {
7954
- var rect = {};
7955
- Array.from(container.children).forEach(function (child) {
7956
- var _rect$left, _rect$top, _rect$right, _rect$bottom;
7957
- if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
7958
- var childRect = getRect(child);
7959
- rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
7960
- rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
7961
- rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
7962
- rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
7963
- });
7964
- rect.width = rect.right - rect.left;
7965
- rect.height = rect.bottom - rect.top;
7966
- rect.x = rect.left;
7967
- rect.y = rect.top;
7968
- return rect;
7969
- }
7970
- var expando = 'Sortable' + new Date().getTime();
7971
-
7972
- function AnimationStateManager() {
7973
- var animationStates = [],
7974
- animationCallbackId;
7975
- return {
7976
- captureAnimationState: function captureAnimationState() {
7977
- animationStates = [];
7978
- if (!this.options.animation) return;
7979
- var children = [].slice.call(this.el.children);
7980
- children.forEach(function (child) {
7981
- if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
7982
- animationStates.push({
7983
- target: child,
7984
- rect: getRect(child)
7985
- });
7986
- var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
7987
-
7988
- // If animating: compensate for current animation
7989
- if (child.thisAnimationDuration) {
7990
- var childMatrix = matrix(child, true);
7991
- if (childMatrix) {
7992
- fromRect.top -= childMatrix.f;
7993
- fromRect.left -= childMatrix.e;
7994
- }
7995
- }
7996
- child.fromRect = fromRect;
7997
- });
7998
- },
7999
- addAnimationState: function addAnimationState(state) {
8000
- animationStates.push(state);
8001
- },
8002
- removeAnimationState: function removeAnimationState(target) {
8003
- animationStates.splice(indexOfObject(animationStates, {
8004
- target: target
8005
- }), 1);
8006
- },
8007
- animateAll: function animateAll(callback) {
8008
- var _this = this;
8009
- if (!this.options.animation) {
8010
- clearTimeout(animationCallbackId);
8011
- if (typeof callback === 'function') callback();
8012
- return;
8013
- }
8014
- var animating = false,
8015
- animationTime = 0;
8016
- animationStates.forEach(function (state) {
8017
- var time = 0,
8018
- target = state.target,
8019
- fromRect = target.fromRect,
8020
- toRect = getRect(target),
8021
- prevFromRect = target.prevFromRect,
8022
- prevToRect = target.prevToRect,
8023
- animatingRect = state.rect,
8024
- targetMatrix = matrix(target, true);
8025
- if (targetMatrix) {
8026
- // Compensate for current animation
8027
- toRect.top -= targetMatrix.f;
8028
- toRect.left -= targetMatrix.e;
8029
- }
8030
- target.toRect = toRect;
8031
- if (target.thisAnimationDuration) {
8032
- // Could also check if animatingRect is between fromRect and toRect
8033
- if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
8034
- // Make sure animatingRect is on line between toRect & fromRect
8035
- (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
8036
- // If returning to same place as started from animation and on same axis
8037
- time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
8038
- }
8039
- }
8040
-
8041
- // if fromRect != toRect: animate
8042
- if (!isRectEqual(toRect, fromRect)) {
8043
- target.prevFromRect = fromRect;
8044
- target.prevToRect = toRect;
8045
- if (!time) {
8046
- time = _this.options.animation;
8047
- }
8048
- _this.animate(target, animatingRect, toRect, time);
8049
- }
8050
- if (time) {
8051
- animating = true;
8052
- animationTime = Math.max(animationTime, time);
8053
- clearTimeout(target.animationResetTimer);
8054
- target.animationResetTimer = setTimeout(function () {
8055
- target.animationTime = 0;
8056
- target.prevFromRect = null;
8057
- target.fromRect = null;
8058
- target.prevToRect = null;
8059
- target.thisAnimationDuration = null;
8060
- }, time);
8061
- target.thisAnimationDuration = time;
8062
- }
8063
- });
8064
- clearTimeout(animationCallbackId);
8065
- if (!animating) {
8066
- if (typeof callback === 'function') callback();
8067
- } else {
8068
- animationCallbackId = setTimeout(function () {
8069
- if (typeof callback === 'function') callback();
8070
- }, animationTime);
8071
- }
8072
- animationStates = [];
8073
- },
8074
- animate: function animate(target, currentRect, toRect, duration) {
8075
- if (duration) {
8076
- css(target, 'transition', '');
8077
- css(target, 'transform', '');
8078
- var elMatrix = matrix(this.el),
8079
- scaleX = elMatrix && elMatrix.a,
8080
- scaleY = elMatrix && elMatrix.d,
8081
- translateX = (currentRect.left - toRect.left) / (scaleX || 1),
8082
- translateY = (currentRect.top - toRect.top) / (scaleY || 1);
8083
- target.animatingX = !!translateX;
8084
- target.animatingY = !!translateY;
8085
- css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
8086
- this.forRepaintDummy = repaint(target); // repaint
8087
-
8088
- css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
8089
- css(target, 'transform', 'translate3d(0,0,0)');
8090
- typeof target.animated === 'number' && clearTimeout(target.animated);
8091
- target.animated = setTimeout(function () {
8092
- css(target, 'transition', '');
8093
- css(target, 'transform', '');
8094
- target.animated = false;
8095
- target.animatingX = false;
8096
- target.animatingY = false;
8097
- }, duration);
8098
- }
8099
- }
8100
- };
8101
- }
8102
- function repaint(target) {
8103
- return target.offsetWidth;
8104
- }
8105
- function calculateRealTime(animatingRect, fromRect, toRect, options) {
8106
- 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;
8107
- }
8108
-
8109
- var plugins = [];
8110
- var defaults = {
8111
- initializeByDefault: true
8112
- };
8113
- var PluginManager = {
8114
- mount: function mount(plugin) {
8115
- // Set default static properties
8116
- for (var option in defaults) {
8117
- if (defaults.hasOwnProperty(option) && !(option in plugin)) {
8118
- plugin[option] = defaults[option];
8119
- }
8120
- }
8121
- plugins.forEach(function (p) {
8122
- if (p.pluginName === plugin.pluginName) {
8123
- throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
8124
- }
8125
- });
8126
- plugins.push(plugin);
8127
- },
8128
- pluginEvent: function pluginEvent(eventName, sortable, evt) {
8129
- var _this = this;
8130
- this.eventCanceled = false;
8131
- evt.cancel = function () {
8132
- _this.eventCanceled = true;
8133
- };
8134
- var eventNameGlobal = eventName + 'Global';
8135
- plugins.forEach(function (plugin) {
8136
- if (!sortable[plugin.pluginName]) return;
8137
- // Fire global events if it exists in this sortable
8138
- if (sortable[plugin.pluginName][eventNameGlobal]) {
8139
- sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
8140
- sortable: sortable
8141
- }, evt));
8142
- }
8143
-
8144
- // Only fire plugin event if plugin is enabled in this sortable,
8145
- // and plugin has event defined
8146
- if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
8147
- sortable[plugin.pluginName][eventName](_objectSpread2({
8148
- sortable: sortable
8149
- }, evt));
8150
- }
8151
- });
8152
- },
8153
- initializePlugins: function initializePlugins(sortable, el, defaults, options) {
8154
- plugins.forEach(function (plugin) {
8155
- var pluginName = plugin.pluginName;
8156
- if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
8157
- var initialized = new plugin(sortable, el, sortable.options);
8158
- initialized.sortable = sortable;
8159
- initialized.options = sortable.options;
8160
- sortable[pluginName] = initialized;
8161
-
8162
- // Add default options from plugin
8163
- _extends(defaults, initialized.defaults);
8164
- });
8165
- for (var option in sortable.options) {
8166
- if (!sortable.options.hasOwnProperty(option)) continue;
8167
- var modified = this.modifyOption(sortable, option, sortable.options[option]);
8168
- if (typeof modified !== 'undefined') {
8169
- sortable.options[option] = modified;
8170
- }
8171
- }
8172
- },
8173
- getEventProperties: function getEventProperties(name, sortable) {
8174
- var eventProperties = {};
8175
- plugins.forEach(function (plugin) {
8176
- if (typeof plugin.eventProperties !== 'function') return;
8177
- _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
8178
- });
8179
- return eventProperties;
8180
- },
8181
- modifyOption: function modifyOption(sortable, name, value) {
8182
- var modifiedValue;
8183
- plugins.forEach(function (plugin) {
8184
- // Plugin must exist on the Sortable
8185
- if (!sortable[plugin.pluginName]) return;
8186
-
8187
- // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
8188
- if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
8189
- modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
8190
- }
8191
- });
8192
- return modifiedValue;
8193
- }
8194
- };
8195
-
8196
- function dispatchEvent(_ref) {
8197
- var sortable = _ref.sortable,
8198
- rootEl = _ref.rootEl,
8199
- name = _ref.name,
8200
- targetEl = _ref.targetEl,
8201
- cloneEl = _ref.cloneEl,
8202
- toEl = _ref.toEl,
8203
- fromEl = _ref.fromEl,
8204
- oldIndex = _ref.oldIndex,
8205
- newIndex = _ref.newIndex,
8206
- oldDraggableIndex = _ref.oldDraggableIndex,
8207
- newDraggableIndex = _ref.newDraggableIndex,
8208
- originalEvent = _ref.originalEvent,
8209
- putSortable = _ref.putSortable,
8210
- extraEventProperties = _ref.extraEventProperties;
8211
- sortable = sortable || rootEl && rootEl[expando];
8212
- if (!sortable) return;
8213
- var evt,
8214
- options = sortable.options,
8215
- onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
8216
- // Support for new CustomEvent feature
8217
- if (window.CustomEvent && !IE11OrLess && !Edge) {
8218
- evt = new CustomEvent(name, {
8219
- bubbles: true,
8220
- cancelable: true
8221
- });
8222
- } else {
8223
- evt = document.createEvent('Event');
8224
- evt.initEvent(name, true, true);
8225
- }
8226
- evt.to = toEl || rootEl;
8227
- evt.from = fromEl || rootEl;
8228
- evt.item = targetEl || rootEl;
8229
- evt.clone = cloneEl;
8230
- evt.oldIndex = oldIndex;
8231
- evt.newIndex = newIndex;
8232
- evt.oldDraggableIndex = oldDraggableIndex;
8233
- evt.newDraggableIndex = newDraggableIndex;
8234
- evt.originalEvent = originalEvent;
8235
- evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
8236
- var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
8237
- for (var option in allEventProperties) {
8238
- evt[option] = allEventProperties[option];
8239
- }
8240
- if (rootEl) {
8241
- rootEl.dispatchEvent(evt);
8242
- }
8243
- if (options[onName]) {
8244
- options[onName].call(sortable, evt);
8245
- }
8246
- }
8247
-
8248
- var _excluded = ["evt"];
8249
- var pluginEvent = function pluginEvent(eventName, sortable) {
8250
- var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
8251
- originalEvent = _ref.evt,
8252
- data = _objectWithoutProperties(_ref, _excluded);
8253
- PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
8254
- dragEl: dragEl,
8255
- parentEl: parentEl,
8256
- ghostEl: ghostEl,
8257
- rootEl: rootEl,
8258
- nextEl: nextEl,
8259
- lastDownEl: lastDownEl,
8260
- cloneEl: cloneEl,
8261
- cloneHidden: cloneHidden,
8262
- dragStarted: moved,
8263
- putSortable: putSortable,
8264
- activeSortable: Sortable.active,
8265
- originalEvent: originalEvent,
8266
- oldIndex: oldIndex,
8267
- oldDraggableIndex: oldDraggableIndex,
8268
- newIndex: newIndex,
8269
- newDraggableIndex: newDraggableIndex,
8270
- hideGhostForTarget: _hideGhostForTarget,
8271
- unhideGhostForTarget: _unhideGhostForTarget,
8272
- cloneNowHidden: function cloneNowHidden() {
8273
- cloneHidden = true;
8274
- },
8275
- cloneNowShown: function cloneNowShown() {
8276
- cloneHidden = false;
8277
- },
8278
- dispatchSortableEvent: function dispatchSortableEvent(name) {
8279
- _dispatchEvent({
8280
- sortable: sortable,
8281
- name: name,
8282
- originalEvent: originalEvent
8283
- });
8284
- }
8285
- }, data));
8286
- };
8287
- function _dispatchEvent(info) {
8288
- dispatchEvent(_objectSpread2({
8289
- putSortable: putSortable,
8290
- cloneEl: cloneEl,
8291
- targetEl: dragEl,
8292
- rootEl: rootEl,
8293
- oldIndex: oldIndex,
8294
- oldDraggableIndex: oldDraggableIndex,
8295
- newIndex: newIndex,
8296
- newDraggableIndex: newDraggableIndex
8297
- }, info));
8298
- }
8299
- var dragEl,
8300
- parentEl,
8301
- ghostEl,
8302
- rootEl,
8303
- nextEl,
8304
- lastDownEl,
8305
- cloneEl,
8306
- cloneHidden,
8307
- oldIndex,
8308
- newIndex,
8309
- oldDraggableIndex,
8310
- newDraggableIndex,
8311
- activeGroup,
8312
- putSortable,
8313
- awaitingDragStarted = false,
8314
- ignoreNextClick = false,
8315
- sortables = [],
8316
- tapEvt,
8317
- touchEvt,
8318
- lastDx,
8319
- lastDy,
8320
- tapDistanceLeft,
8321
- tapDistanceTop,
8322
- moved,
8323
- lastTarget,
8324
- lastDirection,
8325
- pastFirstInvertThresh = false,
8326
- isCircumstantialInvert = false,
8327
- targetMoveDistance,
8328
- // For positioning ghost absolutely
8329
- ghostRelativeParent,
8330
- ghostRelativeParentInitialScroll = [],
8331
- // (left, top)
8332
-
8333
- _silent = false,
8334
- savedInputChecked = [];
8335
-
8336
- /** @const */
8337
- var documentExists = typeof document !== 'undefined',
8338
- PositionGhostAbsolutely = IOS,
8339
- CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
8340
- // This will not pass for IE9, because IE9 DnD only works on anchors
8341
- supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
8342
- supportCssPointerEvents = function () {
8343
- if (!documentExists) return;
8344
- // false when <= IE11
8345
- if (IE11OrLess) {
8346
- return false;
8347
- }
8348
- var el = document.createElement('x');
8349
- el.style.cssText = 'pointer-events:auto';
8350
- return el.style.pointerEvents === 'auto';
8351
- }(),
8352
- _detectDirection = function _detectDirection(el, options) {
8353
- var elCSS = css(el),
8354
- elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
8355
- child1 = getChild(el, 0, options),
8356
- child2 = getChild(el, 1, options),
8357
- firstChildCSS = child1 && css(child1),
8358
- secondChildCSS = child2 && css(child2),
8359
- firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
8360
- secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
8361
- if (elCSS.display === 'flex') {
8362
- return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
8363
- }
8364
- if (elCSS.display === 'grid') {
8365
- return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
8366
- }
8367
- if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
8368
- var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
8369
- return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
8370
- }
8371
- 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';
8372
- },
8373
- _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
8374
- var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
8375
- dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
8376
- dragElOppLength = vertical ? dragRect.width : dragRect.height,
8377
- targetS1Opp = vertical ? targetRect.left : targetRect.top,
8378
- targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
8379
- targetOppLength = vertical ? targetRect.width : targetRect.height;
8380
- return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
8381
- },
8382
- /**
8383
- * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
8384
- * @param {Number} x X position
8385
- * @param {Number} y Y position
8386
- * @return {HTMLElement} Element of the first found nearest Sortable
8387
- */
8388
- _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
8389
- var ret;
8390
- sortables.some(function (sortable) {
8391
- var threshold = sortable[expando].options.emptyInsertThreshold;
8392
- if (!threshold || lastChild(sortable)) return;
8393
- var rect = getRect(sortable),
8394
- insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
8395
- insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
8396
- if (insideHorizontally && insideVertically) {
8397
- return ret = sortable;
8398
- }
8399
- });
8400
- return ret;
8401
- },
8402
- _prepareGroup = function _prepareGroup(options) {
8403
- function toFn(value, pull) {
8404
- return function (to, from, dragEl, evt) {
8405
- var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
8406
- if (value == null && (pull || sameGroup)) {
8407
- // Default pull value
8408
- // Default pull and put value if same group
8409
- return true;
8410
- } else if (value == null || value === false) {
8411
- return false;
8412
- } else if (pull && value === 'clone') {
8413
- return value;
8414
- } else if (typeof value === 'function') {
8415
- return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
8416
- } else {
8417
- var otherGroup = (pull ? to : from).options.group.name;
8418
- return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
8419
- }
8420
- };
8421
- }
8422
- var group = {};
8423
- var originalGroup = options.group;
8424
- if (!originalGroup || _typeof(originalGroup) != 'object') {
8425
- originalGroup = {
8426
- name: originalGroup
8427
- };
8428
- }
8429
- group.name = originalGroup.name;
8430
- group.checkPull = toFn(originalGroup.pull, true);
8431
- group.checkPut = toFn(originalGroup.put);
8432
- group.revertClone = originalGroup.revertClone;
8433
- options.group = group;
8434
- },
8435
- _hideGhostForTarget = function _hideGhostForTarget() {
8436
- if (!supportCssPointerEvents && ghostEl) {
8437
- css(ghostEl, 'display', 'none');
8438
- }
8439
- },
8440
- _unhideGhostForTarget = function _unhideGhostForTarget() {
8441
- if (!supportCssPointerEvents && ghostEl) {
8442
- css(ghostEl, 'display', '');
8443
- }
8444
- };
8445
-
8446
- // #1184 fix - Prevent click event on fallback if dragged but item not changed position
8447
- if (documentExists && !ChromeForAndroid) {
8448
- document.addEventListener('click', function (evt) {
8449
- if (ignoreNextClick) {
8450
- evt.preventDefault();
8451
- evt.stopPropagation && evt.stopPropagation();
8452
- evt.stopImmediatePropagation && evt.stopImmediatePropagation();
8453
- ignoreNextClick = false;
8454
- return false;
8455
- }
8456
- }, true);
8457
- }
8458
- var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
8459
- if (dragEl) {
8460
- evt = evt.touches ? evt.touches[0] : evt;
8461
- var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
8462
- if (nearest) {
8463
- // Create imitation event
8464
- var event = {};
8465
- for (var i in evt) {
8466
- if (evt.hasOwnProperty(i)) {
8467
- event[i] = evt[i];
8468
- }
8469
- }
8470
- event.target = event.rootEl = nearest;
8471
- event.preventDefault = void 0;
8472
- event.stopPropagation = void 0;
8473
- nearest[expando]._onDragOver(event);
8474
- }
8475
- }
8476
- };
8477
- var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
8478
- if (dragEl) {
8479
- dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
8480
- }
8481
- };
8482
-
8483
- /**
8484
- * @class Sortable
8485
- * @param {HTMLElement} el
8486
- * @param {Object} [options]
8487
- */
8488
- function Sortable(el, options) {
8489
- if (!(el && el.nodeType && el.nodeType === 1)) {
8490
- throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
8491
- }
8492
- this.el = el; // root element
8493
- this.options = options = _extends({}, options);
8494
-
8495
- // Export instance
8496
- el[expando] = this;
8497
- var defaults = {
8498
- group: null,
8499
- sort: true,
8500
- disabled: false,
8501
- store: null,
8502
- handle: null,
8503
- draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
8504
- swapThreshold: 1,
8505
- // percentage; 0 <= x <= 1
8506
- invertSwap: false,
8507
- // invert always
8508
- invertedSwapThreshold: null,
8509
- // will be set to same as swapThreshold if default
8510
- removeCloneOnHide: true,
8511
- direction: function direction() {
8512
- return _detectDirection(el, this.options);
8513
- },
8514
- ghostClass: 'sortable-ghost',
8515
- chosenClass: 'sortable-chosen',
8516
- dragClass: 'sortable-drag',
8517
- ignore: 'a, img',
8518
- filter: null,
8519
- preventOnFilter: true,
8520
- animation: 0,
8521
- easing: null,
8522
- setData: function setData(dataTransfer, dragEl) {
8523
- dataTransfer.setData('Text', dragEl.textContent);
8524
- },
8525
- dropBubble: false,
8526
- dragoverBubble: false,
8527
- dataIdAttr: 'data-id',
8528
- delay: 0,
8529
- delayOnTouchOnly: false,
8530
- touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
8531
- forceFallback: false,
8532
- fallbackClass: 'sortable-fallback',
8533
- fallbackOnBody: false,
8534
- fallbackTolerance: 0,
8535
- fallbackOffset: {
8536
- x: 0,
8537
- y: 0
8538
- },
8539
- // Disabled on Safari: #1571; Enabled on Safari IOS: #2244
8540
- supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && (!Safari || IOS),
8541
- emptyInsertThreshold: 5
8542
- };
8543
- PluginManager.initializePlugins(this, el, defaults);
8544
-
8545
- // Set default options
8546
- for (var name in defaults) {
8547
- !(name in options) && (options[name] = defaults[name]);
8548
- }
8549
- _prepareGroup(options);
8550
-
8551
- // Bind all private methods
8552
- for (var fn in this) {
8553
- if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
8554
- this[fn] = this[fn].bind(this);
8555
- }
8556
- }
8557
-
8558
- // Setup drag mode
8559
- this.nativeDraggable = options.forceFallback ? false : supportDraggable;
8560
- if (this.nativeDraggable) {
8561
- // Touch start threshold cannot be greater than the native dragstart threshold
8562
- this.options.touchStartThreshold = 1;
8563
- }
8564
-
8565
- // Bind events
8566
- if (options.supportPointer) {
8567
- on(el, 'pointerdown', this._onTapStart);
8568
- } else {
8569
- on(el, 'mousedown', this._onTapStart);
8570
- on(el, 'touchstart', this._onTapStart);
8571
- }
8572
- if (this.nativeDraggable) {
8573
- on(el, 'dragover', this);
8574
- on(el, 'dragenter', this);
8575
- }
8576
- sortables.push(this.el);
8577
-
8578
- // Restore sorting
8579
- options.store && options.store.get && this.sort(options.store.get(this) || []);
8580
-
8581
- // Add animation state manager
8582
- _extends(this, AnimationStateManager());
8583
- }
8584
- Sortable.prototype = /** @lends Sortable.prototype */{
8585
- constructor: Sortable,
8586
- _isOutsideThisEl: function _isOutsideThisEl(target) {
8587
- if (!this.el.contains(target) && target !== this.el) {
8588
- lastTarget = null;
8589
- }
8590
- },
8591
- _getDirection: function _getDirection(evt, target) {
8592
- return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
8593
- },
8594
- _onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
8595
- if (!evt.cancelable) return;
8596
- var _this = this,
8597
- el = this.el,
8598
- options = this.options,
8599
- preventOnFilter = options.preventOnFilter,
8600
- type = evt.type,
8601
- touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
8602
- target = (touch || evt).target,
8603
- originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
8604
- filter = options.filter;
8605
- _saveInputCheckedState(el);
8606
-
8607
- // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
8608
- if (dragEl) {
8609
- return;
8610
- }
8611
- if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
8612
- return; // only left button and enabled
8613
- }
8614
-
8615
- // cancel dnd if original target is content editable
8616
- if (originalTarget.isContentEditable) {
8617
- return;
8618
- }
8619
-
8620
- // Safari ignores further event handling after mousedown
8621
- if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
8622
- return;
8623
- }
8624
- target = closest(target, options.draggable, el, false);
8625
- if (target && target.animated) {
8626
- return;
8627
- }
8628
- if (lastDownEl === target) {
8629
- // Ignoring duplicate `down`
8630
- return;
8631
- }
8632
-
8633
- // Get the index of the dragged element within its parent
8634
- oldIndex = index$1(target);
8635
- oldDraggableIndex = index$1(target, options.draggable);
8636
-
8637
- // Check filter
8638
- if (typeof filter === 'function') {
8639
- if (filter.call(this, evt, target, this)) {
8640
- _dispatchEvent({
8641
- sortable: _this,
8642
- rootEl: originalTarget,
8643
- name: 'filter',
8644
- targetEl: target,
8645
- toEl: el,
8646
- fromEl: el
8647
- });
8648
- pluginEvent('filter', _this, {
8649
- evt: evt
8650
- });
8651
- preventOnFilter && evt.preventDefault();
8652
- return; // cancel dnd
8653
- }
8654
- } else if (filter) {
8655
- filter = filter.split(',').some(function (criteria) {
8656
- criteria = closest(originalTarget, criteria.trim(), el, false);
8657
- if (criteria) {
8658
- _dispatchEvent({
8659
- sortable: _this,
8660
- rootEl: criteria,
8661
- name: 'filter',
8662
- targetEl: target,
8663
- fromEl: el,
8664
- toEl: el
8665
- });
8666
- pluginEvent('filter', _this, {
8667
- evt: evt
8668
- });
8669
- return true;
8670
- }
8671
- });
8672
- if (filter) {
8673
- preventOnFilter && evt.preventDefault();
8674
- return; // cancel dnd
8675
- }
8676
- }
8677
- if (options.handle && !closest(originalTarget, options.handle, el, false)) {
8678
- return;
8679
- }
8680
-
8681
- // Prepare `dragstart`
8682
- this._prepareDragStart(evt, touch, target);
8683
- },
8684
- _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) {
8685
- var _this = this,
8686
- el = _this.el,
8687
- options = _this.options,
8688
- ownerDocument = el.ownerDocument,
8689
- dragStartFn;
8690
- if (target && !dragEl && target.parentNode === el) {
8691
- var dragRect = getRect(target);
8692
- rootEl = el;
8693
- dragEl = target;
8694
- parentEl = dragEl.parentNode;
8695
- nextEl = dragEl.nextSibling;
8696
- lastDownEl = target;
8697
- activeGroup = options.group;
8698
- Sortable.dragged = dragEl;
8699
- tapEvt = {
8700
- target: dragEl,
8701
- clientX: (touch || evt).clientX,
8702
- clientY: (touch || evt).clientY
8703
- };
8704
- tapDistanceLeft = tapEvt.clientX - dragRect.left;
8705
- tapDistanceTop = tapEvt.clientY - dragRect.top;
8706
- this._lastX = (touch || evt).clientX;
8707
- this._lastY = (touch || evt).clientY;
8708
- dragEl.style['will-change'] = 'all';
8709
- dragStartFn = function dragStartFn() {
8710
- pluginEvent('delayEnded', _this, {
8711
- evt: evt
8712
- });
8713
- if (Sortable.eventCanceled) {
8714
- _this._onDrop();
8715
- return;
8716
- }
8717
- // Delayed drag has been triggered
8718
- // we can re-enable the events: touchmove/mousemove
8719
- _this._disableDelayedDragEvents();
8720
- if (!FireFox && _this.nativeDraggable) {
8721
- dragEl.draggable = true;
8722
- }
8723
-
8724
- // Bind the events: dragstart/dragend
8725
- _this._triggerDragStart(evt, touch);
8726
-
8727
- // Drag start event
8728
- _dispatchEvent({
8729
- sortable: _this,
8730
- name: 'choose',
8731
- originalEvent: evt
8732
- });
8733
-
8734
- // Chosen item
8735
- toggleClass(dragEl, options.chosenClass, true);
8736
- };
8737
-
8738
- // Disable "draggable"
8739
- options.ignore.split(',').forEach(function (criteria) {
8740
- find(dragEl, criteria.trim(), _disableDraggable);
8741
- });
8742
- on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
8743
- on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
8744
- on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
8745
- if (options.supportPointer) {
8746
- on(ownerDocument, 'pointerup', _this._onDrop);
8747
- // Native D&D triggers pointercancel
8748
- !this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
8749
- } else {
8750
- on(ownerDocument, 'mouseup', _this._onDrop);
8751
- on(ownerDocument, 'touchend', _this._onDrop);
8752
- on(ownerDocument, 'touchcancel', _this._onDrop);
8753
- }
8754
-
8755
- // Make dragEl draggable (must be before delay for FireFox)
8756
- if (FireFox && this.nativeDraggable) {
8757
- this.options.touchStartThreshold = 4;
8758
- dragEl.draggable = true;
8759
- }
8760
- pluginEvent('delayStart', this, {
8761
- evt: evt
8762
- });
8763
-
8764
- // Delay is impossible for native DnD in Edge or IE
8765
- if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
8766
- if (Sortable.eventCanceled) {
8767
- this._onDrop();
8768
- return;
8769
- }
8770
- // If the user moves the pointer or let go the click or touch
8771
- // before the delay has been reached:
8772
- // disable the delayed drag
8773
- if (options.supportPointer) {
8774
- on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
8775
- on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
8776
- } else {
8777
- on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
8778
- on(ownerDocument, 'touchend', _this._disableDelayedDrag);
8779
- on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
8780
- }
8781
- on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
8782
- on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
8783
- options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
8784
- _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
8785
- } else {
8786
- dragStartFn();
8787
- }
8788
- }
8789
- },
8790
- _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) {
8791
- var touch = e.touches ? e.touches[0] : e;
8792
- 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))) {
8793
- this._disableDelayedDrag();
8794
- }
8795
- },
8796
- _disableDelayedDrag: function _disableDelayedDrag() {
8797
- dragEl && _disableDraggable(dragEl);
8798
- clearTimeout(this._dragStartTimer);
8799
- this._disableDelayedDragEvents();
8800
- },
8801
- _disableDelayedDragEvents: function _disableDelayedDragEvents() {
8802
- var ownerDocument = this.el.ownerDocument;
8803
- off(ownerDocument, 'mouseup', this._disableDelayedDrag);
8804
- off(ownerDocument, 'touchend', this._disableDelayedDrag);
8805
- off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
8806
- off(ownerDocument, 'pointerup', this._disableDelayedDrag);
8807
- off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
8808
- off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
8809
- off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
8810
- off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
8811
- },
8812
- _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
8813
- touch = touch || evt.pointerType == 'touch' && evt;
8814
- if (!this.nativeDraggable || touch) {
8815
- if (this.options.supportPointer) {
8816
- on(document, 'pointermove', this._onTouchMove);
8817
- } else if (touch) {
8818
- on(document, 'touchmove', this._onTouchMove);
8819
- } else {
8820
- on(document, 'mousemove', this._onTouchMove);
8821
- }
8822
- } else {
8823
- on(dragEl, 'dragend', this);
8824
- on(rootEl, 'dragstart', this._onDragStart);
8825
- }
8826
- try {
8827
- if (document.selection) {
8828
- _nextTick(function () {
8829
- document.selection.empty();
8830
- });
8831
- } else {
8832
- window.getSelection().removeAllRanges();
8833
- }
8834
- } catch (err) {}
8835
- },
8836
- _dragStarted: function _dragStarted(fallback, evt) {
8837
- awaitingDragStarted = false;
8838
- if (rootEl && dragEl) {
8839
- pluginEvent('dragStarted', this, {
8840
- evt: evt
8841
- });
8842
- if (this.nativeDraggable) {
8843
- on(document, 'dragover', _checkOutsideTargetEl);
8844
- }
8845
- var options = this.options;
8846
-
8847
- // Apply effect
8848
- !fallback && toggleClass(dragEl, options.dragClass, false);
8849
- toggleClass(dragEl, options.ghostClass, true);
8850
- Sortable.active = this;
8851
- fallback && this._appendGhost();
8852
-
8853
- // Drag start event
8854
- _dispatchEvent({
8855
- sortable: this,
8856
- name: 'start',
8857
- originalEvent: evt
8858
- });
8859
- } else {
8860
- this._nulling();
8861
- }
8862
- },
8863
- _emulateDragOver: function _emulateDragOver() {
8864
- if (touchEvt) {
8865
- this._lastX = touchEvt.clientX;
8866
- this._lastY = touchEvt.clientY;
8867
- _hideGhostForTarget();
8868
- var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
8869
- var parent = target;
8870
- while (target && target.shadowRoot) {
8871
- target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
8872
- if (target === parent) break;
8873
- parent = target;
8874
- }
8875
- dragEl.parentNode[expando]._isOutsideThisEl(target);
8876
- if (parent) {
8877
- do {
8878
- if (parent[expando]) {
8879
- var inserted = void 0;
8880
- inserted = parent[expando]._onDragOver({
8881
- clientX: touchEvt.clientX,
8882
- clientY: touchEvt.clientY,
8883
- target: target,
8884
- rootEl: parent
8885
- });
8886
- if (inserted && !this.options.dragoverBubble) {
8887
- break;
8888
- }
8889
- }
8890
- target = parent; // store last element
8891
- }
8892
- /* jshint boss:true */ while (parent = getParentOrHost(parent));
8893
- }
8894
- _unhideGhostForTarget();
8895
- }
8896
- },
8897
- _onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
8898
- if (tapEvt) {
8899
- var options = this.options,
8900
- fallbackTolerance = options.fallbackTolerance,
8901
- fallbackOffset = options.fallbackOffset,
8902
- touch = evt.touches ? evt.touches[0] : evt,
8903
- ghostMatrix = ghostEl && matrix(ghostEl, true),
8904
- scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
8905
- scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
8906
- relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
8907
- dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
8908
- dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
8909
-
8910
- // only set the status to dragging, when we are actually dragging
8911
- if (!Sortable.active && !awaitingDragStarted) {
8912
- if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
8913
- return;
8914
- }
8915
- this._onDragStart(evt, true);
8916
- }
8917
- if (ghostEl) {
8918
- if (ghostMatrix) {
8919
- ghostMatrix.e += dx - (lastDx || 0);
8920
- ghostMatrix.f += dy - (lastDy || 0);
8921
- } else {
8922
- ghostMatrix = {
8923
- a: 1,
8924
- b: 0,
8925
- c: 0,
8926
- d: 1,
8927
- e: dx,
8928
- f: dy
8929
- };
8930
- }
8931
- var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
8932
- css(ghostEl, 'webkitTransform', cssMatrix);
8933
- css(ghostEl, 'mozTransform', cssMatrix);
8934
- css(ghostEl, 'msTransform', cssMatrix);
8935
- css(ghostEl, 'transform', cssMatrix);
8936
- lastDx = dx;
8937
- lastDy = dy;
8938
- touchEvt = touch;
8939
- }
8940
- evt.cancelable && evt.preventDefault();
8941
- }
8942
- },
8943
- _appendGhost: function _appendGhost() {
8944
- // Bug if using scale(): https://stackoverflow.com/questions/2637058
8945
- // Not being adjusted for
8946
- if (!ghostEl) {
8947
- var container = this.options.fallbackOnBody ? document.body : rootEl,
8948
- rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
8949
- options = this.options;
8950
-
8951
- // Position absolutely
8952
- if (PositionGhostAbsolutely) {
8953
- // Get relatively positioned parent
8954
- ghostRelativeParent = container;
8955
- while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
8956
- ghostRelativeParent = ghostRelativeParent.parentNode;
8957
- }
8958
- if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
8959
- if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
8960
- rect.top += ghostRelativeParent.scrollTop;
8961
- rect.left += ghostRelativeParent.scrollLeft;
8962
- } else {
8963
- ghostRelativeParent = getWindowScrollingElement();
8964
- }
8965
- ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
8966
- }
8967
- ghostEl = dragEl.cloneNode(true);
8968
- toggleClass(ghostEl, options.ghostClass, false);
8969
- toggleClass(ghostEl, options.fallbackClass, true);
8970
- toggleClass(ghostEl, options.dragClass, true);
8971
- css(ghostEl, 'transition', '');
8972
- css(ghostEl, 'transform', '');
8973
- css(ghostEl, 'box-sizing', 'border-box');
8974
- css(ghostEl, 'margin', 0);
8975
- css(ghostEl, 'top', rect.top);
8976
- css(ghostEl, 'left', rect.left);
8977
- css(ghostEl, 'width', rect.width);
8978
- css(ghostEl, 'height', rect.height);
8979
- css(ghostEl, 'opacity', '0.8');
8980
- css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
8981
- css(ghostEl, 'zIndex', '100000');
8982
- css(ghostEl, 'pointerEvents', 'none');
8983
- Sortable.ghost = ghostEl;
8984
- container.appendChild(ghostEl);
8985
-
8986
- // Set transform-origin
8987
- css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
8988
- }
8989
- },
8990
- _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) {
8991
- var _this = this;
8992
- var dataTransfer = evt.dataTransfer;
8993
- var options = _this.options;
8994
- pluginEvent('dragStart', this, {
8995
- evt: evt
8996
- });
8997
- if (Sortable.eventCanceled) {
8998
- this._onDrop();
8999
- return;
9000
- }
9001
- pluginEvent('setupClone', this);
9002
- if (!Sortable.eventCanceled) {
9003
- cloneEl = clone(dragEl);
9004
- cloneEl.removeAttribute("id");
9005
- cloneEl.draggable = false;
9006
- cloneEl.style['will-change'] = '';
9007
- this._hideClone();
9008
- toggleClass(cloneEl, this.options.chosenClass, false);
9009
- Sortable.clone = cloneEl;
9010
- }
9011
-
9012
- // #1143: IFrame support workaround
9013
- _this.cloneId = _nextTick(function () {
9014
- pluginEvent('clone', _this);
9015
- if (Sortable.eventCanceled) return;
9016
- if (!_this.options.removeCloneOnHide) {
9017
- rootEl.insertBefore(cloneEl, dragEl);
9018
- }
9019
- _this._hideClone();
9020
- _dispatchEvent({
9021
- sortable: _this,
9022
- name: 'clone'
9023
- });
9024
- });
9025
- !fallback && toggleClass(dragEl, options.dragClass, true);
9026
-
9027
- // Set proper drop events
9028
- if (fallback) {
9029
- ignoreNextClick = true;
9030
- _this._loopId = setInterval(_this._emulateDragOver, 50);
9031
- } else {
9032
- // Undo what was set in _prepareDragStart before drag started
9033
- off(document, 'mouseup', _this._onDrop);
9034
- off(document, 'touchend', _this._onDrop);
9035
- off(document, 'touchcancel', _this._onDrop);
9036
- if (dataTransfer) {
9037
- dataTransfer.effectAllowed = 'move';
9038
- options.setData && options.setData.call(_this, dataTransfer, dragEl);
9039
- }
9040
- on(document, 'drop', _this);
9041
-
9042
- // #1276 fix:
9043
- css(dragEl, 'transform', 'translateZ(0)');
9044
- }
9045
- awaitingDragStarted = true;
9046
- _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
9047
- on(document, 'selectstart', _this);
9048
- moved = true;
9049
- window.getSelection().removeAllRanges();
9050
- if (Safari) {
9051
- css(document.body, 'user-select', 'none');
9052
- }
9053
- },
9054
- // Returns true - if no further action is needed (either inserted or another condition)
9055
- _onDragOver: function _onDragOver( /**Event*/evt) {
9056
- var el = this.el,
9057
- target = evt.target,
9058
- dragRect,
9059
- targetRect,
9060
- revert,
9061
- options = this.options,
9062
- group = options.group,
9063
- activeSortable = Sortable.active,
9064
- isOwner = activeGroup === group,
9065
- canSort = options.sort,
9066
- fromSortable = putSortable || activeSortable,
9067
- vertical,
9068
- _this = this,
9069
- completedFired = false;
9070
- if (_silent) return;
9071
- function dragOverEvent(name, extra) {
9072
- pluginEvent(name, _this, _objectSpread2({
9073
- evt: evt,
9074
- isOwner: isOwner,
9075
- axis: vertical ? 'vertical' : 'horizontal',
9076
- revert: revert,
9077
- dragRect: dragRect,
9078
- targetRect: targetRect,
9079
- canSort: canSort,
9080
- fromSortable: fromSortable,
9081
- target: target,
9082
- completed: completed,
9083
- onMove: function onMove(target, after) {
9084
- return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
9085
- },
9086
- changed: changed
9087
- }, extra));
9088
- }
9089
-
9090
- // Capture animation state
9091
- function capture() {
9092
- dragOverEvent('dragOverAnimationCapture');
9093
- _this.captureAnimationState();
9094
- if (_this !== fromSortable) {
9095
- fromSortable.captureAnimationState();
9096
- }
9097
- }
9098
-
9099
- // Return invocation when dragEl is inserted (or completed)
9100
- function completed(insertion) {
9101
- dragOverEvent('dragOverCompleted', {
9102
- insertion: insertion
9103
- });
9104
- if (insertion) {
9105
- // Clones must be hidden before folding animation to capture dragRectAbsolute properly
9106
- if (isOwner) {
9107
- activeSortable._hideClone();
9108
- } else {
9109
- activeSortable._showClone(_this);
9110
- }
9111
- if (_this !== fromSortable) {
9112
- // Set ghost class to new sortable's ghost class
9113
- toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
9114
- toggleClass(dragEl, options.ghostClass, true);
9115
- }
9116
- if (putSortable !== _this && _this !== Sortable.active) {
9117
- putSortable = _this;
9118
- } else if (_this === Sortable.active && putSortable) {
9119
- putSortable = null;
9120
- }
9121
-
9122
- // Animation
9123
- if (fromSortable === _this) {
9124
- _this._ignoreWhileAnimating = target;
9125
- }
9126
- _this.animateAll(function () {
9127
- dragOverEvent('dragOverAnimationComplete');
9128
- _this._ignoreWhileAnimating = null;
9129
- });
9130
- if (_this !== fromSortable) {
9131
- fromSortable.animateAll();
9132
- fromSortable._ignoreWhileAnimating = null;
9133
- }
9134
- }
9135
-
9136
- // Null lastTarget if it is not inside a previously swapped element
9137
- if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
9138
- lastTarget = null;
9139
- }
9140
-
9141
- // no bubbling and not fallback
9142
- if (!options.dragoverBubble && !evt.rootEl && target !== document) {
9143
- dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
9144
-
9145
- // Do not detect for empty insert if already inserted
9146
- !insertion && nearestEmptyInsertDetectEvent(evt);
9147
- }
9148
- !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
9149
- return completedFired = true;
9150
- }
9151
-
9152
- // Call when dragEl has been inserted
9153
- function changed() {
9154
- newIndex = index$1(dragEl);
9155
- newDraggableIndex = index$1(dragEl, options.draggable);
9156
- _dispatchEvent({
9157
- sortable: _this,
9158
- name: 'change',
9159
- toEl: el,
9160
- newIndex: newIndex,
9161
- newDraggableIndex: newDraggableIndex,
9162
- originalEvent: evt
9163
- });
9164
- }
9165
- if (evt.preventDefault !== void 0) {
9166
- evt.cancelable && evt.preventDefault();
9167
- }
9168
- target = closest(target, options.draggable, el, true);
9169
- dragOverEvent('dragOver');
9170
- if (Sortable.eventCanceled) return completedFired;
9171
- if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
9172
- return completed(false);
9173
- }
9174
- ignoreNextClick = false;
9175
- if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
9176
- : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
9177
- vertical = this._getDirection(evt, target) === 'vertical';
9178
- dragRect = getRect(dragEl);
9179
- dragOverEvent('dragOverValid');
9180
- if (Sortable.eventCanceled) return completedFired;
9181
- if (revert) {
9182
- parentEl = rootEl; // actualization
9183
- capture();
9184
- this._hideClone();
9185
- dragOverEvent('revert');
9186
- if (!Sortable.eventCanceled) {
9187
- if (nextEl) {
9188
- rootEl.insertBefore(dragEl, nextEl);
9189
- } else {
9190
- rootEl.appendChild(dragEl);
9191
- }
9192
- }
9193
- return completed(true);
9194
- }
9195
- var elLastChild = lastChild(el, options.draggable);
9196
- if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
9197
- // Insert to end of list
9198
-
9199
- // If already at end of list: Do not insert
9200
- if (elLastChild === dragEl) {
9201
- return completed(false);
9202
- }
9203
-
9204
- // if there is a last element, it is the target
9205
- if (elLastChild && el === evt.target) {
9206
- target = elLastChild;
9207
- }
9208
- if (target) {
9209
- targetRect = getRect(target);
9210
- }
9211
- if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
9212
- capture();
9213
- if (elLastChild && elLastChild.nextSibling) {
9214
- // the last draggable element is not the last node
9215
- el.insertBefore(dragEl, elLastChild.nextSibling);
9216
- } else {
9217
- el.appendChild(dragEl);
9218
- }
9219
- parentEl = el; // actualization
9220
-
9221
- changed();
9222
- return completed(true);
9223
- }
9224
- } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
9225
- // Insert to start of list
9226
- var firstChild = getChild(el, 0, options, true);
9227
- if (firstChild === dragEl) {
9228
- return completed(false);
9229
- }
9230
- target = firstChild;
9231
- targetRect = getRect(target);
9232
- if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
9233
- capture();
9234
- el.insertBefore(dragEl, firstChild);
9235
- parentEl = el; // actualization
9236
-
9237
- changed();
9238
- return completed(true);
9239
- }
9240
- } else if (target.parentNode === el) {
9241
- targetRect = getRect(target);
9242
- var direction = 0,
9243
- targetBeforeFirstSwap,
9244
- differentLevel = dragEl.parentNode !== el,
9245
- differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
9246
- side1 = vertical ? 'top' : 'left',
9247
- scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
9248
- scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
9249
- if (lastTarget !== target) {
9250
- targetBeforeFirstSwap = targetRect[side1];
9251
- pastFirstInvertThresh = false;
9252
- isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
9253
- }
9254
- direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
9255
- var sibling;
9256
- if (direction !== 0) {
9257
- // Check if target is beside dragEl in respective direction (ignoring hidden elements)
9258
- var dragIndex = index$1(dragEl);
9259
- do {
9260
- dragIndex -= direction;
9261
- sibling = parentEl.children[dragIndex];
9262
- } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
9263
- }
9264
- // If dragEl is already beside target: Do not insert
9265
- if (direction === 0 || sibling === target) {
9266
- return completed(false);
9267
- }
9268
- lastTarget = target;
9269
- lastDirection = direction;
9270
- var nextSibling = target.nextElementSibling,
9271
- after = false;
9272
- after = direction === 1;
9273
- var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
9274
- if (moveVector !== false) {
9275
- if (moveVector === 1 || moveVector === -1) {
9276
- after = moveVector === 1;
9277
- }
9278
- _silent = true;
9279
- setTimeout(_unsilent, 30);
9280
- capture();
9281
- if (after && !nextSibling) {
9282
- el.appendChild(dragEl);
9283
- } else {
9284
- target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
9285
- }
9286
-
9287
- // Undo chrome's scroll adjustment (has no effect on other browsers)
9288
- if (scrolledPastTop) {
9289
- scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
9290
- }
9291
- parentEl = dragEl.parentNode; // actualization
9292
-
9293
- // must be done before animation
9294
- if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
9295
- targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
9296
- }
9297
- changed();
9298
- return completed(true);
9299
- }
9300
- }
9301
- if (el.contains(dragEl)) {
9302
- return completed(false);
9303
- }
9304
- }
9305
- return false;
9306
- },
9307
- _ignoreWhileAnimating: null,
9308
- _offMoveEvents: function _offMoveEvents() {
9309
- off(document, 'mousemove', this._onTouchMove);
9310
- off(document, 'touchmove', this._onTouchMove);
9311
- off(document, 'pointermove', this._onTouchMove);
9312
- off(document, 'dragover', nearestEmptyInsertDetectEvent);
9313
- off(document, 'mousemove', nearestEmptyInsertDetectEvent);
9314
- off(document, 'touchmove', nearestEmptyInsertDetectEvent);
9315
- },
9316
- _offUpEvents: function _offUpEvents() {
9317
- var ownerDocument = this.el.ownerDocument;
9318
- off(ownerDocument, 'mouseup', this._onDrop);
9319
- off(ownerDocument, 'touchend', this._onDrop);
9320
- off(ownerDocument, 'pointerup', this._onDrop);
9321
- off(ownerDocument, 'pointercancel', this._onDrop);
9322
- off(ownerDocument, 'touchcancel', this._onDrop);
9323
- off(document, 'selectstart', this);
9324
- },
9325
- _onDrop: function _onDrop( /**Event*/evt) {
9326
- var el = this.el,
9327
- options = this.options;
9328
-
9329
- // Get the index of the dragged element within its parent
9330
- newIndex = index$1(dragEl);
9331
- newDraggableIndex = index$1(dragEl, options.draggable);
9332
- pluginEvent('drop', this, {
9333
- evt: evt
9334
- });
9335
- parentEl = dragEl && dragEl.parentNode;
9336
-
9337
- // Get again after plugin event
9338
- newIndex = index$1(dragEl);
9339
- newDraggableIndex = index$1(dragEl, options.draggable);
9340
- if (Sortable.eventCanceled) {
9341
- this._nulling();
9342
- return;
9343
- }
9344
- awaitingDragStarted = false;
9345
- isCircumstantialInvert = false;
9346
- pastFirstInvertThresh = false;
9347
- clearInterval(this._loopId);
9348
- clearTimeout(this._dragStartTimer);
9349
- _cancelNextTick(this.cloneId);
9350
- _cancelNextTick(this._dragStartId);
9351
-
9352
- // Unbind events
9353
- if (this.nativeDraggable) {
9354
- off(document, 'drop', this);
9355
- off(el, 'dragstart', this._onDragStart);
9356
- }
9357
- this._offMoveEvents();
9358
- this._offUpEvents();
9359
- if (Safari) {
9360
- css(document.body, 'user-select', '');
9361
- }
9362
- css(dragEl, 'transform', '');
9363
- if (evt) {
9364
- if (moved) {
9365
- evt.cancelable && evt.preventDefault();
9366
- !options.dropBubble && evt.stopPropagation();
9367
- }
9368
- ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
9369
- if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
9370
- // Remove clone(s)
9371
- cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
9372
- }
9373
- if (dragEl) {
9374
- if (this.nativeDraggable) {
9375
- off(dragEl, 'dragend', this);
9376
- }
9377
- _disableDraggable(dragEl);
9378
- dragEl.style['will-change'] = '';
9379
-
9380
- // Remove classes
9381
- // ghostClass is added in dragStarted
9382
- if (moved && !awaitingDragStarted) {
9383
- toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
9384
- }
9385
- toggleClass(dragEl, this.options.chosenClass, false);
9386
-
9387
- // Drag stop event
9388
- _dispatchEvent({
9389
- sortable: this,
9390
- name: 'unchoose',
9391
- toEl: parentEl,
9392
- newIndex: null,
9393
- newDraggableIndex: null,
9394
- originalEvent: evt
9395
- });
9396
- if (rootEl !== parentEl) {
9397
- if (newIndex >= 0) {
9398
- // Add event
9399
- _dispatchEvent({
9400
- rootEl: parentEl,
9401
- name: 'add',
9402
- toEl: parentEl,
9403
- fromEl: rootEl,
9404
- originalEvent: evt
9405
- });
9406
-
9407
- // Remove event
9408
- _dispatchEvent({
9409
- sortable: this,
9410
- name: 'remove',
9411
- toEl: parentEl,
9412
- originalEvent: evt
9413
- });
9414
-
9415
- // drag from one list and drop into another
9416
- _dispatchEvent({
9417
- rootEl: parentEl,
9418
- name: 'sort',
9419
- toEl: parentEl,
9420
- fromEl: rootEl,
9421
- originalEvent: evt
9422
- });
9423
- _dispatchEvent({
9424
- sortable: this,
9425
- name: 'sort',
9426
- toEl: parentEl,
9427
- originalEvent: evt
9428
- });
9429
- }
9430
- putSortable && putSortable.save();
9431
- } else {
9432
- if (newIndex !== oldIndex) {
9433
- if (newIndex >= 0) {
9434
- // drag & drop within the same list
9435
- _dispatchEvent({
9436
- sortable: this,
9437
- name: 'update',
9438
- toEl: parentEl,
9439
- originalEvent: evt
9440
- });
9441
- _dispatchEvent({
9442
- sortable: this,
9443
- name: 'sort',
9444
- toEl: parentEl,
9445
- originalEvent: evt
9446
- });
9447
- }
9448
- }
9449
- }
9450
- if (Sortable.active) {
9451
- /* jshint eqnull:true */
9452
- if (newIndex == null || newIndex === -1) {
9453
- newIndex = oldIndex;
9454
- newDraggableIndex = oldDraggableIndex;
9455
- }
9456
- _dispatchEvent({
9457
- sortable: this,
9458
- name: 'end',
9459
- toEl: parentEl,
9460
- originalEvent: evt
9461
- });
9462
-
9463
- // Save sorting
9464
- this.save();
9465
- }
9466
- }
9467
- }
9468
- this._nulling();
9469
- },
9470
- _nulling: function _nulling() {
9471
- pluginEvent('nulling', this);
9472
- rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
9473
- var el = this.el;
9474
- savedInputChecked.forEach(function (checkEl) {
9475
- if (el.contains(checkEl)) {
9476
- checkEl.checked = true;
9477
- }
9478
- });
9479
- savedInputChecked.length = lastDx = lastDy = 0;
9480
- },
9481
- handleEvent: function handleEvent( /**Event*/evt) {
9482
- switch (evt.type) {
9483
- case 'drop':
9484
- case 'dragend':
9485
- this._onDrop(evt);
9486
- break;
9487
- case 'dragenter':
9488
- case 'dragover':
9489
- if (dragEl) {
9490
- this._onDragOver(evt);
9491
- _globalDragOver(evt);
9492
- }
9493
- break;
9494
- case 'selectstart':
9495
- evt.preventDefault();
9496
- break;
9497
- }
9498
- },
9499
- /**
9500
- * Serializes the item into an array of string.
9501
- * @returns {String[]}
9502
- */
9503
- toArray: function toArray() {
9504
- var order = [],
9505
- el,
9506
- children = this.el.children,
9507
- i = 0,
9508
- n = children.length,
9509
- options = this.options;
9510
- for (; i < n; i++) {
9511
- el = children[i];
9512
- if (closest(el, options.draggable, this.el, false)) {
9513
- order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
9514
- }
9515
- }
9516
- return order;
9517
- },
9518
- /**
9519
- * Sorts the elements according to the array.
9520
- * @param {String[]} order order of the items
9521
- */
9522
- sort: function sort(order, useAnimation) {
9523
- var items = {},
9524
- rootEl = this.el;
9525
- this.toArray().forEach(function (id, i) {
9526
- var el = rootEl.children[i];
9527
- if (closest(el, this.options.draggable, rootEl, false)) {
9528
- items[id] = el;
9529
- }
9530
- }, this);
9531
- useAnimation && this.captureAnimationState();
9532
- order.forEach(function (id) {
9533
- if (items[id]) {
9534
- rootEl.removeChild(items[id]);
9535
- rootEl.appendChild(items[id]);
9536
- }
9537
- });
9538
- useAnimation && this.animateAll();
9539
- },
9540
- /**
9541
- * Save the current sorting
9542
- */
9543
- save: function save() {
9544
- var store = this.options.store;
9545
- store && store.set && store.set(this);
9546
- },
9547
- /**
9548
- * 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.
9549
- * @param {HTMLElement} el
9550
- * @param {String} [selector] default: `options.draggable`
9551
- * @returns {HTMLElement|null}
9552
- */
9553
- closest: function closest$1(el, selector) {
9554
- return closest(el, selector || this.options.draggable, this.el, false);
9555
- },
9556
- /**
9557
- * Set/get option
9558
- * @param {string} name
9559
- * @param {*} [value]
9560
- * @returns {*}
9561
- */
9562
- option: function option(name, value) {
9563
- var options = this.options;
9564
- if (value === void 0) {
9565
- return options[name];
9566
- } else {
9567
- var modifiedValue = PluginManager.modifyOption(this, name, value);
9568
- if (typeof modifiedValue !== 'undefined') {
9569
- options[name] = modifiedValue;
9570
- } else {
9571
- options[name] = value;
9572
- }
9573
- if (name === 'group') {
9574
- _prepareGroup(options);
9575
- }
9576
- }
9577
- },
9578
- /**
9579
- * Destroy
9580
- */
9581
- destroy: function destroy() {
9582
- pluginEvent('destroy', this);
9583
- var el = this.el;
9584
- el[expando] = null;
9585
- off(el, 'mousedown', this._onTapStart);
9586
- off(el, 'touchstart', this._onTapStart);
9587
- off(el, 'pointerdown', this._onTapStart);
9588
- if (this.nativeDraggable) {
9589
- off(el, 'dragover', this);
9590
- off(el, 'dragenter', this);
9591
- }
9592
- // Remove draggable attributes
9593
- Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
9594
- el.removeAttribute('draggable');
9595
- });
9596
- this._onDrop();
9597
- this._disableDelayedDragEvents();
9598
- sortables.splice(sortables.indexOf(this.el), 1);
9599
- this.el = el = null;
9600
- },
9601
- _hideClone: function _hideClone() {
9602
- if (!cloneHidden) {
9603
- pluginEvent('hideClone', this);
9604
- if (Sortable.eventCanceled) return;
9605
- css(cloneEl, 'display', 'none');
9606
- if (this.options.removeCloneOnHide && cloneEl.parentNode) {
9607
- cloneEl.parentNode.removeChild(cloneEl);
9608
- }
9609
- cloneHidden = true;
9610
- }
9611
- },
9612
- _showClone: function _showClone(putSortable) {
9613
- if (putSortable.lastPutMode !== 'clone') {
9614
- this._hideClone();
9615
- return;
9616
- }
9617
- if (cloneHidden) {
9618
- pluginEvent('showClone', this);
9619
- if (Sortable.eventCanceled) return;
9620
-
9621
- // show clone at dragEl or original position
9622
- if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
9623
- rootEl.insertBefore(cloneEl, dragEl);
9624
- } else if (nextEl) {
9625
- rootEl.insertBefore(cloneEl, nextEl);
9626
- } else {
9627
- rootEl.appendChild(cloneEl);
9628
- }
9629
- if (this.options.group.revertClone) {
9630
- this.animate(dragEl, cloneEl);
9631
- }
9632
- css(cloneEl, 'display', '');
9633
- cloneHidden = false;
9634
- }
9635
- }
9636
- };
9637
- function _globalDragOver( /**Event*/evt) {
9638
- if (evt.dataTransfer) {
9639
- evt.dataTransfer.dropEffect = 'move';
9640
- }
9641
- evt.cancelable && evt.preventDefault();
9642
- }
9643
- function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
9644
- var evt,
9645
- sortable = fromEl[expando],
9646
- onMoveFn = sortable.options.onMove,
9647
- retVal;
9648
- // Support for new CustomEvent feature
9649
- if (window.CustomEvent && !IE11OrLess && !Edge) {
9650
- evt = new CustomEvent('move', {
9651
- bubbles: true,
9652
- cancelable: true
9653
- });
9654
- } else {
9655
- evt = document.createEvent('Event');
9656
- evt.initEvent('move', true, true);
9657
- }
9658
- evt.to = toEl;
9659
- evt.from = fromEl;
9660
- evt.dragged = dragEl;
9661
- evt.draggedRect = dragRect;
9662
- evt.related = targetEl || toEl;
9663
- evt.relatedRect = targetRect || getRect(toEl);
9664
- evt.willInsertAfter = willInsertAfter;
9665
- evt.originalEvent = originalEvent;
9666
- fromEl.dispatchEvent(evt);
9667
- if (onMoveFn) {
9668
- retVal = onMoveFn.call(sortable, evt, originalEvent);
9669
- }
9670
- return retVal;
9671
- }
9672
- function _disableDraggable(el) {
9673
- el.draggable = false;
9674
- }
9675
- function _unsilent() {
9676
- _silent = false;
9677
- }
9678
- function _ghostIsFirst(evt, vertical, sortable) {
9679
- var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
9680
- var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
9681
- var spacer = 10;
9682
- 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;
9683
- }
9684
- function _ghostIsLast(evt, vertical, sortable) {
9685
- var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
9686
- var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
9687
- var spacer = 10;
9688
- 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;
9689
- }
9690
- function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
9691
- var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
9692
- targetLength = vertical ? targetRect.height : targetRect.width,
9693
- targetS1 = vertical ? targetRect.top : targetRect.left,
9694
- targetS2 = vertical ? targetRect.bottom : targetRect.right,
9695
- invert = false;
9696
- if (!invertSwap) {
9697
- // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
9698
- if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
9699
- // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
9700
- // check if past first invert threshold on side opposite of lastDirection
9701
- if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
9702
- // past first invert threshold, do not restrict inverted threshold to dragEl shadow
9703
- pastFirstInvertThresh = true;
9704
- }
9705
- if (!pastFirstInvertThresh) {
9706
- // dragEl shadow (target move distance shadow)
9707
- if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
9708
- : mouseOnAxis > targetS2 - targetMoveDistance) {
9709
- return -lastDirection;
9710
- }
9711
- } else {
9712
- invert = true;
9713
- }
9714
- } else {
9715
- // Regular
9716
- if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
9717
- return _getInsertDirection(target);
9718
- }
9719
- }
9720
- }
9721
- invert = invert || invertSwap;
9722
- if (invert) {
9723
- // Invert of regular
9724
- if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
9725
- return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
9726
- }
9727
- }
9728
- return 0;
9729
- }
9730
-
9731
- /**
9732
- * Gets the direction dragEl must be swapped relative to target in order to make it
9733
- * seem that dragEl has been "inserted" into that element's position
9734
- * @param {HTMLElement} target The target whose position dragEl is being inserted at
9735
- * @return {Number} Direction dragEl must be swapped
9736
- */
9737
- function _getInsertDirection(target) {
9738
- if (index$1(dragEl) < index$1(target)) {
9739
- return 1;
9740
- } else {
9741
- return -1;
9742
- }
9743
- }
9744
-
9745
- /**
9746
- * Generate id
9747
- * @param {HTMLElement} el
9748
- * @returns {String}
9749
- * @private
9750
- */
9751
- function _generateId(el) {
9752
- var str = el.tagName + el.className + el.src + el.href + el.textContent,
9753
- i = str.length,
9754
- sum = 0;
9755
- while (i--) {
9756
- sum += str.charCodeAt(i);
9757
- }
9758
- return sum.toString(36);
9759
- }
9760
- function _saveInputCheckedState(root) {
9761
- savedInputChecked.length = 0;
9762
- var inputs = root.getElementsByTagName('input');
9763
- var idx = inputs.length;
9764
- while (idx--) {
9765
- var el = inputs[idx];
9766
- el.checked && savedInputChecked.push(el);
9767
- }
9768
- }
9769
- function _nextTick(fn) {
9770
- return setTimeout(fn, 0);
9771
- }
9772
- function _cancelNextTick(id) {
9773
- return clearTimeout(id);
9774
- }
9775
-
9776
- // Fixed #973:
9777
- if (documentExists) {
9778
- on(document, 'touchmove', function (evt) {
9779
- if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
9780
- evt.preventDefault();
9781
- }
9782
- });
9783
- }
9784
-
9785
- // Export utils
9786
- Sortable.utils = {
9787
- on: on,
9788
- off: off,
9789
- css: css,
9790
- find: find,
9791
- is: function is(el, selector) {
9792
- return !!closest(el, selector, el, false);
9793
- },
9794
- extend: extend,
9795
- throttle: throttle,
9796
- closest: closest,
9797
- toggleClass: toggleClass,
9798
- clone: clone,
9799
- index: index$1,
9800
- nextTick: _nextTick,
9801
- cancelNextTick: _cancelNextTick,
9802
- detectDirection: _detectDirection,
9803
- getChild: getChild,
9804
- expando: expando
9805
- };
9806
-
9807
- /**
9808
- * Get the Sortable instance of an element
9809
- * @param {HTMLElement} element The element
9810
- * @return {Sortable|undefined} The instance of Sortable
9811
- */
9812
- Sortable.get = function (element) {
9813
- return element[expando];
9814
- };
9815
-
9816
- /**
9817
- * Mount a plugin to Sortable
9818
- * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
9819
- */
9820
- Sortable.mount = function () {
9821
- for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
9822
- plugins[_key] = arguments[_key];
9823
- }
9824
- if (plugins[0].constructor === Array) plugins = plugins[0];
9825
- plugins.forEach(function (plugin) {
9826
- if (!plugin.prototype || !plugin.prototype.constructor) {
9827
- throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
9828
- }
9829
- if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
9830
- PluginManager.mount(plugin);
9831
- });
9832
- };
9833
-
9834
- /**
9835
- * Create sortable instance
9836
- * @param {HTMLElement} el
9837
- * @param {Object} [options]
9838
- */
9839
- Sortable.create = function (el, options) {
9840
- return new Sortable(el, options);
9841
- };
9842
-
9843
- // Export
9844
- Sortable.version = version;
9845
-
9846
- var autoScrolls = [],
9847
- scrollEl,
9848
- scrollRootEl,
9849
- scrolling = false,
9850
- lastAutoScrollX,
9851
- lastAutoScrollY,
9852
- touchEvt$1,
9853
- pointerElemChangedInterval;
9854
- function AutoScrollPlugin() {
9855
- function AutoScroll() {
9856
- this.defaults = {
9857
- scroll: true,
9858
- forceAutoScrollFallback: false,
9859
- scrollSensitivity: 30,
9860
- scrollSpeed: 10,
9861
- bubbleScroll: true
9862
- };
9863
-
9864
- // Bind all private methods
9865
- for (var fn in this) {
9866
- if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
9867
- this[fn] = this[fn].bind(this);
9868
- }
9869
- }
9870
- }
9871
- AutoScroll.prototype = {
9872
- dragStarted: function dragStarted(_ref) {
9873
- var originalEvent = _ref.originalEvent;
9874
- if (this.sortable.nativeDraggable) {
9875
- on(document, 'dragover', this._handleAutoScroll);
9876
- } else {
9877
- if (this.options.supportPointer) {
9878
- on(document, 'pointermove', this._handleFallbackAutoScroll);
9879
- } else if (originalEvent.touches) {
9880
- on(document, 'touchmove', this._handleFallbackAutoScroll);
9881
- } else {
9882
- on(document, 'mousemove', this._handleFallbackAutoScroll);
9883
- }
9884
- }
9885
- },
9886
- dragOverCompleted: function dragOverCompleted(_ref2) {
9887
- var originalEvent = _ref2.originalEvent;
9888
- // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
9889
- if (!this.options.dragOverBubble && !originalEvent.rootEl) {
9890
- this._handleAutoScroll(originalEvent);
9891
- }
9892
- },
9893
- drop: function drop() {
9894
- if (this.sortable.nativeDraggable) {
9895
- off(document, 'dragover', this._handleAutoScroll);
9896
- } else {
9897
- off(document, 'pointermove', this._handleFallbackAutoScroll);
9898
- off(document, 'touchmove', this._handleFallbackAutoScroll);
9899
- off(document, 'mousemove', this._handleFallbackAutoScroll);
9900
- }
9901
- clearPointerElemChangedInterval();
9902
- clearAutoScrolls();
9903
- cancelThrottle();
9904
- },
9905
- nulling: function nulling() {
9906
- touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
9907
- autoScrolls.length = 0;
9908
- },
9909
- _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
9910
- this._handleAutoScroll(evt, true);
9911
- },
9912
- _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
9913
- var _this = this;
9914
- var x = (evt.touches ? evt.touches[0] : evt).clientX,
9915
- y = (evt.touches ? evt.touches[0] : evt).clientY,
9916
- elem = document.elementFromPoint(x, y);
9917
- touchEvt$1 = evt;
9918
-
9919
- // IE does not seem to have native autoscroll,
9920
- // Edge's autoscroll seems too conditional,
9921
- // MACOS Safari does not have autoscroll,
9922
- // Firefox and Chrome are good
9923
- if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
9924
- autoScroll(evt, this.options, elem, fallback);
9925
-
9926
- // Listener for pointer element change
9927
- var ogElemScroller = getParentAutoScrollElement(elem, true);
9928
- if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
9929
- pointerElemChangedInterval && clearPointerElemChangedInterval();
9930
- // Detect for pointer elem change, emulating native DnD behaviour
9931
- pointerElemChangedInterval = setInterval(function () {
9932
- var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
9933
- if (newElem !== ogElemScroller) {
9934
- ogElemScroller = newElem;
9935
- clearAutoScrolls();
9936
- }
9937
- autoScroll(evt, _this.options, newElem, fallback);
9938
- }, 10);
9939
- lastAutoScrollX = x;
9940
- lastAutoScrollY = y;
9941
- }
9942
- } else {
9943
- // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
9944
- if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
9945
- clearAutoScrolls();
9946
- return;
9947
- }
9948
- autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
9949
- }
9950
- }
9951
- };
9952
- return _extends(AutoScroll, {
9953
- pluginName: 'scroll',
9954
- initializeByDefault: true
9955
- });
9956
- }
9957
- function clearAutoScrolls() {
9958
- autoScrolls.forEach(function (autoScroll) {
9959
- clearInterval(autoScroll.pid);
9960
- });
9961
- autoScrolls = [];
9962
- }
9963
- function clearPointerElemChangedInterval() {
9964
- clearInterval(pointerElemChangedInterval);
9965
- }
9966
- var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
9967
- // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
9968
- if (!options.scroll) return;
9969
- var x = (evt.touches ? evt.touches[0] : evt).clientX,
9970
- y = (evt.touches ? evt.touches[0] : evt).clientY,
9971
- sens = options.scrollSensitivity,
9972
- speed = options.scrollSpeed,
9973
- winScroller = getWindowScrollingElement();
9974
- var scrollThisInstance = false,
9975
- scrollCustomFn;
9976
-
9977
- // New scroll root, set scrollEl
9978
- if (scrollRootEl !== rootEl) {
9979
- scrollRootEl = rootEl;
9980
- clearAutoScrolls();
9981
- scrollEl = options.scroll;
9982
- scrollCustomFn = options.scrollFn;
9983
- if (scrollEl === true) {
9984
- scrollEl = getParentAutoScrollElement(rootEl, true);
9985
- }
9986
- }
9987
- var layersOut = 0;
9988
- var currentParent = scrollEl;
9989
- do {
9990
- var el = currentParent,
9991
- rect = getRect(el),
9992
- top = rect.top,
9993
- bottom = rect.bottom,
9994
- left = rect.left,
9995
- right = rect.right,
9996
- width = rect.width,
9997
- height = rect.height,
9998
- canScrollX = void 0,
9999
- canScrollY = void 0,
10000
- scrollWidth = el.scrollWidth,
10001
- scrollHeight = el.scrollHeight,
10002
- elCSS = css(el),
10003
- scrollPosX = el.scrollLeft,
10004
- scrollPosY = el.scrollTop;
10005
- if (el === winScroller) {
10006
- canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
10007
- canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
10008
- } else {
10009
- canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
10010
- canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
10011
- }
10012
- var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
10013
- var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
10014
- if (!autoScrolls[layersOut]) {
10015
- for (var i = 0; i <= layersOut; i++) {
10016
- if (!autoScrolls[i]) {
10017
- autoScrolls[i] = {};
10018
- }
10019
- }
10020
- }
10021
- if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
10022
- autoScrolls[layersOut].el = el;
10023
- autoScrolls[layersOut].vx = vx;
10024
- autoScrolls[layersOut].vy = vy;
10025
- clearInterval(autoScrolls[layersOut].pid);
10026
- if (vx != 0 || vy != 0) {
10027
- scrollThisInstance = true;
10028
- /* jshint loopfunc:true */
10029
- autoScrolls[layersOut].pid = setInterval(function () {
10030
- // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
10031
- if (isFallback && this.layer === 0) {
10032
- Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
10033
- }
10034
- var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
10035
- var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
10036
- if (typeof scrollCustomFn === 'function') {
10037
- if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
10038
- return;
10039
- }
10040
- }
10041
- scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
10042
- }.bind({
10043
- layer: layersOut
10044
- }), 24);
10045
- }
10046
- }
10047
- layersOut++;
10048
- } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
10049
- scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
10050
- }, 30);
10051
-
10052
- var drop = function drop(_ref) {
10053
- var originalEvent = _ref.originalEvent,
10054
- putSortable = _ref.putSortable,
10055
- dragEl = _ref.dragEl,
10056
- activeSortable = _ref.activeSortable,
10057
- dispatchSortableEvent = _ref.dispatchSortableEvent,
10058
- hideGhostForTarget = _ref.hideGhostForTarget,
10059
- unhideGhostForTarget = _ref.unhideGhostForTarget;
10060
- if (!originalEvent) return;
10061
- var toSortable = putSortable || activeSortable;
10062
- hideGhostForTarget();
10063
- var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
10064
- var target = document.elementFromPoint(touch.clientX, touch.clientY);
10065
- unhideGhostForTarget();
10066
- if (toSortable && !toSortable.el.contains(target)) {
10067
- dispatchSortableEvent('spill');
10068
- this.onSpill({
10069
- dragEl: dragEl,
10070
- putSortable: putSortable
10071
- });
10072
- }
10073
- };
10074
- function Revert() {}
10075
- Revert.prototype = {
10076
- startIndex: null,
10077
- dragStart: function dragStart(_ref2) {
10078
- var oldDraggableIndex = _ref2.oldDraggableIndex;
10079
- this.startIndex = oldDraggableIndex;
10080
- },
10081
- onSpill: function onSpill(_ref3) {
10082
- var dragEl = _ref3.dragEl,
10083
- putSortable = _ref3.putSortable;
10084
- this.sortable.captureAnimationState();
10085
- if (putSortable) {
10086
- putSortable.captureAnimationState();
10087
- }
10088
- var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
10089
- if (nextSibling) {
10090
- this.sortable.el.insertBefore(dragEl, nextSibling);
10091
- } else {
10092
- this.sortable.el.appendChild(dragEl);
10093
- }
10094
- this.sortable.animateAll();
10095
- if (putSortable) {
10096
- putSortable.animateAll();
10097
- }
10098
- },
10099
- drop: drop
10100
- };
10101
- _extends(Revert, {
10102
- pluginName: 'revertOnSpill'
10103
- });
10104
- function Remove() {}
10105
- Remove.prototype = {
10106
- onSpill: function onSpill(_ref4) {
10107
- var dragEl = _ref4.dragEl,
10108
- putSortable = _ref4.putSortable;
10109
- var parentSortable = putSortable || this.sortable;
10110
- parentSortable.captureAnimationState();
10111
- dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
10112
- parentSortable.animateAll();
10113
- },
10114
- drop: drop
10115
- };
10116
- _extends(Remove, {
10117
- pluginName: 'removeOnSpill'
10118
- });
10119
-
10120
- Sortable.mount(new AutoScrollPlugin());
10121
- Sortable.mount(Remove, Revert);
10122
-
10123
7473
  var _hoisted_1$7 = {
10124
7474
  "class": "fy-transfer-wrap"
10125
7475
  };