From b28b57635fd3337c72630a10c86c613c6f3a69eb Mon Sep 17 00:00:00 2001 From: Marius Petcu Date: Mon, 30 Jun 2014 12:00:26 +0300 Subject: [PATCH 1/8] Added vim swap files to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 574dc3b..840d87c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules mock.png +.*.sw* From d272d12e785c56042bfe5d579fc27a6c4a4dad1c Mon Sep 17 00:00:00 2001 From: Marius Petcu Date: Mon, 30 Jun 2014 12:03:20 +0300 Subject: [PATCH 2/8] IE11 support --- Sortable.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Sortable.js b/Sortable.js index 69f9ae2..2b44f62 100644 --- a/Sortable.js +++ b/Sortable.js @@ -104,6 +104,10 @@ _on(el, 'dragover', this._onDragOver); _on(el, 'dragenter', this._onDragOver); + _on(el, 'pointerdown', this._onTapStart); + + _css(el, 'touch-action', 'none'); + _css(el, '-ms-touch-action', 'none'); touchDragOverListeners.push(this._onDragOver); } @@ -158,7 +162,11 @@ this._onDragStart(tapEvt, true); evt.preventDefault(); } - + + if (evt.type == 'pointerdown') { + this._onDragStart(tapEvt, true); + evt.preventDefault(); + } _on(this.el, 'dragstart', this._onDragStart); _on(this.el, 'dragend', this._onDrop); @@ -211,16 +219,19 @@ }, - _onTouchMove: function (evt/**TouchEvent*/){ + _onTouchMove: function (evt/**TouchEvent|PointerEvent*/){ if( tapEvt ){ var - touch = evt.touches[0] + touch = (evt.type == 'pointermove') ? evt : evt.touches[0] , dx = touch.clientX - tapEvt.clientX , dy = touch.clientY - tapEvt.clientY ; touchEvt = touch; _css(ghostEl, 'webkitTransform', 'translate3d('+dx+'px,'+dy+'px,0)'); + _css(ghostEl, 'mozTransform', 'translate3d('+dx+'px,'+dy+'px,0)'); + _css(ghostEl, 'msTransform', 'translate3d('+dx+'px,'+dy+'px,0)'); + _css(ghostEl, 'transform', 'translate3d('+dx+'px,'+dy+'px,0)'); } }, @@ -263,6 +274,8 @@ // Bind touch events _on(document, 'touchmove', this._onTouchMove); _on(document, 'touchend', this._onDrop); + _on(document, 'pointermove', this._onTouchMove); + _on(document, 'pointerup', this._onDrop); this._loopId = setInterval(this._emulateDragOver, 150); } @@ -339,6 +352,8 @@ _off(document, 'touchmove', this._onTouchMove); _off(document, 'touchend', this._onDrop); + _off(document, 'pointermove', this._onTouchMove); + _off(document, 'pointerup', this._onDrop); if( evt ){ @@ -393,6 +408,7 @@ _off(el, 'mousedown', this._onTapStart); _off(el, 'touchstart', this._onTapStart); _off(el, 'selectstart', this._onTapStart); + _off(el, 'pointerdown', this._onTapStart); _off(el, 'dragover', this._onDragOver); _off(el, 'dragenter', this._onDragOver); From 66038b3ddd0b31e9ca4f468c151b5fefefa2cba0 Mon Sep 17 00:00:00 2001 From: Marius Petcu Date: Mon, 30 Jun 2014 12:32:25 +0300 Subject: [PATCH 3/8] IE10 pointer event support --- Sortable.js | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Sortable.js b/Sortable.js index 2b44f62..f8f2c38 100644 --- a/Sortable.js +++ b/Sortable.js @@ -55,6 +55,10 @@ , slice = [].slice , touchDragOverListeners = [] + + ,pointerdown + ,pointerup + ,pointermove ; @@ -92,6 +96,16 @@ } } + // Detect IE10/IE11+ + if (window.onpointerdown !== undefined) { + pointerdown = 'pointerdown'; + pointerup = 'pointerup'; + pointermove = 'pointermove'; + } else { + pointerdown = 'MSPointerDown'; + pointerup = 'MSPointerUp'; + pointermove = 'MSPointerMove'; + } // Bind events _on(el, 'add', options.onAdd); @@ -104,7 +118,7 @@ _on(el, 'dragover', this._onDragOver); _on(el, 'dragenter', this._onDragOver); - _on(el, 'pointerdown', this._onTapStart); + _on(el, pointerdown, this._onTapStart); _css(el, 'touch-action', 'none'); _css(el, '-ms-touch-action', 'none'); @@ -122,7 +136,7 @@ }, - _onTapStart: function (evt/**Event|TouchEvent*/){ + _onTapStart: function (evt/**Event|TouchEvent|PointerEvent*/){ var touch = evt.touches && evt.touches[0] , target = (touch || evt).target @@ -163,7 +177,7 @@ evt.preventDefault(); } - if (evt.type == 'pointerdown') { + if (evt.type == 'pointerdown' || evt.type == 'MSPointerDown') { this._onDragStart(tapEvt, true); evt.preventDefault(); } @@ -222,7 +236,7 @@ _onTouchMove: function (evt/**TouchEvent|PointerEvent*/){ if( tapEvt ){ var - touch = (evt.type == 'pointermove') ? evt : evt.touches[0] + touch = (evt.type == 'pointermove' || evt.type == 'MSPointerMove') ? evt : evt.touches[0] , dx = touch.clientX - tapEvt.clientX , dy = touch.clientY - tapEvt.clientY ; @@ -232,6 +246,7 @@ _css(ghostEl, 'mozTransform', 'translate3d('+dx+'px,'+dy+'px,0)'); _css(ghostEl, 'msTransform', 'translate3d('+dx+'px,'+dy+'px,0)'); _css(ghostEl, 'transform', 'translate3d('+dx+'px,'+dy+'px,0)'); + evt.preventDefault(); } }, @@ -274,8 +289,8 @@ // Bind touch events _on(document, 'touchmove', this._onTouchMove); _on(document, 'touchend', this._onDrop); - _on(document, 'pointermove', this._onTouchMove); - _on(document, 'pointerup', this._onDrop); + _on(document, pointermove, this._onTouchMove); + _on(document, pointerup, this._onDrop); this._loopId = setInterval(this._emulateDragOver, 150); } @@ -352,8 +367,8 @@ _off(document, 'touchmove', this._onTouchMove); _off(document, 'touchend', this._onDrop); - _off(document, 'pointermove', this._onTouchMove); - _off(document, 'pointerup', this._onDrop); + _off(document, pointermove, this._onTouchMove); + _off(document, pointerup, this._onDrop); if( evt ){ @@ -408,7 +423,7 @@ _off(el, 'mousedown', this._onTapStart); _off(el, 'touchstart', this._onTapStart); _off(el, 'selectstart', this._onTapStart); - _off(el, 'pointerdown', this._onTapStart); + _off(el, pointerdown, this._onTapStart); _off(el, 'dragover', this._onDragOver); _off(el, 'dragenter', this._onDragOver); From 5d24bc6ef4bb8724264be6b9c327f8d567cfdaae Mon Sep 17 00:00:00 2001 From: Marius Petcu Date: Mon, 30 Jun 2014 12:37:46 +0300 Subject: [PATCH 4/8] Supports touchcancel --- Sortable.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sortable.js b/Sortable.js index f8f2c38..9f8a4f0 100644 --- a/Sortable.js +++ b/Sortable.js @@ -59,6 +59,7 @@ ,pointerdown ,pointerup ,pointermove + ,pointercancel ; @@ -101,10 +102,12 @@ pointerdown = 'pointerdown'; pointerup = 'pointerup'; pointermove = 'pointermove'; + pointercancel = 'pointercancel'; } else { pointerdown = 'MSPointerDown'; pointerup = 'MSPointerUp'; pointermove = 'MSPointerMove'; + pointercancel = 'MSPointerCancel'; } // Bind events @@ -289,8 +292,10 @@ // Bind touch events _on(document, 'touchmove', this._onTouchMove); _on(document, 'touchend', this._onDrop); + _on(document, 'touchcancel', this._onDrop); _on(document, pointermove, this._onTouchMove); _on(document, pointerup, this._onDrop); + _on(document, pointercancel, this._onDrop); this._loopId = setInterval(this._emulateDragOver, 150); } @@ -367,8 +372,10 @@ _off(document, 'touchmove', this._onTouchMove); _off(document, 'touchend', this._onDrop); + _off(document, 'touchcancel', this._onDrop); _off(document, pointermove, this._onTouchMove); _off(document, pointerup, this._onDrop); + _off(document, pointercancel, this._onDrop); if( evt ){ From f4973c8984115d91571ef04f1849aad880c4c63d Mon Sep 17 00:00:00 2001 From: Marius Petcu Date: Mon, 30 Jun 2014 12:38:59 +0300 Subject: [PATCH 5/8] Ran grunt --- Sortable.min.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sortable.min.js b/Sortable.min.js index 2a8e2ca..d0521a0 100644 --- a/Sortable.min.js +++ b/Sortable.min.js @@ -1 +1,2 @@ -(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(;i5}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 From a022e35858f7f11a54d689fa73b42dc9a381d3c7 Mon Sep 17 00:00:00 2001 From: Marius Petcu Date: Mon, 30 Jun 2014 13:16:52 +0300 Subject: [PATCH 6/8] Fixed identation --- Sortable.js | 86 ++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/Sortable.js b/Sortable.js index 9f8a4f0..f596f3d 100644 --- a/Sortable.js +++ b/Sortable.js @@ -21,7 +21,7 @@ "use strict"; var - dragEl + dragEl , ghostEl , rootEl , nextEl @@ -56,10 +56,10 @@ , touchDragOverListeners = [] - ,pointerdown - ,pointerup - ,pointermove - ,pointercancel + ,pointerdown + ,pointerup + ,pointermove + ,pointercancel ; @@ -97,18 +97,18 @@ } } - // Detect IE10/IE11+ - if (window.onpointerdown !== undefined) { - pointerdown = 'pointerdown'; - pointerup = 'pointerup'; - pointermove = 'pointermove'; - pointercancel = 'pointercancel'; - } else { - pointerdown = 'MSPointerDown'; - pointerup = 'MSPointerUp'; - pointermove = 'MSPointerMove'; - pointercancel = 'MSPointerCancel'; - } + // Detect IE10/IE11+ + if (window.onpointerdown !== undefined) { + pointerdown = 'pointerdown'; + pointerup = 'pointerup'; + pointermove = 'pointermove'; + pointercancel = 'pointercancel'; + } else { + pointerdown = 'MSPointerDown'; + pointerup = 'MSPointerUp'; + pointermove = 'MSPointerMove'; + pointercancel = 'MSPointerCancel'; + } // Bind events _on(el, 'add', options.onAdd); @@ -121,10 +121,10 @@ _on(el, 'dragover', this._onDragOver); _on(el, 'dragenter', this._onDragOver); - _on(el, pointerdown, this._onTapStart); + _on(el, pointerdown, this._onTapStart); - _css(el, 'touch-action', 'none'); - _css(el, '-ms-touch-action', 'none'); + _css(el, 'touch-action', 'none'); + _css(el, '-ms-touch-action', 'none'); touchDragOverListeners.push(this._onDragOver); } @@ -141,7 +141,7 @@ _onTapStart: function (evt/**Event|TouchEvent|PointerEvent*/){ var - touch = evt.touches && evt.touches[0] + touch = evt.touches && evt.touches[0] , target = (touch || evt).target , options = this.options , el = this.el @@ -172,18 +172,18 @@ if( touch ){ // Touch device support tapEvt = { - target: target + target: target , clientX: touch.clientX , clientY: touch.clientY }; this._onDragStart(tapEvt, true); evt.preventDefault(); } - - if (evt.type == 'pointerdown' || evt.type == 'MSPointerDown') { - this._onDragStart(tapEvt, true); - evt.preventDefault(); - } + + if (evt.type == 'pointerdown' || evt.type == 'MSPointerDown') { + this._onDragStart(tapEvt, true); + evt.preventDefault(); + } _on(this.el, 'dragstart', this._onDragStart); _on(this.el, 'dragend', this._onDrop); @@ -206,7 +206,7 @@ _css(ghostEl, 'display', 'none'); var - target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY) + target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY) , parent = target , group = this.options.group , i = touchDragOverListeners.length @@ -239,7 +239,7 @@ _onTouchMove: function (evt/**TouchEvent|PointerEvent*/){ if( tapEvt ){ var - touch = (evt.type == 'pointermove' || evt.type == 'MSPointerMove') ? evt : evt.touches[0] + touch = (evt.type == 'pointermove' || evt.type == 'MSPointerMove') ? evt : evt.touches[0] , dx = touch.clientX - tapEvt.clientX , dy = touch.clientY - tapEvt.clientY ; @@ -249,14 +249,14 @@ _css(ghostEl, 'mozTransform', 'translate3d('+dx+'px,'+dy+'px,0)'); _css(ghostEl, 'msTransform', 'translate3d('+dx+'px,'+dy+'px,0)'); _css(ghostEl, 'transform', 'translate3d('+dx+'px,'+dy+'px,0)'); - evt.preventDefault(); + evt.preventDefault(); } }, _onDragStart: function (evt/**Event*/, isTouch/**Boolean*/){ var - target = evt.target + target = evt.target , dataTransfer = evt.dataTransfer ; @@ -267,7 +267,7 @@ if( isTouch ){ var - rect = target.getBoundingClientRect() + rect = target.getBoundingClientRect() , css = _css(target) , ghostRect ; @@ -293,9 +293,9 @@ _on(document, 'touchmove', this._onTouchMove); _on(document, 'touchend', this._onDrop); _on(document, 'touchcancel', this._onDrop); - _on(document, pointermove, this._onTouchMove); - _on(document, pointerup, this._onDrop); - _on(document, pointercancel, this._onDrop); + _on(document, pointermove, this._onTouchMove); + _on(document, pointerup, this._onDrop); + _on(document, pointercancel, this._onDrop); this._loopId = setInterval(this._emulateDragOver, 150); } @@ -313,7 +313,7 @@ _onDragOver: function (evt/**Event*/){ if( !_silent && (activeGroup === this.options.group) && (evt.rootEl === void 0 || evt.rootEl === this.el) ){ var - el = this.el + el = this.el , target = _closest(evt.target, this.options.draggable, el) ; @@ -329,7 +329,7 @@ var - rect = lastRect + rect = lastRect , width = rect.right - rect.left , height = rect.bottom - rect.top , floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) @@ -373,9 +373,9 @@ _off(document, 'touchmove', this._onTouchMove); _off(document, 'touchend', this._onDrop); _off(document, 'touchcancel', this._onDrop); - _off(document, pointermove, this._onTouchMove); - _off(document, pointerup, this._onDrop); - _off(document, pointercancel, this._onDrop); + _off(document, pointermove, this._onTouchMove); + _off(document, pointerup, this._onDrop); + _off(document, pointercancel, this._onDrop); if( evt ){ @@ -430,7 +430,7 @@ _off(el, 'mousedown', this._onTapStart); _off(el, 'touchstart', this._onTapStart); _off(el, 'selectstart', this._onTapStart); - _off(el, pointerdown, this._onTapStart); + _off(el, pointerdown, this._onTapStart); _off(el, 'dragover', this._onDragOver); _off(el, 'dragenter', this._onDragOver); @@ -465,13 +465,13 @@ selector = selector.split('.'); var - tag = selector.shift().toUpperCase() + tag = selector.shift().toUpperCase() , re = new RegExp('\\s('+selector.join('|')+')\\s', 'g') ; do { if( - (tag === '' || el.nodeName == tag) + (tag === '' || el.nodeName == tag) && (!selector.length || ((' '+el.className+' ').match(re) || []).length == selector.length) ){ return el; From b45807462d6bb62fd6153f1d1b32512a4e1de4b7 Mon Sep 17 00:00:00 2001 From: Marius Petcu Date: Mon, 30 Jun 2014 13:23:27 +0300 Subject: [PATCH 7/8] Fixed the identation once again --- Sortable.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Sortable.js b/Sortable.js index f596f3d..62f78e4 100644 --- a/Sortable.js +++ b/Sortable.js @@ -21,7 +21,7 @@ "use strict"; var - dragEl + dragEl , ghostEl , rootEl , nextEl @@ -141,7 +141,7 @@ _onTapStart: function (evt/**Event|TouchEvent|PointerEvent*/){ var - touch = evt.touches && evt.touches[0] + touch = evt.touches && evt.touches[0] , target = (touch || evt).target , options = this.options , el = this.el @@ -172,7 +172,7 @@ if( touch ){ // Touch device support tapEvt = { - target: target + target: target , clientX: touch.clientX , clientY: touch.clientY }; @@ -206,7 +206,7 @@ _css(ghostEl, 'display', 'none'); var - target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY) + target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY) , parent = target , group = this.options.group , i = touchDragOverListeners.length @@ -239,7 +239,7 @@ _onTouchMove: function (evt/**TouchEvent|PointerEvent*/){ if( tapEvt ){ var - touch = (evt.type == 'pointermove' || evt.type == 'MSPointerMove') ? evt : evt.touches[0] + touch = evt.touches[0] , dx = touch.clientX - tapEvt.clientX , dy = touch.clientY - tapEvt.clientY ; @@ -256,7 +256,7 @@ _onDragStart: function (evt/**Event*/, isTouch/**Boolean*/){ var - target = evt.target + target = evt.target , dataTransfer = evt.dataTransfer ; @@ -267,7 +267,7 @@ if( isTouch ){ var - rect = target.getBoundingClientRect() + rect = target.getBoundingClientRect() , css = _css(target) , ghostRect ; @@ -313,7 +313,7 @@ _onDragOver: function (evt/**Event*/){ if( !_silent && (activeGroup === this.options.group) && (evt.rootEl === void 0 || evt.rootEl === this.el) ){ var - el = this.el + el = this.el , target = _closest(evt.target, this.options.draggable, el) ; @@ -329,7 +329,7 @@ var - rect = lastRect + rect = lastRect , width = rect.right - rect.left , height = rect.bottom - rect.top , floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) @@ -465,13 +465,13 @@ selector = selector.split('.'); var - tag = selector.shift().toUpperCase() + tag = selector.shift().toUpperCase() , re = new RegExp('\\s('+selector.join('|')+')\\s', 'g') ; do { if( - (tag === '' || el.nodeName == tag) + (tag === '' || el.nodeName == tag) && (!selector.length || ((' '+el.className+' ').match(re) || []).length == selector.length) ){ return el; From 363f5e9a1c241fc1dd5bf1f7adae310bb2456929 Mon Sep 17 00:00:00 2001 From: Marius Petcu Date: Mon, 30 Jun 2014 13:35:09 +0300 Subject: [PATCH 8/8] Added spaces after commas --- Sortable.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sortable.js b/Sortable.js index 62f78e4..a45686c 100644 --- a/Sortable.js +++ b/Sortable.js @@ -56,10 +56,10 @@ , touchDragOverListeners = [] - ,pointerdown - ,pointerup - ,pointermove - ,pointercancel + , pointerdown + , pointerup + , pointermove + , pointercancel ;