|
|
|
!function(a){"use strict";"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=a():"undefined"!=typeof Package?Sortable=a():window.Sortable=a()}(function(){"use strict";function a(a,c){this.el=a,this.options=c=c||{};var d={group:Math.random(),sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,draggable:a.children[0]&&a.children[0].nodeName||(/[uo]l/i.test(a.nodeName)?"li":"*"),ghostClass:"sortable-ghost",ignore:"a, img",filter:null,animation:0,setData:function(a,b){a.setData("Text",b.textContent)}};for(var f in d)!(f in c)&&(c[f]=d[f]);c.group.name||(c.group={name:c.group}),["pull","put"].forEach(function(a){a in c.group||(c.group[a]=!0)}),J.forEach(function(d){c[d]=b(this,c[d]||K),e(a,d.substr(2).toLowerCase(),c[d])},this),a[C]=c.group.name;for(var g in this)"_"===g.charAt(0)&&(this[g]=b(this,this[g]));e(a,"mousedown",this._onTapStart),e(a,"touchstart",this._onTapStart),G&&e(a,"selectstart",this._onTapStart),e(a,"dragover",this._onDragOver),e(a,"dragenter",this._onDragOver),N.push(this._onDragOver),c.store&&this.sort(c.store.get(this))}function b(a,b){var c=M.call(arguments,2);return b.bind?b.bind.apply(b,[a].concat(c)):function(){return b.apply(a,c.concat(M.call(arguments)))}}function c(a,b,c){if("*"===b)return a;if(a){c=c||E,b=b.split(".");var d=b.shift().toUpperCase(),e=new RegExp("\\s("+b.join("|")+")\\s","g");do if(!(""!==d&&a.nodeName!=d||b.length&&((" "+a.className+" ").match(e)||[]).length!=b.length))return a;while(a!==c&&(a=a.parentNode))}return null}function d(a){a.dataTransfer.dropEffect="move",a.preventDefault()}function e(a,b,c){a.addEventListener(b,c,!1)}function f(a,b,c){a.removeEventListener(b,c,!1)}function g(a,b,c){if(a)if(a.classList)a.classList[c?"add":"remove"](b);else{var d=(" "+a.className+" ").replace(/\s+/g," ").replace(" "+b+" ","");a.className=d+(c?" "+b:"")}}function h(a,b,c){var d=a&&a.style;if(d){if(void 0===c)return E.defaultView&&E.defaultView.getComputedStyle?c=E.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];b in d||(b="-webkit-"+b),d[b]=c+("string"==typeof c?"":"px")}}function i(a,b,c){if(a){var d=a.getElementsByTagName(b),e=0,f=d.length;if(c)for(;f>e;e++)c(d[e],e);return d}return[]}function j(a){a.draggable=!1}function k(){H=!1}function l(a,b){var c=a.lastElementChild,d=c.getBoundingClientRect();return b.clientY-(d.top+d.height)>5&&c}function m(a){for(var b=a.tagName+a.className+a.src+a.href+a.textContent,c=b.length,d=0;c--;)d+=b.charCodeAt(c);return d.toString(36)}function n(a){for(var b=0;a&&(a=a.previousElementSibling);)b++;return b}function o(a,b){var c,d;return function(){void 0===c&&(c=arguments,d=this,setTimeout(function(){1===c.length?a.call(d,c[0]):a.apply(d,c),c=void 0},b))}}var p,q,r,s,t,u,v,w,x,y,z,A,B={},C="Sortable"+(new Date).getTime(),D=window,E=D.document,F=D.parseInt,G=!!E.createElement("div").dragDrop,H=!1,I=function(a,b,c,d,e,f){var g=E.createEvent("Event");g.initEvent(b,!0,!0),g.item=c||a,g.from=d||a,g.oldIndex=e,g.newIndex=f,a.dispatchEvent(g)},J="onAdd onUpdate onRemove onStart onEnd onFilter onSort".split(" "),K=function(){},L=Math.abs,M=[].slice,N=[];return a.prototype={constructor:a,_applyEffects:function(){g(p,this.options.ghostClass,!0)},_onTapStart:function(a){var b=a.touches&&a.touches[0],d=(b||a).target,f=d,g=this.options,k=this.el,l=g.filter;if(!("mousedown"===a.type&&0!==a.button||g.disabled)){if(g.handle&&(d=c(d,g.handle,k)),d=c(d,g.draggable,k),q=n(d),"function"==typeof l){if(l.call(this,a,d,this))return I(f,"filter",d,k,q),void 0}else if(l&&(l=l.split(",").some(function(a){return a=c(f,a.trim(),k),a?(I(a,"filter",d,k,q),!0):void 0}),l.length))return;if(d&&"selectstart"==a.type&&"A"!=d.tagName&&"IMG"!=d.tagName&&d.dragDrop(),d&&!p&&d.parentNode===k){z=a,t=this.el,p=d,v=p.nextSibling,y=this.options.group,p.draggable=!0,g.ignore.split(",").forEach(function(a){i(d,a.trim(),j)}),b&&(z={target:d,clientX:b.clientX,clientY:b.clientY},this._onDragStart(z,!0),a.preventDefault()),e(E,"mouseup",this._onDrop),e(
|