You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
6.8 KiB

11 years ago
/*! Sortable 0.1.9 - MIT | git://github.com/rubaxa/Sortable.git */
!function(a){"use strict";"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=a():window.Sortable=a()}(function(){"use strict";function a(a,c){this.el=a,this.options=c=c||{},c.group=c.group||Math.random(),c.handle=c.handle||null,c.draggable=c.draggable||a.children[0]&&a.children[0].nodeName||(/[uo]l/i.test(a.nodeName)?"li":"*"),c.ghostClass=c.ghostClass||"sortable-ghost",c.ignore=c.ignore||"a, img",c.onAdd=b(this,c.onAdd||H),c.onUpdate=b(this,c.onUpdate||H),c.onRemove=b(this,c.onRemove||H),a[A]=c.group;for(var d in this)"_"===d.charAt(0)&&(this[d]=b(this,this[d]));void 0!==window.onpointerdown?(w="pointerdown",x="pointerup",y="pointermove",z="pointercancel"):(w="MSPointerDown",x="MSPointerUp",y="MSPointerMove",z="MSPointerCancel"),e(a,"add",c.onAdd),e(a,"update",c.onUpdate),e(a,"remove",c.onRemove),e(a,"mousedown",this._onTapStart),e(a,"touchstart",this._onTapStart),E&&e(a,"selectstart",this._onTapStart),e(a,"dragover",this._onDragOver),e(a,"dragenter",this._onDragOver),e(a,w,this._onTapStart),h(a,"touch-action","none"),h(a,"-ms-touch-action","none"),J.push(this._onDragOver)}function b(a,b){var c=I.call(arguments,2);return b.bind?b.bind.apply(b,[a].concat(c)):function(){return b.apply(a,c.concat(I.call(arguments)))}}function c(a,b,c){if("*"===b)return a;if(a){c=c||C,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){if(a&&a.style){if(void 0===c)return C.defaultView&&C.defaultView.getComputedStyle?c=C.defaultView.getComputedStyle(a,""):a.currentStyle&&(c=a.currentStyle),void 0===b?c:c[b];a.style[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){return a.draggable=!1}function k(){F=!1}function l(a,b){var c=a.lastElementChild.getBoundingClientRect();return b.clientY-(c.top+c.height)>5}var m,n,o,p,q,r,s,t,u,v,w,x,y,z,A="Sortable"+(new Date).getTime(),B=window,C=B.document,D=B.parseInt,E=!!C.createElement("div").dragDrop,F=!1,G=function(a,b){var c=C.createEvent("Event");return c.initEvent(a,!0,!0),c.item=b,c},H=function(){},I=[].slice,J=[];return a.prototype={constructor:a,_applyEffects:function(){g(m,this.options.ghostClass,!0)},_onTapStart:function(a){var b=a.touches&&a.touches[0],f=(b||a).target,g=this.options,h=this.el;if(g.handle&&(f=c(f,g.handle,h)),f=c(f,g.draggable,h),f&&"selectstart"==a.type&&"A"!=f.tagName&&"IMG"!=f.tagName&&f.dragDrop(),f&&!m&&f.parentNode===h){u=a,f.draggable=!0,Array.prototype.forEach.call(g.ignore.split(","),function(a){i(f,a.trim(),j)}),b&&(u={target:f,clientX:b.clientX,clientY:b.clientY},this._onDragStart(u,!0),a.preventDefault()),("pointerdown"==a.type||"MSPointerDown"==a.type)&&(this._onDragStart(u,!0),a.preventDefault()),e(this.el,"dragstart",this._onDragStart),e(this.el,"dragend",this._onDrop),e(C,"dragover",d);try{C.selection?C.selection.empty():window.getSelection().removeAllRanges()}catch(k){}}},_emulateDragOver:function(){if(v){h(n,"display","none");var a=C.elementFromPoint(v.clientX,v.clientY),b=a,c=this.options.group,d=J.length;if(b)do{if(b[A]===c){for(;d--;)J[d]({clientX:v.clientX,clientY:v.clientY,target:a,rootEl:b});break}a=b}while(b=b.parentNode);h(n,"display","")}},_onTouchMove:function(a){if(u){var b="pointermove"==a.type||"MSPointerMove"==a.type?a:a.touches[0],c=b.clientX-u.clientX,d=b.clientY-u.clientY;v=b,h(n,"webkitTransform","translate3d("+c+"px,"+d+"px,0)"),h(n,"mozTransform","translate3d("+c+"px,"+d+"px,0)"),h(n,"msTransform","translate3d("+c+"px,"+d+"px,0)