|
|
// sortablejs@1.15.7 downloaded from https://ga.jspm.io/npm:sortablejs@1.15.7/modular/sortable.esm.js
|
|
|
|
|
|
/**!
|
|
|
* Sortable 1.15.7
|
|
|
* @author RubaXa <trash@rubaxa.org>
|
|
|
* @author owenm <owen23355@gmail.com>
|
|
|
* @license MIT
|
|
|
*/
|
|
|
function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);n<e;n++)o[n]=t[n];return o}function e(e){if(Array.isArray(e))return t(e)}function n(t,e,n){return(e=d(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(){return o=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)({}).hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},o.apply(null,arguments)}function i(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function r(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function l(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?a(Object(o),!0).forEach((function(e){n(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):a(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function s(t,e){if(null==t)return{};var n,o,i=u(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(o=0;o<r.length;o++)n=r[o],-1===e.indexOf(n)&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function u(t,e){if(null==t)return{};var n={};for(var o in t)if({}.hasOwnProperty.call(t,o)){if(-1!==e.indexOf(o))continue;n[o]=t[o]}return n}function c(t){return e(t)||i(t)||p(t)||r()}function f(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function d(t){var e=f(t,"string");return"symbol"==typeof e?e:e+""}function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function p(e,n){if(e){if("string"==typeof e)return t(e,n);var o={}.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?t(e,n):void 0}}var g="1.15.7";function v(t){if(typeof window!=="undefined"&&window.navigator)return!!navigator.userAgent.match(t)}var m=v(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);var b=v(/Edge/i);var y=v(/firefox/i);var w=v(/safari/i)&&!v(/chrome/i)&&!v(/android/i);var D=v(/iP(ad|od|hone)/i);var E=v(/chrome/i)&&v(/android/i);var S={capture:false,passive:false};function _(t,e,n){t.addEventListener(e,n,!m&&S)}function C(t,e,n){t.removeEventListener(e,n,!m&&S)}function T(t,e){if(e){e[0]===">"&&(e=e.substring(1));if(t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return false}return false}}function x(t){return t.host&&t!==document&&t.host.nodeType&&t.host!==t?t.host:t.parentNode}function M(t,e,n,o){if(t){n=n||document;do{if(e!=null&&(e[0]===">"?t.parentNode===n&&T(t,e):T(t,e))||o&&t===n)return t;if(t===n)break}while(t=x(t))}return null}var O=/\s+/g;function A(t,e,n){if(t&&e)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(O," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(O," ")}}function N(t,e,n){var o=t&&t.style;if(o){if(n===void 0){document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle);return e===void 0?n:n[e]}e in o||e.indexOf("webkit")!==-1||(e="-webkit-"+e);o[e]=n+(typeof n==="string"?"":"px")}}function I(t,e){var n="";if(typeof t==="string")n=t;else do{var o=N(t,"transform");o&&o!=="none"&&(n=o+" "+n)}while(!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function P(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i<r;i++)n(o[i],i);return o}return[]}function k(){var t=document.scrollingElement;return t||document.documentElement}
|
|
|
/**
|
|
|
* Returns the "bounding client rect" of given element
|
|
|
* @param {HTMLElement} el The element whose boundingClientRect is wanted
|
|
|
* @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
|
|
|
* @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
|
|
|
* @param {[Boolean]} undoScale Whether the container's scale() should be undone
|
|
|
* @param {[HTMLElement]} container The parent the element will be placed in
|
|
|
* @return {Object} The boundingClientRect of el, with specified adjustments
|
|
|
*/function R(t,e,n,o,i){if(t.getBoundingClientRect||t===window){var r,a,l,s,u,c,f;if(t!==window&&t.parentNode&&t!==k()){r=t.getBoundingClientRect();a=r.top;l=r.left;s=r.bottom;u=r.right;c=r.height;f=r.width}else{a=0;l=0;s=window.innerHeight;u=window.innerWidth;c=window.innerHeight;f=window.innerWidth}if((e||n)&&t!==window){i=i||t.parentNode;if(!m)do{if(i&&i.getBoundingClientRect&&(N(i,"transform")!=="none"||n&&N(i,"position")!=="static")){var d=i.getBoundingClientRect();a-=d.top+parseInt(N(i,"border-top-width"));l-=d.left+parseInt(N(i,"border-left-width"));s=a+r.height;u=l+r.width;break}}while(i=i.parentNode)}if(o&&t!==window){var h=I(i||t),p=h&&h.a,g=h&&h.d;if(h){a/=g;l/=p;f/=p;c/=g;s=a+c;u=l+f}}return{top:a,left:l,bottom:s,right:u,width:f,height:c}}}
|
|
|
/**
|
|
|
* Checks if a side of an element is scrolled past a side of its parents
|
|
|
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
|
|
|
* @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
|
|
|
* @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
|
|
|
* @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
|
|
|
*/function X(t,e,n){var o=L(t,true),i=R(t)[e];while(o){var r=R(o)[n],a=void 0;a=n==="top"||n==="left"?i>=r:i<=r;if(!a)return o;if(o===k())break;o=L(o,false)}return false}
|
|
|
/**
|
|
|
* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
|
|
|
* and non-draggable elements
|
|
|
* @param {HTMLElement} el The parent element
|
|
|
* @param {Number} childNum The index of the child
|
|
|
* @param {Object} options Parent Sortable's options
|
|
|
* @return {HTMLElement} The child at index childNum, or null if not found
|
|
|
*/function Y(t,e,n,o){var i=0,r=0,a=t.children;while(r<a.length){if(a[r].style.display!=="none"&&a[r]!==ne.ghost&&(o||a[r]!==ne.dragged)&&M(a[r],n.draggable,t,false)){if(i===e)return a[r];i++}r++}return null}
|
|
|
/**
|
|
|
* Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
|
|
|
* @param {HTMLElement} el Parent element
|
|
|
* @param {selector} selector Any other elements that should be ignored
|
|
|
* @return {HTMLElement} The last child, ignoring ghostEl
|
|
|
*/function B(t,e){var n=t.lastElementChild;while(n&&(n===ne.ghost||N(n,"display")==="none"||e&&!T(n,e)))n=n.previousElementSibling;return n||null}
|
|
|
/**
|
|
|
* Returns the index of an element within its parent for a selected set of
|
|
|
* elements
|
|
|
* @param {HTMLElement} el
|
|
|
* @param {selector} selector
|
|
|
* @return {number}
|
|
|
*/function F(t,e){var n=0;if(!t||!t.parentNode)return-1;while(t=t.previousElementSibling)t.nodeName.toUpperCase()==="TEMPLATE"||t===ne.clone||e&&!T(t,e)||n++;return n}
|
|
|
/**
|
|
|
* Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
|
|
|
* The value is returned in real pixels.
|
|
|
* @param {HTMLElement} el
|
|
|
* @return {Array} Offsets in the format of [left, top]
|
|
|
*/function H(t){var e=0,n=0,o=k();if(t)do{var i=I(t),r=i.a,a=i.d;e+=t.scrollLeft*r;n+=t.scrollTop*a}while(t!==o&&(t=t.parentNode));return[e,n]}
|
|
|
/**
|
|
|
* Returns the index of the object within the given array
|
|
|
* @param {Array} arr Array that may or may not hold the object
|
|
|
* @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
|
|
|
* @return {Number} The index of the object in the array, or -1
|
|
|
*/function j(t,e){for(var n in t)if(t.hasOwnProperty(n))for(var o in e)if(e.hasOwnProperty(o)&&e[o]===t[n][o])return Number(n);return-1}function L(t,e){if(!t||!t.getBoundingClientRect)return k();var n=t;var o=false;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=N(n);if(n.clientWidth<n.scrollWidth&&(i.overflowX=="auto"||i.overflowX=="scroll")||n.clientHeight<n.scrollHeight&&(i.overflowY=="auto"||i.overflowY=="scroll")){if(!n.getBoundingClientRect||n===document.body)return k();if(o||e)return n;o=true}}}while(n=n.parentNode);return k()}function K(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function W(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}var z;function G(t,e){return function(){if(!z){var n=arguments,o=this;n.length===1?t.call(o,n[0]):t.apply(o,n);z=setTimeout((function(){z=void 0}),e)}}}function U(){clearTimeout(z);z=void 0}function q(t,e,n){t.scrollLeft+=e;t.scrollTop+=n}function V(t){var e=window.Polymer;var n=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(true):n?n(t).clone(true)[0]:t.cloneNode(true)}function Z(t,e){N(t,"position","absolute");N(t,"top",e.top);N(t,"left",e.left);N(t,"width",e.width);N(t,"height",e.height)}function $(t){N(t,"position","");N(t,"top","");N(t,"left","");N(t,"width","");N(t,"height","")}function Q(t,e,n){var o={};Array.from(t.children).forEach((function(i){var r,a,l,s;if(M(i,e.draggable,t,false)&&!i.animated&&i!==n){var u=R(i);o.left=Math.min((r=o.left)!==null&&r!==void 0?r:Infinity,u.left);o.top=Math.min((a=o.top)!==null&&a!==void 0?a:Infinity,u.top);o.right=Math.max((l=o.right)!==null&&l!==void 0?l:-Infinity,u.right);o.bottom=Math.max((s=o.bottom)!==null&&s!==void 0?s:-Infinity,u.bottom)}}));o.width=o.right-o.left;o.height=o.bottom-o.top;o.x=o.left;o.y=o.top;return o}var J="Sortable"+(new Date).getTime();function tt(){var t,e=[];return{captureAnimationState:function(){e=[];if(this.options.animation){var t=[].slice.call(this.el.children);t.forEach((function(t){if(N(t,"display")!=="none"&&t!==ne.ghost){e.push({target:t,rect:R(t)});var n=l({},e[e.length-1].rect);if(t.thisAnimationDuration){var o=I(t,true);if(o){n.top-=o.f;n.left-=o.e}}t.fromRect=n}}))}},addAnimationState:function(t){e.push(t)},removeAnimationState:function(t){e.splice(j(e,{target:t}),1)},animateAll:function(n){var o=this;if(this.options.animation){var i=false,r=0;e.forEach((function(t){var e=0,n=t.target,a=n.fromRect,l=R(n),s=n.prevFromRect,u=n.prevToRect,c=t.rect,f=I(n,true);if(f){l.top-=f.f;l.left-=f.e}n.toRect=l;n.thisAnimationDuration&&W(s,l)&&!W(a,l)&&(c.top-l.top)/(c.left-l.left)===(a.top-l.top)/(a.left-l.left)&&(e=nt(c,s,u,o.options));if(!W(l,a)){n.prevFromRect=a;n.prevToRect=l;e||(e=o.options.animation);o.animate(n,c,l,e)}if(e){i=true;r=Math.max(r,e);clearTimeout(n.animationResetTimer);n.animationResetTimer=setTimeout((function(){n.animationTime=0;n.prevFromRect=null;n.fromRect=null;n.prevToRect=null;n.thisAnimationDuration=null}),e);n.thisAnimationDuration=e}}));clearTimeout(t);i?t=setTimeout((function(){typeof n==="function"&&n()}),r):typeof n==="function"&&n();e=[]}else{clearTimeout(t);typeof n==="function"&&n()}},animate:function(t,e,n,o){if(o){N(t,"transition","");N(t,"transform","");var i=I(this.el),r=i&&i.a,a=i&&i.d,l=(e.left-n.left)/(r||1),s=(e.top-n.top)/(a||1);t.animatingX=!!l;t.animatingY=!!s;N(t,"transform","translate3d("+l+"px,"+s+"px,0)");this.forRepaintDummy=et(t);N(t,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:""));N(t,"transform","translate3d(0,0,0)");typeof t.animated==="number"&&clearTimeout(t.animated);t.animated=setTimeout((function(){N(t,"transition","");N(t,"transform","");t.animated=false;t.animatingX=false;t.animatingY=false}),o)}}}}function et(t){return t.offsetWidth}function nt(t,e,n,o){return Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))/Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))*o.animation}var ot=[];var it={initializeByDefault:true};var rt={mount:function(t){for(var e in it)it.hasOwnProperty(e)&&!(e in t)&&(t[e]=it[e]);ot.forEach((function(e){if(e.pluginName===t.pluginName)throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}));ot.push(t)},pluginEvent:function(t,e,n){var o=this;this.eventCanceled=false;n.cancel=function(){o.eventCanceled=true};var i=t+"Global";ot.forEach((function(o){if(e[o.pluginName]){e[o.pluginName][i]&&e[o.pluginName][i](l({sortable:e},n));e.options[o.pluginName]&&e[o.pluginName][t]&&e[o.pluginName][t](l({sortable:e},n))}}))},initializePlugins:function(t,e,n,i){ot.forEach((function(i){var r=i.pluginName;if(t.options[r]||i.initializeByDefault){var a=new i(t,e,t.options);a.sortable=t;a.options=t.options;t[r]=a;o(n,a.defaults)}}));for(var r in t.options)if(t.options.hasOwnProperty(r)){var a=this.modifyOption(t,r,t.options[r]);typeof a!=="undefined"&&(t.options[r]=a)}},getEventProperties:function(t,e){var n={};ot.forEach((function(i){typeof i.eventProperties==="function"&&o(n,i.eventProperties.call(e[i.pluginName],t))}));return n},modifyOption:function(t,e,n){var o;ot.forEach((function(i){t[i.pluginName]&&i.optionListeners&&typeof i.optionListeners[e]==="function"&&(o=i.optionListeners[e].call(t[i.pluginName],n))}));return o}};function at(t){var e=t.sortable,n=t.rootEl,o=t.name,i=t.targetEl,r=t.cloneEl,a=t.toEl,s=t.fromEl,u=t.oldIndex,c=t.newIndex,f=t.oldDraggableIndex,d=t.newDraggableIndex,h=t.originalEvent,p=t.putSortable,g=t.extraEventProperties;e=e||n&&n[J];if(e){var v,y=e.options,w="on"+o.charAt(0).toUpperCase()+o.substr(1);if(!window.CustomEvent||m||b){v=document.createEvent("Event");v.initEvent(o,true,true)}else v=new CustomEvent(o,{bubbles:true,cancelable:true});v.to=a||n;v.from=s||n;v.item=i||n;v.clone=r;v.oldIndex=u;v.newIndex=c;v.oldDraggableIndex=f;v.newDraggableIndex=d;v.originalEvent=h;v.pullMode=p?p.lastPutMode:void 0;var D=l(l({},g),rt.getEventProperties(o,e));for(var E in D)v[E]=D[E];n&&n.dispatchEvent(v);y[w]&&y[w].call(e,v)}}var lt=["evt"];var st=function(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,i=s(n,lt);rt.pluginEvent.bind(ne)(t,e,l({dragEl:ct,parentEl:ft,ghostEl:dt,rootEl:ht,nextEl:pt,lastDownEl:gt,cloneEl:vt,cloneHidden:mt,dragStarted:At,putSortable:St,activeSortable:ne.active,originalEvent:o,oldIndex:bt,oldDraggableIndex:wt,newIndex:yt,newDraggableIndex:Dt,hideGhostForTarget:Qt,unhideGhostForTarget:Jt,cloneNowHidden:function(){mt=true},cloneNowShown:function(){mt=false},dispatchSortableEvent:function(t){ut({sortable:e,name:t,originalEvent:o})}},i))};function ut(t){at(l({putSortable:St,cloneEl:vt,targetEl:ct,rootEl:ht,oldIndex:bt,oldDraggableIndex:wt,newIndex:yt,newDraggableIndex:Dt},t))}var ct,ft,dt,ht,pt,gt,vt,mt,bt,yt,wt,Dt,Et,St,_t,Ct,Tt,xt,Mt,Ot,At,Nt,It,Pt,kt,Rt=false,Xt=false,Yt=[],Bt=false,Ft=false,Ht=[],jt=false,Lt=[];var Kt=typeof document!=="undefined",Wt=D,zt=b||m?"cssFloat":"float",Gt=Kt&&!E&&!D&&"draggable"in document.createElement("div"),Ut=function(){if(Kt){if(m)return false;var t=document.createElement("x");t.style.cssText="pointer-events:auto";return t.style.pointerEvents==="auto"}}(),qt=function(t,e){var n=N(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=Y(t,0,e),r=Y(t,1,e),a=i&&N(i),l=r&&N(r),s=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+R(i).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+R(r).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&a.float&&a.float!=="none"){var c=a.float==="left"?"left":"right";return!r||l.clear!=="both"&&l.clear!==c?"horizontal":"vertical"}return i&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||s>=o&&n[zt]==="none"||r&&n[zt]==="none"&&s+u>o)?"vertical":"horizontal"},Vt=function(t,e,n){var o=n?t.left:t.top,i=n?t.right:t.bottom,r=n?t.width:t.height,a=n?e.left:e.top,l=n?e.right:e.bottom,s=n?e.width:e.height;return o===a||i===l||o+r/2===a+s/2},
|
|
|
/**
|
|
|
* Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
|
|
|
* @param {Number} x X position
|
|
|
* @param {Number} y Y position
|
|
|
* @return {HTMLElement} Element of the first found nearest Sortable
|
|
|
*/
|
|
|
Zt=function(t,e){var n;Yt.some((function(o){var i=o[J].options.emptyInsertThreshold;if(i&&!B(o)){var r=R(o),a=t>=r.left-i&&t<=r.right+i,l=e>=r.top-i&&e<=r.bottom+i;return a&&l?n=o:void 0}}));return n},$t=function(t){function e(t,n){return function(o,i,r,a){var l=o.options.group.name&&i.options.group.name&&o.options.group.name===i.options.group.name;if(t==null&&(n||l))return true;if(t==null||t===false)return false;if(n&&t==="clone")return t;if(typeof t==="function")return e(t(o,i,r,a),n)(o,i,r,a);var s=(n?o:i).options.group.name;return t===true||typeof t==="string"&&t===s||t.join&&t.indexOf(s)>-1}}var n={};var o=t.group;o&&h(o)=="object"||(o={name:o});n.name=o.name;n.checkPull=e(o.pull,true);n.checkPut=e(o.put);n.revertClone=o.revertClone;t.group=n},Qt=function(){!Ut&&dt&&N(dt,"display","none")},Jt=function(){!Ut&&dt&&N(dt,"display","")};Kt&&!E&&document.addEventListener("click",(function(t){if(Xt){t.preventDefault();t.stopPropagation&&t.stopPropagation();t.stopImmediatePropagation&&t.stopImmediatePropagation();Xt=false;return false}}),true);var te=function(t){if(ct){t=t.touches?t.touches[0]:t;var e=Zt(t.clientX,t.clientY);if(e){var n={};for(var o in t)t.hasOwnProperty(o)&&(n[o]=t[o]);n.target=n.rootEl=e;n.preventDefault=void 0;n.stopPropagation=void 0;e[J]._onDragOver(n)}}};var ee=function(t){ct&&ct.parentNode[J]._isOutsideThisEl(t.target)};
|
|
|
/**
|
|
|
* @class Sortable
|
|
|
* @param {HTMLElement} el
|
|
|
* @param {Object} [options]
|
|
|
*/function ne(t,e){if(!(t&&t.nodeType&&t.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t;this.options=e=o({},e);t[J]=this;var n={group:null,sort:true,disabled:false,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:false,invertedSwapThreshold:null,removeCloneOnHide:true,direction:function(){return qt(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:true,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:false,dragoverBubble:false,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:false,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:false,fallbackClass:"sortable-fallback",fallbackOnBody:false,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:ne.supportPointer!==false&&"PointerEvent"in window&&(!w||D),emptyInsertThreshold:5};rt.initializePlugins(this,t,n);for(var i in n)!(i in e)&&(e[i]=n[i]);$t(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]==="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=!e.forceFallback&≫this.nativeDraggable&&(this.options.touchStartThreshold=1);if(e.supportPointer)_(t,"pointerdown",this._onTapStart);else{_(t,"mousedown",this._onTapStart);_(t,"touchstart",this._onTapStart)}if(this.nativeDraggable){_(t,"dragover",this);_(t,"dragenter",this)}Yt.push(this.el);e.store&&e.store.get&&this.sort(e.store.get(this)||[]);o(this,tt())}ne.prototype={constructor:ne,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(Nt=null)},_getDirection:function(t,e){return typeof this.options.direction==="function"?this.options.direction.call(this,t,e,ct):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,n=this.el,o=this.options,i=o.preventOnFilter,r=t.type,a=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,l=(a||t).target,s=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||l,u=o.filter;de(n);if(!ct&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||o.disabled)&&!s.isContentEditable&&(this.nativeDraggable||!w||!l||l.tagName.toUpperCase()!=="SELECT")){l=M(l,o.draggable,n,false);if((!l||!l.animated)&>!==l){bt=F(l);wt=F(l,o.draggable);if(typeof u==="function"){if(u.call(this,t,l,this)){ut({sortable:e,rootEl:s,name:"filter",targetEl:l,toEl:n,fromEl:n});st("filter",e,{evt:t});i&&t.preventDefault();return}}else if(u){u=u.split(",").some((function(o){o=M(s,o.trim(),n,false);if(o){ut({sortable:e,rootEl:o,name:"filter",targetEl:l,fromEl:n,toEl:n});st("filter",e,{evt:t});return true}}));if(u){i&&t.preventDefault();return}}o.handle&&!M(s,o.handle,n,false)||this._prepareDragStart(t,a,l)}}}},_prepareDragStart:function(t,e,n){var o,i=this,r=i.el,a=i.options,l=r.ownerDocument;if(n&&!ct&&n.parentNode===r){var s=R(n);ht=r;ct=n;ft=ct.parentNode;pt=ct.nextSibling;gt=n;Et=a.group;ne.dragged=ct;_t={target:ct,clientX:(e||t).clientX,clientY:(e||t).clientY};Mt=_t.clientX-s.left;Ot=_t.clientY-s.top;this._lastX=(e||t).clientX;this._lastY=(e||t).clientY;ct.style["will-change"]="all";o=function(){st("delayEnded",i,{evt:t});if(ne.eventCanceled)i._onDrop();else{i._disableDelayedDragEvents();!y&&i.nativeDraggable&&(ct.draggable=true);i._triggerDragStart(t,e);ut({sortable:i,name:"choose",originalEvent:t});A(ct,a.chosenClass,true)}};a.ignore.split(",").forEach((function(t){P(ct,t.trim(),re)}));_(l,"dragover",te);_(l,"mousemove",te);_(l,"touchmove",te);if(a.supportPointer){_(l,"pointerup",i._onDrop);!this.nativeDraggable&&_(l,"pointercancel",i._onDrop)}else{_(l,"mouseup",i._onDrop);_(l,"touchend",i._onDrop);_(l,"touchcancel",i._onDrop)}if(y&&this.nativeDraggable){this.options.touchStartThreshold=4;ct.draggable=true}st("delayStart",this,{evt:t});if(!a.delay||a.delayOnTouchOnly&&!e||this.nativeDraggable&&(b||m))o();else{if(ne.eventCanceled){this._onDrop();return}if(a.supportPointer){_(l,"pointerup",i._disableDelayedDrag);_(l,"pointercancel",i._disableDelayedDrag)}else{_(l,"mouseup",i._disableDelayedDrag);_(l,"touchend",i._disableDelayedDrag);_(l,"touchcancel",i._disableDelayedDrag)}_(l,"mousemove",i._delayedDragTouchMoveHandler);_(l,"touchmove",i._delayedDragTouchMoveHandler);a.supportPointer&&_(l,"pointermove",i._delayedDragTouchMoveHandler);i._dragStartTimer=setTimeout(o,a.delay)}}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){ct&&re(ct);clearTimeout(this._dragStartTimer);this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;C(t,"mouseup",this._disableDelayedDrag);C(t,"touchend",this._disableDelayedDrag);C(t,"touchcancel",this._disableDelayedDrag);C(t,"pointerup",this._disableDelayedDrag);C(t,"pointercancel",this._disableDelayedDrag);C(t,"mousemove",this._delayedDragTouchMoveHandler);C(t,"touchmove",this._delayedDragTouchMoveHandler);C(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t;if(!this.nativeDraggable||e)this.options.supportPointer?_(document,"pointermove",this._onTouchMove):_(document,e?"touchmove":"mousemove",this._onTouchMove);else{_(ct,"dragend",this);_(ht,"dragstart",this._onDragStart)}try{document.selection?he((function(){document.selection.empty()})):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){Rt=false;if(ht&&ct){st("dragStarted",this,{evt:e});this.nativeDraggable&&_(document,"dragover",ee);var n=this.options;!t&&A(ct,n.dragClass,false);A(ct,n.ghostClass,true);ne.active=this;t&&this._appendGhost();ut({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Ct){this._lastX=Ct.clientX;this._lastY=Ct.clientY;Qt();var t=document.elementFromPoint(Ct.clientX,Ct.clientY);var e=t;while(t&&t.shadowRoot){t=t.shadowRoot.elementFromPoint(Ct.clientX,Ct.clientY);if(t===e)break;e=t}ct.parentNode[J]._isOutsideThisEl(t);if(e)do{if(e[J]){var n=void 0;n=e[J]._onDragOver({clientX:Ct.clientX,clientY:Ct.clientY,target:t,rootEl:e});if(n&&!this.options.dragoverBubble)break}t=e}while(e=x(e));Jt()}},_onTouchMove:function(t){if(_t){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,i=t.touches?t.touches[0]:t,r=dt&&I(dt,true),a=dt&&r&&r.a,l=dt&&r&&r.d,s=Wt&&kt&&H(kt),u=(i.clientX-_t.clientX+o.x)/(a||1)+(s?s[0]-Ht[0]:0)/(a||1),c=(i.clientY-_t.clientY+o.y)/(l||1)+(s?s[1]-Ht[1]:0)/(l||1);if(!ne.active&&!Rt){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))<n)return;this._onDragStart(t,true)}if(dt){if(r){r.e+=u-(Tt||0);r.f+=c-(xt||0)}else r={a:1,b:0,c:0,d:1,e:u,f:c};var f="matrix(".concat(r.a,",").concat(r.b,",").concat(r.c,",").concat(r.d,",").concat(r.e,",").concat(r.f,")");N(dt,"webkitTransform",f);N(dt,"mozTransform",f);N(dt,"msTransform",f);N(dt,"transform",f);Tt=u;xt=c;Ct=i}t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!dt){var t=this.options.fallbackOnBody?document.body:ht,e=R(ct,true,Wt,true,t),n=this.options;if(Wt){kt=t;while(N(kt,"position")==="static"&&N(kt,"transform")==="none"&&kt!==document)kt=kt.parentNode;if(kt!==document.body&&kt!==document.documentElement){kt===document&&(kt=k());e.top+=kt.scrollTop;e.left+=kt.scrollLeft}else kt=k();Ht=H(kt)}dt=ct.cloneNode(true);A(dt,n.ghostClass,false);A(dt,n.fallbackClass,true);A(dt,n.dragClass,true);N(dt,"transition","");N(dt,"transform","");N(dt,"box-sizing","border-box");N(dt,"margin",0);N(dt,"top",e.top);N(dt,"left",e.left);N(dt,"width",e.width);N(dt,"height",e.height);N(dt,"opacity","0.8");N(dt,"position",Wt?"absolute":"fixed");N(dt,"zIndex","100000");N(dt,"pointerEvents","none");ne.ghost=dt;t.appendChild(dt);N(dt,"transform-origin",Mt/parseInt(dt.style.width)*100+"% "+Ot/parseInt(dt.style.height)*100+"%")}},_onDragStart:function(t,e){var n=this;var o=t.dataTransfer;var i=n.options;st("dragStart",this,{evt:t});if(ne.eventCanceled)this._onDrop();else{st("setupClone",this);if(!ne.eventCanceled){vt=V(ct);vt.removeAttribute("id");vt.draggable=false;vt.style["will-change"]="";this._hideClone();A(vt,this.options.chosenClass,false);ne.clone=vt}n.cloneId=he((function(){st("clone",n);if(!ne.eventCanceled){n.options.removeCloneOnHide||ht.insertBefore(vt,ct);n._hideClone();ut({sortable:n,name:"clone"})}}));!e&&A(ct,i.dragClass,true);if(e){Xt=true;n._loopId=setInterval(n._emulateDragOver,50)}else{C(document,"mouseup",n._onDrop);C(document,"touchend",n._onDrop);C(document,"touchcancel",n._onDrop);if(o){o.effectAllowed="move";i.setData&&i.setData.call(n,o,ct)}_(document,"drop",n);N(ct,"transform","translateZ(0)")}Rt=true;n._dragStartId=he(n._dragStarted.bind(n,e,t));_(document,"selectstart",n);At=true;window.getSelection().removeAllRanges();w&&N(document.body,"user-select","none")}},_onDragOver:function(t){var e,n,o,i,r=this.el,a=t.target,s=this.options,u=s.group,c=ne.active,f=Et===u,d=s.sort,h=St||c,p=this,g=false;if(!jt){t.preventDefault!==void 0&&t.cancelable&&t.preventDefault();a=M(a,s.draggable,r,true);P("dragOver");if(ne.eventCanceled)return g;if(ct.contains(t.target)||a.animated&&a.animatingX&&a.animatingY||p._ignoreWhileAnimating===a)return H(false);Xt=false;if(c&&!s.disabled&&(f?d||(o=ft!==ht):St===this||(this.lastPutMode=Et.checkPull(this,c,ct,t))&&u.checkPut(this,c,ct,t))){i=this._getDirection(t,a)==="vertical";e=R(ct);P("dragOverValid");if(ne.eventCanceled)return g;if(o){ft=ht;k();this._hideClone();P("revert");ne.eventCanceled||(pt?ht.insertBefore(ct,pt):ht.appendChild(ct));return H(true)}var v=B(r,s.draggable);if(!v||se(t,i,this)&&!v.animated){if(v===ct)return H(false);v&&r===t.target&&(a=v);a&&(n=R(a));if(ie(ht,r,ct,e,a,n,t,!!a)!==false){k();v&&v.nextSibling?r.insertBefore(ct,v.nextSibling):r.appendChild(ct);ft=r;j();return H(true)}}else if(v&&le(t,i,this)){var m=Y(r,0,s,true);if(m===ct)return H(false);a=m;n=R(a);if(ie(ht,r,ct,e,a,n,t,false)!==false){k();r.insertBefore(ct,m);ft=r;j();return H(true)}}else if(a.parentNode===r){n=R(a);var b,y=0,w=ct.parentNode!==r,D=!Vt(ct.animated&&ct.toRect||e,a.animated&&a.toRect||n,i),E=i?"top":"left",S=X(a,"top","top")||X(ct,"top","top"),_=S?S.scrollTop:void 0;if(Nt!==a){b=n[E];Bt=false;Ft=!D&&s.invertSwap||w}y=ue(t,a,n,i,D?1:s.swapThreshold,s.invertedSwapThreshold==null?s.swapThreshold:s.invertedSwapThreshold,Ft,Nt===a);var C;if(y!==0){var T=F(ct);do{T-=y;C=ft.children[T]}while(C&&(N(C,"display")==="none"||C===dt))}if(y===0||C===a)return H(false);Nt=a;It=y;var x=a.nextElementSibling,O=false;O=y===1;var I=ie(ht,r,ct,e,a,n,t,O);if(I!==false){I!==1&&I!==-1||(O=I===1);jt=true;setTimeout(ae,30);k();O&&!x?r.appendChild(ct):a.parentNode.insertBefore(ct,O?x:a);S&&q(S,0,_-S.scrollTop);ft=ct.parentNode;b===void 0||Ft||(Pt=Math.abs(b-R(a)[E]));j();return H(true)}}if(r.contains(ct))return H(false)}return false}function P(s,u){st(s,p,l({evt:t,isOwner:f,axis:i?"vertical":"horizontal",revert:o,dragRect:e,targetRect:n,canSort:d,fromSortable:h,target:a,completed:H,onMove:function(n,o){return ie(ht,r,ct,e,n,R(n),t,o)},changed:j},u))}function k(){P("dragOverAnimationCapture");p.captureAnimationState();p!==h&&h.captureAnimationState()}function H(e){P("dragOverCompleted",{insertion:e});if(e){f?c._hideClone():c._showClone(p);if(p!==h){A(ct,St?St.options.ghostClass:c.options.ghostClass,false);A(ct,s.ghostClass,true)}St!==p&&p!==ne.active?St=p:p===ne.active&&St&&(St=null);h===p&&(p._ignoreWhileAnimating=a);p.animateAll((function(){P("dragOverAnimationComplete");p._ignoreWhileAnimating=null}));if(p!==h){h.animateAll();h._ignoreWhileAnimating=null}}(a===ct&&!ct.animated||a===r&&!a.animated)&&(Nt=null);if(!s.dragoverBubble&&!t.rootEl&&a!==document){ct.parentNode[J]._isOutsideThisEl(t.target);!e&&te(t)}!s.dragoverBubble&&t.stopPropagation&&t.stopPropagation();return g=true}function j(){yt=F(ct);Dt=F(ct,s.draggable);ut({sortable:p,name:"change",toEl:r,newIndex:yt,newDraggableIndex:Dt,originalEvent:t})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){C(document,"mousemove",this._onTouchMove);C(document,"touchmove",this._onTouchMove);C(document,"pointermove",this._onTouchMove);C(document,"dragover",te);C(document,"mousemove",te);C(document,"touchmove",te)},_offUpEvents:function(){var t=this.el.ownerDocument;C(t,"mouseup",this._onDrop);C(t,"touchend",this._onDrop);C(t,"pointerup",this._onDrop);C(t,"pointercancel",this._onDrop);C(t,"touchcancel",this._onDrop);C(document,"selectstart",this)},_onDrop:function(t){var e=this.el,n=this.options;yt=F(ct);Dt=F(ct,n.draggable);st("drop",this,{evt:t});ft=ct&&ct.parentNode;yt=F(ct);Dt=F(ct,n.draggable);if(ne.eventCanceled)this._nulling();else{Rt=false;Ft=false;Bt=false;clearInterval(this._loopId);clearTimeout(this._dragStartTimer);pe(this.cloneId);pe(this._dragStartId);if(this.nativeDraggable){C(document,"drop",this);C(e,"dragstart",this._onDragStart)}this._offMoveEvents();this._offUpEvents();w&&N(document.body,"user-select","");N(ct,"transform","");if(t){if(At){t.cancelable&&t.preventDefault();!n.dropBubble&&t.stopPropagation()}dt&&dt.parentNode&&dt.parentNode.removeChild(dt);(ht===ft||St&&St.lastPutMode!=="clone")&&vt&&vt.parentNode&&vt.parentNode.removeChild(vt);if(ct){this.nativeDraggable&&C(ct,"dragend",this);re(ct);ct.style["will-change"]="";At&&!Rt&&A(ct,St?St.options.ghostClass:this.options.ghostClass,false);A(ct,this.options.chosenClass,false);ut({sortable:this,name:"unchoose",toEl:ft,newIndex:null,newDraggableIndex:null,originalEvent:t});if(ht!==ft){if(yt>=0){ut({rootEl:ft,name:"add",toEl:ft,fromEl:ht,originalEvent:t});ut({sortable:this,name:"remove",toEl:ft,originalEvent:t});ut({rootEl:ft,name:"sort",toEl:ft,fromEl:ht,originalEvent:t});ut({sortable:this,name:"sort",toEl:ft,originalEvent:t})}St&&St.save()}else if(yt!==bt&&yt>=0){ut({sortable:this,name:"update",toEl:ft,originalEvent:t});ut({sortable:this,name:"sort",toEl:ft,originalEvent:t})}if(ne.active){if(yt==null||yt===-1){yt=bt;Dt=wt}ut({sortable:this,name:"end",toEl:ft,originalEvent:t});this.save()}}}this._nulling()}},_nulling:function(){st("nulling",this);ht=ct=ft=dt=pt=vt=gt=mt=_t=Ct=At=yt=Dt=bt=wt=Nt=It=St=Et=ne.dragged=ne.ghost=ne.clone=ne.active=null;var t=this.el;Lt.forEach((function(e){t.contains(e)&&(e.checked=true)}));Lt.length=Tt=xt=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":if(ct){this._onDragOver(t);oe(t)}break;case"selectstart":t.preventDefault();break}},
|
|
|
/**
|
|
|
* Serializes the item into an array of string.
|
|
|
* @returns {String[]}
|
|
|
*/
|
|
|
toArray:function(){var t,e=[],n=this.el.children,o=0,i=n.length,r=this.options;for(;o<i;o++){t=n[o];M(t,r.draggable,this.el,false)&&e.push(t.getAttribute(r.dataIdAttr)||fe(t))}return e},
|
|
|
/**
|
|
|
* Sorts the elements according to the array.
|
|
|
* @param {String[]} order order of the items
|
|
|
*/
|
|
|
sort:function(t,e){var n={},o=this.el;this.toArray().forEach((function(t,e){var i=o.children[e];M(i,this.options.draggable,o,false)&&(n[t]=i)}),this);e&&this.captureAnimationState();t.forEach((function(t){if(n[t]){o.removeChild(n[t]);o.appendChild(n[t])}}));e&&this.animateAll()},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},
|
|
|
/**
|
|
|
* 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.
|
|
|
* @param {HTMLElement} el
|
|
|
* @param {String} [selector] default: `options.draggable`
|
|
|
* @returns {HTMLElement|null}
|
|
|
*/
|
|
|
closest:function(t,e){return M(t,e||this.options.draggable,this.el,false)},
|
|
|
/**
|
|
|
* Set/get option
|
|
|
* @param {string} name
|
|
|
* @param {*} [value]
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
option:function(t,e){var n=this.options;if(e===void 0)return n[t];var o=rt.modifyOption(this,t,e);n[t]=typeof o!=="undefined"?o:e;t==="group"&&$t(n)},destroy:function(){st("destroy",this);var t=this.el;t[J]=null;C(t,"mousedown",this._onTapStart);C(t,"touchstart",this._onTapStart);C(t,"pointerdown",this._onTapStart);if(this.nativeDraggable){C(t,"dragover",this);C(t,"dragenter",this)}Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),(function(t){t.removeAttribute("draggable")}));this._onDrop();this._disableDelayedDragEvents();Yt.splice(Yt.indexOf(this.el),1);this.el=t=null},_hideClone:function(){if(!mt){st("hideClone",this);if(ne.eventCanceled)return;N(vt,"display","none");this.options.removeCloneOnHide&&vt.parentNode&&vt.parentNode.removeChild(vt);mt=true}},_showClone:function(t){if(t.lastPutMode==="clone"){if(mt){st("showClone",this);if(ne.eventCanceled)return;ct.parentNode!=ht||this.options.group.revertClone?pt?ht.insertBefore(vt,pt):ht.appendChild(vt):ht.insertBefore(vt,ct);this.options.group.revertClone&&this.animate(ct,vt);N(vt,"display","");mt=false}}else this._hideClone()}};function oe(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}function ie(t,e,n,o,i,r,a,l){var s,u,c=t[J],f=c.options.onMove;if(!window.CustomEvent||m||b){s=document.createEvent("Event");s.initEvent("move",true,true)}else s=new CustomEvent("move",{bubbles:true,cancelable:true});s.to=e;s.from=t;s.dragged=n;s.draggedRect=o;s.related=i||e;s.relatedRect=r||R(e);s.willInsertAfter=l;s.originalEvent=a;t.dispatchEvent(s);f&&(u=f.call(c,s,a));return u}function re(t){t.draggable=false}function ae(){jt=false}function le(t,e,n){var o=R(Y(n.el,0,n.options,true));var i=Q(n.el,n.options,dt);var r=10;return e?t.clientX<i.left-r||t.clientY<o.top&&t.clientX<o.right:t.clientY<i.top-r||t.clientY<o.bottom&&t.clientX<o.left}function se(t,e,n){var o=R(B(n.el,n.options.draggable));var i=Q(n.el,n.options,dt);var r=10;return e?t.clientX>i.right+r||t.clientY>o.bottom&&t.clientX>o.left:t.clientY>i.bottom+r||t.clientX>o.right&&t.clientY>o.top}function ue(t,e,n,o,i,r,a,l){var s=o?t.clientY:t.clientX,u=o?n.height:n.width,c=o?n.top:n.left,f=o?n.bottom:n.right,d=false;if(!a)if(l&&Pt<u*i){!Bt&&(It===1?s>c+u*r/2:s<f-u*r/2)&&(Bt=true);if(Bt)d=true;else if(It===1?s<c+Pt:s>f-Pt)return-It}else if(s>c+u*(1-i)/2&&s<f-u*(1-i)/2)return ce(e);d=d||a;return d&&(s<c+u*r/2||s>f-u*r/2)?s>c+u/2?1:-1:0}
|
|
|
/**
|
|
|
* Gets the direction dragEl must be swapped relative to target in order to make it
|
|
|
* seem that dragEl has been "inserted" into that element's position
|
|
|
* @param {HTMLElement} target The target whose position dragEl is being inserted at
|
|
|
* @return {Number} Direction dragEl must be swapped
|
|
|
*/function ce(t){return F(ct)<F(t)?1:-1}
|
|
|
/**
|
|
|
* Generate id
|
|
|
* @param {HTMLElement} el
|
|
|
* @returns {String}
|
|
|
* @private
|
|
|
*/function fe(t){var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,o=0;while(n--)o+=e.charCodeAt(n);return o.toString(36)}function de(t){Lt.length=0;var e=t.getElementsByTagName("input");var n=e.length;while(n--){var o=e[n];o.checked&&Lt.push(o)}}function he(t){return setTimeout(t,0)}function pe(t){return clearTimeout(t)}Kt&&_(document,"touchmove",(function(t){(ne.active||Rt)&&t.cancelable&&t.preventDefault()}));ne.utils={on:_,off:C,css:N,find:P,is:function(t,e){return!!M(t,e,t,false)},extend:K,throttle:G,closest:M,toggleClass:A,clone:V,index:F,nextTick:he,cancelNextTick:pe,detectDirection:qt,getChild:Y,expando:J};
|
|
|
/**
|
|
|
* Get the Sortable instance of an element
|
|
|
* @param {HTMLElement} element The element
|
|
|
* @return {Sortable|undefined} The instance of Sortable
|
|
|
*/ne.get=function(t){return t[J]};
|
|
|
/**
|
|
|
* Mount a plugin to Sortable
|
|
|
* @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
|
|
|
*/ne.mount=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];e[0].constructor===Array&&(e=e[0]);e.forEach((function(t){if(!t.prototype||!t.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(t));t.utils&&(ne.utils=l(l({},ne.utils),t.utils));rt.mount(t)}))};
|
|
|
/**
|
|
|
* Create sortable instance
|
|
|
* @param {HTMLElement} el
|
|
|
* @param {Object} [options]
|
|
|
*/ne.create=function(t,e){return new ne(t,e)};ne.version=g;var ge,ve,me,be,ye,we,De=[],Ee=false;function Se(){function t(){this.defaults={scroll:true,forceAutoScrollFallback:false,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:true};for(var t in this)t.charAt(0)==="_"&&typeof this[t]==="function"&&(this[t]=this[t].bind(this))}t.prototype={dragStarted:function(t){var e=t.originalEvent;this.sortable.nativeDraggable?_(document,"dragover",this._handleAutoScroll):this.options.supportPointer?_(document,"pointermove",this._handleFallbackAutoScroll):e.touches?_(document,"touchmove",this._handleFallbackAutoScroll):_(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var e=t.originalEvent;this.options.dragOverBubble||e.rootEl||this._handleAutoScroll(e)},drop:function(){if(this.sortable.nativeDraggable)C(document,"dragover",this._handleAutoScroll);else{C(document,"pointermove",this._handleFallbackAutoScroll);C(document,"touchmove",this._handleFallbackAutoScroll);C(document,"mousemove",this._handleFallbackAutoScroll)}Ce();_e();U()},nulling:function(){ye=ve=ge=Ee=we=me=be=null;De.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,true)},_handleAutoScroll:function(t,e){var n=this;var o=(t.touches?t.touches[0]:t).clientX,i=(t.touches?t.touches[0]:t).clientY,r=document.elementFromPoint(o,i);ye=t;if(e||this.options.forceAutoScrollFallback||b||m||w){Te(t,this.options,r,e);var a=L(r,true);if(Ee&&(!we||o!==me||i!==be)){we&&Ce();we=setInterval((function(){var r=L(document.elementFromPoint(o,i),true);if(r!==a){a=r;_e()}Te(t,n.options,r,e)}),10);me=o;be=i}}else{if(!this.options.bubbleScroll||L(r,true)===k()){_e();return}Te(t,this.options,L(r,false),false)}}};return o(t,{pluginName:"scroll",initializeByDefault:true})}function _e(){De.forEach((function(t){clearInterval(t.pid)}));De=[]}function Ce(){clearInterval(we)}var Te=G((function(t,e,n,o){if(e.scroll){var i=(t.touches?t.touches[0]:t).clientX,r=(t.touches?t.touches[0]:t).clientY,a=e.scrollSensitivity,l=e.scrollSpeed,s=k();var u,c=false;if(ve!==n){ve=n;_e();ge=e.scroll;u=e.scrollFn;ge===true&&(ge=L(n,true))}var f=0;var d=ge;do{var h=d,p=R(h),g=p.top,v=p.bottom,m=p.left,b=p.right,y=p.width,w=p.height,D=void 0,E=void 0,S=h.scrollWidth,_=h.scrollHeight,C=N(h),T=h.scrollLeft,x=h.scrollTop;if(h===s){D=y<S&&(C.overflowX==="auto"||C.overflowX==="scroll"||C.overflowX==="visible");E=w<_&&(C.overflowY==="auto"||C.overflowY==="scroll"||C.overflowY==="visible")}else{D=y<S&&(C.overflowX==="auto"||C.overflowX==="scroll");E=w<_&&(C.overflowY==="auto"||C.overflowY==="scroll")}var M=D&&(Math.abs(b-i)<=a&&T+y<S)-(Math.abs(m-i)<=a&&!!T);var O=E&&(Math.abs(v-r)<=a&&x+w<_)-(Math.abs(g-r)<=a&&!!x);if(!De[f])for(var A=0;A<=f;A++)De[A]||(De[A]={});if(De[f].vx!=M||De[f].vy!=O||De[f].el!==h){De[f].el=h;De[f].vx=M;De[f].vy=O;clearInterval(De[f].pid);if(M!=0||O!=0){c=true;De[f].pid=setInterval(function(){o&&this.layer===0&&ne.active._onTouchMove(ye);var e=De[this.layer].vy?De[this.layer].vy*l:0;var n=De[this.layer].vx?De[this.layer].vx*l:0;typeof u==="function"&&u.call(ne.dragged.parentNode[J],n,e,t,ye,De[this.layer].el)!=="continue"||q(De[this.layer].el,n,e)}.bind({layer:f}),24)}}f++}while(e.bubbleScroll&&d!==s&&(d=L(d,false)));Ee=c}}),30);var xe=function(t){var e=t.originalEvent,n=t.putSortable,o=t.dragEl,i=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget;if(e){var s=n||i;a();var u=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e;var c=document.elementFromPoint(u.clientX,u.clientY);l();if(s&&!s.el.contains(c)){r("spill");this.onSpill({dragEl:o,putSortable:n})}}};function Me(){}Me.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){var e=t.dragEl,n=t.putSortable;this.sortable.captureAnimationState();n&&n.captureAnimationState();var o=Y(this.sortable.el,this.startIndex,this.options);o?this.sortable.el.insertBefore(e,o):this.sortable.el.appendChild(e);this.sortable.animateAll();n&&n.animateAll()},drop:xe};o(Me,{pluginName:"revertOnSpill"});function Oe(){}Oe.prototype={onSpill:function(t){var e=t.dragEl,n=t.putSortable;var o=n||this.sortable;o.captureAnimationState();e.parentNode&&e.parentNode.removeChild(e);o.animateAll()},drop:xe};o(Oe,{pluginName:"removeOnSpill"});var Ae;function Ne(){function t(){this.defaults={swapClass:"sortable-swap-highlight"}}t.prototype={dragStart:function(t){var e=t.dragEl;Ae=e},dragOverValid:function(t){var e=t.completed,n=t.target,o=t.onMove,i=t.activeSortable,r=t.changed,a=t.cancel;if(i.options.swap){var l=this.sortable.el,s=this.options;if(n&&n!==l){var u=Ae;if(o(n)!==false){A(n,s.swapClass,true);Ae=n}else Ae=null;u&&u!==Ae&&A(u,s.swapClass,false)}r();e(true);a()}},drop:function(t){var e=t.activeSortable,n=t.putSortable,o=t.dragEl;var i=n||this.sortable;var r=this.options;Ae&&A(Ae,r.swapClass,false);if(Ae&&(r.swap||n&&n.options.swap)&&o!==Ae){i.captureAnimationState();i!==e&&e.captureAnimationState();Ie(o,Ae);i.animateAll();i!==e&&e.animateAll()}},nulling:function(){Ae=null}};return o(t,{pluginName:"swap",eventProperties:function(){return{swapItem:Ae}}})}function Ie(t,e){var n,o,i=t.parentNode,r=e.parentNode;if(i&&r&&!i.isEqualNode(e)&&!r.isEqualNode(t)){n=F(t);o=F(e);i.isEqualNode(r)&&n<o&&o++;i.insertBefore(e,i.children[n]);r.insertBefore(t,r.children[o])}}var Pe,ke,Re,Xe,Ye,Be=[],Fe=[],He=false,je=false,Le=false;function Ke(){function t(t){for(var e in this)e.charAt(0)==="_"&&typeof this[e]==="function"&&(this[e]=this[e].bind(this));if(!t.options.avoidImplicitDeselect)if(t.options.supportPointer)_(document,"pointerup",this._deselectMultiDrag);else{_(document,"mouseup",this._deselectMultiDrag);_(document,"touchend",this._deselectMultiDrag)}_(document,"keydown",this._checkKeyDown);_(document,"keyup",this._checkKeyUp);this.defaults={selectedClass:"sortable-selected",multiDragKey:null,avoidImplicitDeselect:false,setData:function(e,n){var o="";Be.length&&ke===t?Be.forEach((function(t,e){o+=(e?", ":"")+t.textContent})):o=n.textContent;e.setData("Text",o)}}}t.prototype={multiDragKeyDown:false,isMultiDrag:false,delayStartGlobal:function(t){var e=t.dragEl;Re=e},delayEnded:function(){this.isMultiDrag=~Be.indexOf(Re)},setupClone:function(t){var e=t.sortable,n=t.cancel;if(this.isMultiDrag){for(var o=0;o<Be.length;o++){Fe.push(V(Be[o]));Fe[o].sortableIndex=Be[o].sortableIndex;Fe[o].draggable=false;Fe[o].style["will-change"]="";A(Fe[o],this.options.selectedClass,false);Be[o]===Re&&A(Fe[o],this.options.chosenClass,false)}e._hideClone();n()}},clone:function(t){var e=t.sortable,n=t.rootEl,o=t.dispatchSortableEvent,i=t.cancel;if(this.isMultiDrag&&!this.options.removeCloneOnHide&&Be.length&&ke===e){ze(true,n);o("clone");i()}},showClone:function(t){var e=t.cloneNowShown,n=t.rootEl,o=t.cancel;if(this.isMultiDrag){ze(false,n);Fe.forEach((function(t){N(t,"display","")}));e();Ye=false;o()}},hideClone:function(t){var e=this;t.sortable;var n=t.cloneNowHidden,o=t.cancel;if(this.isMultiDrag){Fe.forEach((function(t){N(t,"display","none");e.options.removeCloneOnHide&&t.parentNode&&t.parentNode.removeChild(t)}));n();Ye=true;o()}},dragStartGlobal:function(t){t.sortable;!this.isMultiDrag&&ke&&ke.multiDrag._deselectMultiDrag();Be.forEach((function(t){t.sortableIndex=F(t)}));Be=Be.sort((function(t,e){return t.sortableIndex-e.sortableIndex}));Le=true},dragStarted:function(t){var e=this;var n=t.sortable;if(this.isMultiDrag){if(this.options.sort){n.captureAnimationState();if(this.options.animation){Be.forEach((function(t){t!==Re&&N(t,"position","absolute")}));var o=R(Re,false,true,true);Be.forEach((function(t){t!==Re&&Z(t,o)}));je=true;He=true}}n.animateAll((function(){je=false;He=false;e.options.animation&&Be.forEach((function(t){$(t)}));e.options.sort&&Ge()}))}},dragOver:function(t){var e=t.target,n=t.completed,o=t.cancel;if(je&&~Be.indexOf(e)){n(false);o()}},revert:function(t){var e=t.fromSortable,n=t.rootEl,o=t.sortable,i=t.dragRect;if(Be.length>1){Be.forEach((function(t){o.addAnimationState({target:t,rect:je?R(t):i});$(t);t.fromRect=i;e.removeAnimationState(t)}));je=false;We(!this.options.removeCloneOnHide,n)}},dragOverCompleted:function(t){var e=t.sortable,n=t.isOwner,o=t.insertion,i=t.activeSortable,r=t.parentEl,a=t.putSortable;var l=this.options;if(o){n&&i._hideClone();He=false;if(l.animation&&Be.length>1&&(je||!n&&!i.options.sort&&!a)){var s=R(Re,false,true,true);Be.forEach((function(t){if(t!==Re){Z(t,s);r.appendChild(t)}}));je=true}if(!n){je||Ge();if(Be.length>1){var u=Ye;i._showClone(e);i.options.animation&&!Ye&&u&&Fe.forEach((function(t){i.addAnimationState({target:t,rect:Xe});t.fromRect=Xe;t.thisAnimationDuration=null}))}else i._showClone(e)}}},dragOverAnimationCapture:function(t){var e=t.dragRect,n=t.isOwner,i=t.activeSortable;Be.forEach((function(t){t.thisAnimationDuration=null}));if(i.options.animation&&!n&&i.multiDrag.isMultiDrag){Xe=o({},e);var r=I(Re,true);Xe.top-=r.f;Xe.left-=r.e}},dragOverAnimationComplete:function(){if(je){je=false;Ge()}},drop:function(t){var e=t.originalEvent,n=t.rootEl,o=t.parentEl,i=t.sortable,r=t.dispatchSortableEvent,a=t.oldIndex,l=t.putSortable;var s=l||this.sortable;if(e){var u=this.options,c=o.children;if(!Le){u.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag();A(Re,u.selectedClass,!~Be.indexOf(Re));if(~Be.indexOf(Re)){Be.splice(Be.indexOf(Re),1);Pe=null;at({sortable:i,rootEl:n,name:"deselect",targetEl:Re,originalEvent:e})}else{Be.push(Re);at({sortable:i,rootEl:n,name:"select",targetEl:Re,originalEvent:e});if(e.shiftKey&&Pe&&i.el.contains(Pe)){var f=F(Pe),d=F(Re);~f&&~d&&f!==d&&function(){var t,r;if(d>f){r=f;t=d}else{r=d;t=f+1}var a=u.filter;for(;r<t;r++)if(!~Be.indexOf(c[r])&&M(c[r],u.draggable,o,false)){var l=a&&(typeof a==="function"?a.call(i,e,c[r],i):a.split(",").some((function(t){return M(c[r],t.trim(),o,false)})));if(!l){A(c[r],u.selectedClass,true);Be.push(c[r]);at({sortable:i,rootEl:n,name:"select",targetEl:c[r],originalEvent:e})}}}()}else Pe=Re;ke=s}}if(Le&&this.isMultiDrag){je=false;if((o[J].options.sort||o!==n)&&Be.length>1){var h=R(Re),p=F(Re,":not(."+this.options.selectedClass+")");!He&&u.animation&&(Re.thisAnimationDuration=null);s.captureAnimationState();if(!He){if(u.animation){Re.fromRect=h;Be.forEach((function(t){t.thisAnimationDuration=null;if(t!==Re){var e=je?R(t):h;t.fromRect=e;s.addAnimationState({target:t,rect:e})}}))}Ge();Be.forEach((function(t){c[p]?o.insertBefore(t,c[p]):o.appendChild(t);p++}));if(a===F(Re)){var g=false;Be.forEach((function(t){t.sortableIndex===F(t)||(g=true)}));if(g){r("update");r("sort")}}}Be.forEach((function(t){$(t)}));s.animateAll()}ke=s}(n===o||l&&l.lastPutMode!=="clone")&&Fe.forEach((function(t){t.parentNode&&t.parentNode.removeChild(t)}))}},nullingGlobal:function(){this.isMultiDrag=Le=false;Fe.length=0},destroyGlobal:function(){this._deselectMultiDrag();C(document,"pointerup",this._deselectMultiDrag);C(document,"mouseup",this._deselectMultiDrag);C(document,"touchend",this._deselectMultiDrag);C(document,"keydown",this._checkKeyDown);C(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if((typeof Le==="undefined"||!Le)&&ke===this.sortable&&(!t||!M(t.target,this.options.draggable,this.sortable.el,false))&&(!t||t.button===0))while(Be.length){var e=Be[0];A(e,this.options.selectedClass,false);Be.shift();at({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:e,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=true)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=false)}};return o(t,{pluginName:"multiDrag",utils:{
|
|
|
/**
|
|
|
* Selects the provided multi-drag item
|
|
|
* @param {HTMLElement} el The element to be selected
|
|
|
*/
|
|
|
select:function(t){var e=t.parentNode[J];if(e&&e.options.multiDrag&&!~Be.indexOf(t)){if(ke&&ke!==e){ke.multiDrag._deselectMultiDrag();ke=e}A(t,e.options.selectedClass,true);Be.push(t)}},
|
|
|
/**
|
|
|
* Deselects the provided multi-drag item
|
|
|
* @param {HTMLElement} el The element to be deselected
|
|
|
*/
|
|
|
deselect:function(t){var e=t.parentNode[J],n=Be.indexOf(t);if(e&&e.options.multiDrag&&~n){A(t,e.options.selectedClass,false);Be.splice(n,1)}}},eventProperties:function(){var t=this;var e=[],n=[];Be.forEach((function(o){e.push({multiDragElement:o,index:o.sortableIndex});var i;i=je&&o!==Re?-1:je?F(o,":not(."+t.options.selectedClass+")"):F(o);n.push({multiDragElement:o,index:i})}));return{items:c(Be),clones:[].concat(Fe),oldIndicies:e,newIndicies:n}},optionListeners:{multiDragKey:function(t){t=t.toLowerCase();t==="ctrl"?t="Control":t.length>1&&(t=t.charAt(0).toUpperCase()+t.substr(1));return t}}})}function We(t,e){Be.forEach((function(n,o){var i=e.children[n.sortableIndex+(t?Number(o):0)];i?e.insertBefore(n,i):e.appendChild(n)}))}
|
|
|
/**
|
|
|
* Insert multi-drag clones
|
|
|
* @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
|
|
|
* @param {HTMLElement} rootEl
|
|
|
*/function ze(t,e){Fe.forEach((function(n,o){var i=e.children[n.sortableIndex+(t?Number(o):0)];i?e.insertBefore(n,i):e.appendChild(n)}))}function Ge(){Be.forEach((function(t){t!==Re&&t.parentNode&&t.parentNode.removeChild(t)}))}ne.mount(new Se);ne.mount(Oe,Me);export{Ke as MultiDrag,ne as Sortable,Ne as Swap,ne as default};
|
|
|
|