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