forked from gilsondia/angular-drag-and-drop-lists
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
!function(e){var n="application/x-dnd",a="application/json",r="Text",t=["move","copy","link"];function d(e,n){return"all"==n?e:e.filter(function(e){return-1!=n.toLowerCase().indexOf(e)})}e.directive("dndDraggable",["$parse","$timeout",function(e,i){return function(l,f,c){f.attr("draggable","true"),c.dndDisableIf&&l.$watch(c.dndDisableIf,function(e){f.attr("draggable",!e)}),f.on("dragstart",function(s){if(s=s.originalEvent||s,"false"==f.attr("draggable"))return!0;o.isDragging=!0,o.itemType=c.dndType&&l.$eval(c.dndType).toLowerCase(),o.dropEffect="none",o.effectAllowed=c.dndEffectAllowed||t[0],s.dataTransfer.effectAllowed=o.effectAllowed;var g=l.$eval(c.dndDraggable),u=n+(o.itemType?"-"+o.itemType:"");try{s.dataTransfer.setData(u,angular.toJson(g))}catch(e){var p=angular.toJson({item:g,type:o.itemType});try{s.dataTransfer.setData(a,p)}catch(e){var v=d(t,o.effectAllowed);s.dataTransfer.effectAllowed=v[0],s.dataTransfer.setData(r,p)}}if(f.addClass("dndDragging"),i(function(){f.addClass("dndDraggingSource")},0),s._dndHandle&&s.dataTransfer.setDragImage&&s.dataTransfer.setDragImage(f[0],0,0),e(c.dndDragstart)(l,{event:s}),c.dndCallback){var D=e(c.dndCallback);o.callback=function(e){return D(l,e||{})}}s.stopPropagation()}),f.on("dragend",function(n){n=n.originalEvent||n,l.$apply(function(){var a=o.dropEffect;e(c[{copy:"dndCopied",link:"dndLinked",move:"dndMoved",none:"dndCanceled"}[a]])(l,{event:n}),e(c.dndDragend)(l,{event:n,dropEffect:a})}),o.isDragging=!1,o.callback=void 0,f.removeClass("dndDragging"),f.removeClass("dndDraggingSource"),n.stopPropagation(),i(function(){f.removeClass("dndDraggingSource")},0)}),f.on("click",function(n){c.dndSelected&&(n=n.originalEvent||n,l.$apply(function(){e(c.dndSelected)(l,{event:n})}),n.stopPropagation())}),f.on("selectstart",function(){this.dragDrop&&this.dragDrop()})}}]),e.directive("dndList",["$parse",function(e){return function(i,l,f){var c=function(){var e;return angular.forEach(l.children(),function(n){var a=angular.element(n);a.hasClass("dndPlaceholder")&&(e=a)}),e||angular.element("<li class='dndPlaceholder'></li>")}();c.remove();var s=c[0],g=l[0],u={};function p(e){if(!e)return r;for(var t=0;t<e.length;t++)if(e[t]==r||e[t]==a||e[t].substr(0,n.length)==n)return e[t];return null}function v(e){return o.isDragging?o.itemType||void 0:e==r||e==a?null:e&&e.substr(n.length+1)||void 0}function D(e){return!u.disabled&&(!(!u.externalSources&&!o.isDragging)&&(!u.allowedTypes||null===e||e&&-1!=u.allowedTypes.indexOf(e)))}function y(e,n){var a=t;return n||(a=d(a,e.dataTransfer.effectAllowed)),o.isDragging&&(a=d(a,o.effectAllowed)),f.dndEffectAllowed&&(a=d(a,f.dndEffectAllowed)),a.length?e.ctrlKey&&-1!=a.indexOf("copy")?"copy":e.altKey&&-1!=a.indexOf("link")?"link":a[0]:"none"}function T(){return c.remove(),l.removeClass("dndDragover"),!0}function h(n,a,r,t,d,l){return e(n)(i,{callback:o.callback,dropEffect:r,event:a,external:!o.isDragging,index:void 0!==d?d:m(),item:l||void 0,type:t})}function m(){return Array.prototype.indexOf.call(g.children,s)}l.on("dragenter",function(e){e=e.originalEvent||e;var n=f.dndAllowedTypes&&i.$eval(f.dndAllowedTypes);u={allowedTypes:angular.isArray(n)&&n.join("|").toLowerCase().split("|"),disabled:f.dndDisableIf&&i.$eval(f.dndDisableIf),externalSources:f.dndExternalSources&&i.$eval(f.dndExternalSources),horizontal:f.dndHorizontalList&&i.$eval(f.dndHorizontalList)};var a=p(e.dataTransfer.types);if(!a||!D(v(a)))return!0;e.preventDefault()}),l.on("dragover",function(e){var n=p((e=e.originalEvent||e).dataTransfer.types),a=v(n);if(!n||!D(a))return!0;if(s.parentNode!=g&&l.append(c),e.target!=g){for(var t=e.target;t.parentNode!=g&&t.parentNode;)t=t.parentNode;if(t.parentNode==g&&t!=s){var d=t.getBoundingClientRect();if(u.horizontal)var o=e.clientX<d.left+d.width/2;else o=e.clientY<d.top+d.height/2;o?t.previousSibling!=s&&g.insertBefore(s,t):t.nextSibling!=s&&g.insertBefore(s,t.nextSibling)}}var i=n==r,m=y(e,i);return"none"==m?T():f.dndDragover&&!h(f.dndDragover,e,m,a)?T():(e.preventDefault(),i||(e.dataTransfer.dropEffect=m),l.addClass("dndDragover"),e.stopPropagation(),!1)}),l.on("drop",function(e){var n=p((e=e.originalEvent||e).dataTransfer.types),t=v(n);if(!n||!D(t))return!0;e.preventDefault();try{var d=JSON.parse(e.dataTransfer.getData(n))}catch(e){return T()}if((n==r||n==a)&&(t=d.type||void 0,d=d.item,!D(t)))return T();var l=n==r,c=y(e,l);if("none"==c)return T();var s=m();return f.dndDrop&&!(d=h(f.dndDrop,e,c,t,s,d))?T():(o.dropEffect=c,l||(e.dataTransfer.dropEffect=c),!0!==d&&i.$apply(function(){i.$eval(f.dndList).splice(s,0,d)}),h(f.dndInserted,e,c,t,s,d),T(),e.stopPropagation(),!1)}),l.on("dragleave",function(e){e=e.originalEvent||e;var n=document.elementFromPoint(e.clientX,e.clientY);g.contains(n)&&!e._dndPhShown?e._dndPhShown=!0:T()})}}]),e.directive("dndNodrag",function(){return function(e,n,a){n.attr("draggable","true"),n.on("dragstart",function(e){(e=e.originalEvent||e)._dndHandle||(e.dataTransfer.types&&e.dataTransfer.types.length||e.preventDefault(),e.stopPropagation())}),n.on("dragend",function(e){(e=e.originalEvent||e)._dndHandle||e.stopPropagation()})}}),e.directive("dndHandle",function(){return function(e,n,a){n.attr("draggable","true"),n.on("dragstart dragend",function(e){(e=e.originalEvent||e)._dndHandle=!0})}});var o={}}(angular.module("dndLists",[])); | ||
/** | ||
* angular-drag-and-drop-lists v2.1.0 | ||
* | ||
* Copyright (c) 2014 Marcel Juenemann [email protected] | ||
* Copyright (c) 2014-2017 Google Inc. | ||
* https://github.com/marceljuenemann/angular-drag-and-drop-lists | ||
* | ||
* License: MIT | ||
*/ | ||
!function(e){function n(e,n){return"all"==n?e:e.filter(function(e){return-1!=n.toLowerCase().indexOf(e)})}var a="application/x-dnd",r="application/json",t="Text",d=["move","copy","link"] | ||
e.directive("dndDraggable",["$parse","$timeout",function(e,i){return function(l,f,c){f.attr("draggable","true"),c.dndDisableIf&&l.$watch(c.dndDisableIf,function(e){f.attr("draggable",!e)}),f.on("dragstart",function(s){if(s=s.originalEvent||s,"false"==f.attr("draggable"))return!0 | ||
o.isDragging=!0,o.itemType=c.dndType&&l.$eval(c.dndType).toLowerCase(),o.dropEffect="none",o.effectAllowed=c.dndEffectAllowed||d[0],s.dataTransfer.effectAllowed=o.effectAllowed | ||
var g=l.$eval(c.dndDraggable),u=a+(o.itemType?"-"+o.itemType:"") | ||
try{s.dataTransfer.setData(u,angular.toJson(g))}catch(e){var p=angular.toJson({item:g,type:o.itemType}) | ||
try{s.dataTransfer.setData(r,p)}catch(e){var v=n(d,o.effectAllowed) | ||
s.dataTransfer.effectAllowed=v[0],s.dataTransfer.setData(t,p)}}if(f.addClass("dndDragging"),i(function(){f.addClass("dndDraggingSource")},0),s._dndHandle&&s.dataTransfer.setDragImage&&s.dataTransfer.setDragImage(f[0],0,0),e(c.dndDragstart)(l,{event:s}),c.dndCallback){var D=e(c.dndCallback) | ||
o.callback=function(e){return D(l,e||{})}}s.stopPropagation()}),f.on("dragend",function(n){n=n.originalEvent||n,l.$apply(function(){var a=o.dropEffect | ||
e(c[{copy:"dndCopied",link:"dndLinked",move:"dndMoved",none:"dndCanceled"}[a]])(l,{event:n}),e(c.dndDragend)(l,{event:n,dropEffect:a})}),o.isDragging=!1,o.callback=void 0,f.removeClass("dndDragging"),f.removeClass("dndDraggingSource"),n.stopPropagation(),i(function(){f.removeClass("dndDraggingSource")},0)}),f.on("click",function(n){c.dndSelected&&(n=n.originalEvent||n,l.$apply(function(){e(c.dndSelected)(l,{event:n})}),n.stopPropagation())}),f.on("selectstart",function(){this.dragDrop&&this.dragDrop()})}}]),e.directive("dndList",["$parse",function(e){return function(i,l,f){function c(e){if(!e)return t | ||
for(var n=0;n<e.length;n++)if(e[n]==t||e[n]==r||e[n].substr(0,a.length)==a)return e[n] | ||
return null}function s(e){return o.isDragging?o.itemType||void 0:e==t||e==r?null:e&&e.substr(a.length+1)||void 0}function g(e){return!m.disabled&&(!(!m.externalSources&&!o.isDragging)&&(!m.allowedTypes||null===e||e&&-1!=m.allowedTypes.indexOf(e)))}function u(e,a){var r=d | ||
return a||(r=n(r,e.dataTransfer.effectAllowed)),o.isDragging&&(r=n(r,o.effectAllowed)),f.dndEffectAllowed&&(r=n(r,f.dndEffectAllowed)),r.length?e.ctrlKey&&-1!=r.indexOf("copy")?"copy":e.altKey&&-1!=r.indexOf("link")?"link":r[0]:"none"}function p(){return y.remove(),l.removeClass("dndDragover"),!0}function v(n,a,r,t,d,l){return e(n)(i,{callback:o.callback,dropEffect:r,event:a,external:!o.isDragging,index:void 0!==d?d:D(),item:l||void 0,type:t})}function D(){return Array.prototype.indexOf.call(h.children,T)}var y=function(){var e | ||
return angular.forEach(l.children(),function(n){var a=angular.element(n) | ||
a.hasClass("dndPlaceholder")&&(e=a)}),e||angular.element("<li class='dndPlaceholder'></li>")}() | ||
y.remove() | ||
var T=y[0],h=l[0],m={} | ||
l.on("dragenter",function(e){e=e.originalEvent||e | ||
var n=f.dndAllowedTypes&&i.$eval(f.dndAllowedTypes) | ||
m={allowedTypes:angular.isArray(n)&&n.join("|").toLowerCase().split("|"),disabled:f.dndDisableIf&&i.$eval(f.dndDisableIf),externalSources:f.dndExternalSources&&i.$eval(f.dndExternalSources),horizontal:f.dndHorizontalList&&i.$eval(f.dndHorizontalList)} | ||
var a=c(e.dataTransfer.types) | ||
if(!a||!g(s(a)))return!0 | ||
e.preventDefault()}),l.on("dragover",function(e){e=e.originalEvent||e | ||
var n=c(e.dataTransfer.types),a=s(n) | ||
if(!n||!g(a))return!0 | ||
if(T.parentNode!=h&&l.append(y),e.target!=h){for(var r=e.target;r.parentNode!=h&&r.parentNode;)r=r.parentNode | ||
if(r.parentNode==h&&r!=T){var d=r.getBoundingClientRect() | ||
if(m.horizontal)var o=e.clientX<d.left+d.width/2 | ||
else var o=e.clientY<d.top+d.height/2 | ||
o?r.previousSibling!=T&&h.insertBefore(T,r):r.nextSibling!=T&&h.insertBefore(T,r.nextSibling)}}var i=n==t,D=u(e,i) | ||
return"none"==D?p():f.dndDragover&&!v(f.dndDragover,e,D,a)?p():(e.preventDefault(),i||(e.dataTransfer.dropEffect=D),l.addClass("dndDragover"),e.stopPropagation(),!1)}),l.on("drop",function(e){e=e.originalEvent||e | ||
var n=c(e.dataTransfer.types),a=s(n) | ||
if(!n||!g(a))return!0 | ||
e.preventDefault() | ||
try{var d=JSON.parse(e.dataTransfer.getData(n))}catch(e){return p()}if((n==t||n==r)&&(a=d.type||void 0,d=d.item,!g(a)))return p() | ||
var l=n==t,y=u(e,l) | ||
if("none"==y)return p() | ||
var T=D() | ||
return f.dndDrop&&!(d=v(f.dndDrop,e,y,a,T,d))?p():(o.dropEffect=y,l||(e.dataTransfer.dropEffect=y),!0!==d&&i.$apply(function(){i.$eval(f.dndList).splice(T,0,d)}),v(f.dndInserted,e,y,a,T,d),p(),e.stopPropagation(),!1)}),l.on("dragleave",function(e){e=e.originalEvent||e | ||
var n=document.elementFromPoint(e.clientX,e.clientY) | ||
h.contains(n)&&!e._dndPhShown?e._dndPhShown=!0:p()})}}]),e.directive("dndNodrag",function(){return function(e,n,a){n.attr("draggable","true"),n.on("dragstart",function(e){e=e.originalEvent||e,e._dndHandle||(e.dataTransfer.types&&e.dataTransfer.types.length||e.preventDefault(),e.stopPropagation())}),n.on("dragend",function(e){e=e.originalEvent||e,e._dndHandle||e.stopPropagation()})}}),e.directive("dndHandle",function(){return function(e,n,a){n.attr("draggable","true"),n.on("dragstart dragend",function(e){e=e.originalEvent||e,e._dndHandle=!0})}}) | ||
var o={}}(angular.module("dndLists",[])) |