提交 f4973c89 编写于 作者: M Marius Petcu

Ran grunt

上级 5d24bc6e
(function(factory){"use strict";if(typeof define==="function"&&define.amd){define(factory)}else if(typeof module!="undefined"&&typeof module.exports!="undefined"){module.exports=factory()}else{window["Sortable"]=factory()}})(function(){"use strict";var dragEl,ghostEl,rootEl,nextEl,lastEl,lastCSS,lastRect,activeGroup,tapEvt,touchEvt,expando="Sortable"+(new Date).getTime(),win=window,document=win.document,parseInt=win.parseInt,supportIEdnd=!!document.createElement("div").dragDrop,_silent=false,_createEvent=function(event,item){var evt=document.createEvent("Event");evt.initEvent(event,true,true);evt.item=item;return evt},noop=function(){},slice=[].slice,touchDragOverListeners=[];function Sortable(el,options){this.el=el;this.options=options=options||{};options.group=options.group||Math.random();options.handle=options.handle||null;options.draggable=options.draggable||el.children[0]&&el.children[0].nodeName||(/[uo]l/i.test(el.nodeName)?"li":"*");options.ghostClass=options.ghostClass||"sortable-ghost";options.ignore=options.ignore||"a, img";options.onAdd=_bind(this,options.onAdd||noop);options.onUpdate=_bind(this,options.onUpdate||noop);options.onRemove=_bind(this,options.onRemove||noop);el[expando]=options.group;for(var fn in this){if(fn.charAt(0)==="_"){this[fn]=_bind(this,this[fn])}}_on(el,"add",options.onAdd);_on(el,"update",options.onUpdate);_on(el,"remove",options.onRemove);_on(el,"mousedown",this._onTapStart);_on(el,"touchstart",this._onTapStart);supportIEdnd&&_on(el,"selectstart",this._onTapStart);_on(el,"dragover",this._onDragOver);_on(el,"dragenter",this._onDragOver);touchDragOverListeners.push(this._onDragOver)}Sortable.prototype={constructor:Sortable,_applyEffects:function(){_toggleClass(dragEl,this.options.ghostClass,true)},_onTapStart:function(evt){var touch=evt.touches&&evt.touches[0],target=(touch||evt).target,options=this.options,el=this.el;if(options.handle){target=_closest(target,options.handle,el)}target=_closest(target,options.draggable,el);if(target&&evt.type=="selectstart"){if(target.tagName!="A"&&target.tagName!="IMG"){target.dragDrop()}}if(target&&!dragEl&&target.parentNode===el){tapEvt=evt;target.draggable=true;Array.prototype.forEach.call(options.ignore.split(","),function(criteria){_find(target,criteria.trim(),_disableDraggable)});if(touch){tapEvt={target:target,clientX:touch.clientX,clientY:touch.clientY};this._onDragStart(tapEvt,true);evt.preventDefault()}_on(this.el,"dragstart",this._onDragStart);_on(this.el,"dragend",this._onDrop);_on(document,"dragover",_globalDragOver);try{if(document.selection){document.selection.empty()}else{window.getSelection().removeAllRanges()}}catch(err){}}},_emulateDragOver:function(){if(touchEvt){_css(ghostEl,"display","none");var target=document.elementFromPoint(touchEvt.clientX,touchEvt.clientY),parent=target,group=this.options.group,i=touchDragOverListeners.length;if(parent){do{if(parent[expando]===group){while(i--){touchDragOverListeners[i]({clientX:touchEvt.clientX,clientY:touchEvt.clientY,target:target,rootEl:parent})}break}target=parent}while(parent=parent.parentNode)}_css(ghostEl,"display","")}},_onTouchMove:function(evt){if(tapEvt){var touch=evt.touches[0],dx=touch.clientX-tapEvt.clientX,dy=touch.clientY-tapEvt.clientY;touchEvt=touch;_css(ghostEl,"webkitTransform","translate3d("+dx+"px,"+dy+"px,0)")}},_onDragStart:function(evt,isTouch){var target=evt.target,dataTransfer=evt.dataTransfer;rootEl=this.el;dragEl=target;nextEl=target.nextSibling;activeGroup=this.options.group;if(isTouch){var rect=target.getBoundingClientRect(),css=_css(target),ghostRect;ghostEl=target.cloneNode(true);_css(ghostEl,"top",rect.top-parseInt(css.marginTop,10));_css(ghostEl,"left",rect.left-parseInt(css.marginLeft,10));_css(ghostEl,"width",rect.width);_css(ghostEl,"height",rect.height);_css(ghostEl,"opacity","0.8");_css(ghostEl,"position","fixed");_css(ghostEl,"zIndex","100000");rootEl.appendChild(ghostEl);ghostRect=ghostEl.getBoundingClientRect();_css(ghostEl,"width",rect.width*2-ghostRect.width);_css(ghostEl,"height",rect.height*2-ghostRect.height);_on(document,"touchmove",this._onTouchMove);_on(document,"touchend",this._onDrop);this._loopId=setInterval(this._emulateDragOver,150)}else{dataTransfer.effectAllowed="move";dataTransfer.setData("Text",target.textContent);_on(document,"drop",this._onDrop)}setTimeout(this._applyEffects)},_onDragOver:function(evt){if(!_silent&&activeGroup===this.options.group&&(evt.rootEl===void 0||evt.rootEl===this.el)){var el=this.el,target=_closest(evt.target,this.options.draggable,el);if(el.children.length===0||el.children[0]===ghostEl||el===evt.target&&_ghostInBottom(el,evt)){el.appendChild(dragEl)}else if(target&&target!==dragEl&&target.parentNode[expando]!==void 0){if(lastEl!==target){lastEl=target;lastCSS=_css(target);lastRect=target.getBoundingClientRect()}var rect=lastRect,width=rect.right-rect.left,height=rect.bottom-rect.top,floating=/left|right|inline/.test(lastCSS.cssFloat+lastCSS.display),skew=(floating?(evt.clientX-rect.left)/width:(evt.clientY-rect.top)/height)>.5,isWide=target.offsetWidth>dragEl.offsetWidth,isLong=target.offsetHeight>dragEl.offsetHeight,nextSibling=target.nextSibling,after;_silent=true;setTimeout(_unsilent,30);if(floating){after=target.previousElementSibling===dragEl&&!isWide||skew>.5&&isWide}else{after=target.nextElementSibling!==dragEl&&!isLong||skew>.5&&isLong}if(after&&!nextSibling){el.appendChild(dragEl)}else{target.parentNode.insertBefore(dragEl,after?nextSibling:target)}}}},_onDrop:function(evt){clearInterval(this._loopId);_off(document,"drop",this._onDrop);_off(document,"dragover",_globalDragOver);_off(this.el,"dragend",this._onDrop);_off(this.el,"dragstart",this._onDragStart);_off(this.el,"selectstart",this._onTapStart);_off(document,"touchmove",this._onTouchMove);_off(document,"touchend",this._onDrop);if(evt){evt.preventDefault();evt.stopPropagation();if(ghostEl){ghostEl.parentNode.removeChild(ghostEl)}if(dragEl){_disableDraggable(dragEl);_toggleClass(dragEl,this.options.ghostClass,false);if(!rootEl.contains(dragEl)){rootEl.dispatchEvent(_createEvent("remove",dragEl));dragEl.dispatchEvent(_createEvent("add",dragEl))}else if(dragEl.nextSibling!==nextEl){dragEl.dispatchEvent(_createEvent("update",dragEl))}}rootEl=dragEl=ghostEl=nextEl=tapEvt=touchEvt=lastEl=lastCSS=activeGroup=null}},destroy:function(){var el=this.el,options=this.options;_off(el,"add",options.onAdd);_off(el,"update",options.onUpdate);_off(el,"remove",options.onRemove);_off(el,"mousedown",this._onTapStart);_off(el,"touchstart",this._onTapStart);_off(el,"selectstart",this._onTapStart);_off(el,"dragover",this._onDragOver);_off(el,"dragenter",this._onDragOver);Array.prototype.forEach.call(el.querySelectorAll("[draggable]"),function(el){el.removeAttribute("draggable")});touchDragOverListeners.splice(touchDragOverListeners.indexOf(this._onDragOver),1);this._onDrop();this.el=null}};function _bind(ctx,fn){var args=slice.call(arguments,2);return fn.bind?fn.bind.apply(fn,[ctx].concat(args)):function(){return fn.apply(ctx,args.concat(slice.call(arguments)))}}function _closest(el,selector,ctx){if(selector==="*"){return el}else if(el){ctx=ctx||document;selector=selector.split(".");var tag=selector.shift().toUpperCase(),re=new RegExp("\\s("+selector.join("|")+")\\s","g");do{if((tag===""||el.nodeName==tag)&&(!selector.length||((" "+el.className+" ").match(re)||[]).length==selector.length)){return el}}while(el!==ctx&&(el=el.parentNode))}return null}function _globalDragOver(evt){evt.dataTransfer.dropEffect="move";evt.preventDefault()}function _on(el,event,fn){el.addEventListener(event,fn,false)}function _off(el,event,fn){el.removeEventListener(event,fn,false)}function _toggleClass(el,name,state){if(el){if(el.classList){el.classList[state?"add":"remove"](name)}else{var className=(" "+el.className+" ").replace(/\s+/g," ").replace(" "+name+" ","");el.className=className+(state?" "+name:"")}}}function _css(el,prop,val){if(el&&el.style){if(val===void 0){if(document.defaultView&&document.defaultView.getComputedStyle){val=document.defaultView.getComputedStyle(el,"")}else if(el.currentStyle){val=el.currentStyle}return prop===void 0?val:val[prop]}else{el.style[prop]=val+(typeof val==="string"?"":"px")}}}function _find(ctx,tagName,iterator){if(ctx){var list=ctx.getElementsByTagName(tagName),i=0,n=list.length;if(iterator){for(;i<n;i++){iterator(list[i],i)}}return list}return[]}function _disableDraggable(el){return el.draggable=false}function _unsilent(){_silent=false}function _ghostInBottom(el,evt){var last=el.lastElementChild.getBoundingClientRect();return evt.clientY-(last.top+last.height)>5}Sortable.utils={on:_on,off:_off,css:_css,find:_find,bind:_bind,closest:_closest,toggleClass:_toggleClass};Sortable.version="0.1.9";return Sortable});
\ No newline at end of file
/*! 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)"),h(n,"transform","translate3d("+c+"px,"+d+"px,0)"),a.preventDefault()}},_onDragStart:function(a,b){var c=a.target,d=a.dataTransfer;if(o=this.el,m=c,p=c.nextSibling,t=this.options.group,b){var f,g=c.getBoundingClientRect(),i=h(c);n=c.cloneNode(!0),h(n,"top",g.top-D(i.marginTop,10)),h(n,"left",g.left-D(i.marginLeft,10)),h(n,"width",g.width),h(n,"height",g.height),h(n,"opacity","0.8"),h(n,"position","fixed"),h(n,"zIndex","100000"),o.appendChild(n),f=n.getBoundingClientRect(),h(n,"width",2*g.width-f.width),h(n,"height",2*g.height-f.height),e(C,"touchmove",this._onTouchMove),e(C,"touchend",this._onDrop),e(C,"touchcancel",this._onDrop),e(C,y,this._onTouchMove),e(C,x,this._onDrop),e(C,z,this._onDrop),this._loopId=setInterval(this._emulateDragOver,150)}else d.effectAllowed="move",d.setData("Text",c.textContent),e(C,"drop",this._onDrop);setTimeout(this._applyEffects)},_onDragOver:function(a){if(!F&&t===this.options.group&&(void 0===a.rootEl||a.rootEl===this.el)){var b=this.el,d=c(a.target,this.options.draggable,b);if(0===b.children.length||b.children[0]===n||b===a.target&&l(b,a))b.appendChild(m);else if(d&&d!==m&&void 0!==d.parentNode[A]){q!==d&&(q=d,r=h(d),s=d.getBoundingClientRect());var e,f=s,g=f.right-f.left,i=f.bottom-f.top,j=/left|right|inline/.test(r.cssFloat+r.display),o=(j?(a.clientX-f.left)/g:(a.clientY-f.top)/i)>.5,p=d.offsetWidth>m.offsetWidth,u=d.offsetHeight>m.offsetHeight,v=d.nextSibling;F=!0,setTimeout(k,30),e=j?d.previousElementSibling===m&&!p||o>.5&&p:d.nextElementSibling!==m&&!u||o>.5&&u,e&&!v?b.appendChild(m):d.parentNode.insertBefore(m,e?v:d)}}},_onDrop:function(a){clearInterval(this._loopId),f(C,"drop",this._onDrop),f(C,"dragover",d),f(this.el,"dragend",this._onDrop),f(this.el,"dragstart",this._onDragStart),f(this.el,"selectstart",this._onTapStart),f(C,"touchmove",this._onTouchMove),f(C,"touchend",this._onDrop),f(C,"touchcancel",this._onDrop),f(C,y,this._onTouchMove),f(C,x,this._onDrop),f(C,z,this._onDrop),a&&(a.preventDefault(),a.stopPropagation(),n&&n.parentNode.removeChild(n),m&&(j(m),g(m,this.options.ghostClass,!1),o.contains(m)?m.nextSibling!==p&&m.dispatchEvent(G("update",m)):(o.dispatchEvent(G("remove",m)),m.dispatchEvent(G("add",m)))),o=m=n=p=u=v=q=r=t=null)},destroy:function(){var a=this.el,b=this.options;f(a,"add",b.onAdd),f(a,"update",b.onUpdate),f(a,"remove",b.onRemove),f(a,"mousedown",this._onTapStart),f(a,"touchstart",this._onTapStart),f(a,"selectstart",this._onTapStart),f(a,w,this._onTapStart),f(a,"dragover",this._onDragOver),f(a,"dragenter",this._onDragOver),Array.prototype.forEach.call(a.querySelectorAll("[draggable]"),function(a){a.removeAttribute("draggable")}),J.splice(J.indexOf(this._onDragOver),1),this._onDrop(),this.el=null}},a.utils={on:e,off:f,css:h,find:i,bind:b,closest:c,toggleClass:g},a.version="0.1.9",a});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册