angular.module("ngDraggable",[]).directive("ngDrag",["$rootScope","$parse",function(a,b){return{restrict:"A",link:function(e,i,v){e.value=v.ngDrag;var m,h,f,q,p;var c=("ontouchstart" in document.documentElement);var g="touchstart mousedown";var A="touchmove mousemove";var F="touchend mouseup";var E=$(document);var s=$(window);var t=null;var o=false;var C=null;var k=b(v.ngDragSuccess)||null;var d=function(){i.attr("draggable","false");z(true)};var z=function(H){if(!H){return}e.$on("$destroy",l);v.$observe("ngDrag",r);e.$watch(v.ngDragData,n);i.on(g,G);if(!c){i.on("mousedown",function(){return false})}};var l=function(H){z(false)};var n=function(I,H){t=I};var r=function(I,H){o=e.$eval(I)};var G=function(H){if(!o){return}if(c){y();C=setTimeout(function(){y();B(H)},100);E.on(A,y);E.on(F,y)}else{B(H)}};var y=function(){clearTimeout(C);E.off(A,y);E.off(F,y)};var B=function(H){if(!o){return}H.preventDefault();m=i.offset();i.centerX=(i.width()/2);i.centerY=(i.height()/2);i.addClass("dragging");h=(H.pageX||H.originalEvent.touches[0].pageX);f=(H.pageY||H.originalEvent.touches[0].pageY);q=h-i.centerX-s.scrollLeft();p=f-i.centerY-s.scrollTop();w(q,p);E.on(A,j);E.on(F,u);a.$broadcast("draggable:start",{x:h,y:f,tx:q,ty:p,element:i,data:t})};var j=function(H){if(!o){return}H.preventDefault();h=(H.pageX||H.originalEvent.touches[0].pageX);f=(H.pageY||H.originalEvent.touches[0].pageY);q=h-i.centerX-s.scrollLeft();p=f-i.centerY-s.scrollTop();w(q,p);a.$broadcast("draggable:move",{x:h,y:f,tx:q,ty:p,element:i,data:t})};var u=function(H){if(!o){return}H.preventDefault();a.$broadcast("draggable:end",{x:h,y:f,tx:q,ty:p,element:i,data:t,callback:x});i.removeClass("dragging");D();E.off(A,j);E.off(F,u)};var x=function(H){if(!k){return}e.$apply(function(){k(e,{$data:t,$event:H})})};var D=function(){i.css({left:"",top:"",position:"","z-index":""})};var w=function(H,I){i.css({left:H,top:I,position:"fixed","z-index":99999})};d()}}}]).directive("ngDrop",["$parse","$timeout",function(b,a){return{restrict:"A",link:function(q,k,o){q.value=o.ngDrop;var p=false;var c=b(o.ngDropSuccess);var l=function(){i(true)};var i=function(r){if(!r){return}o.$observe("ngDrop",j);q.$on("$destroy",n);q.$on("draggable:start",f);q.$on("draggable:move",e);q.$on("draggable:end",g)};var n=function(r){i(false)};var j=function(s,r){p=q.$eval(s)};var f=function(r,s){if(!p){return}h(s.x,s.y,s.element)};var e=function(r,s){if(!p){return}h(s.x,s.y,s.element)};var g=function(r,s){if(!p){return}if(h(s.x,s.y,s.element)){if(s.callback){s.callback(r)}a(function(){c(q,{$data:s.data,$event:r})})}d(false,s.element)};var h=function(u,t,s){var r=m(u,t);d(r,s);return r};var d=function(r,s){if(r){k.addClass("drag-enter");s.addClass("drag-over")}else{k.removeClass("drag-enter");s.removeClass("drag-over")}};var m=function(r,t){var s=k.offset();s.right=s.left+k.outerWidth();s.bottom=s.top+k.outerHeight();return r>=s.left&&r<=s.right&&t<=s.bottom&&t>=s.top};l()}}}]).directive("ngDragClone",["$parse","$timeout",function(b,a){return{restrict:"A",link:function(o,i,n){var j;o.clonedData={};var k=function(){j=$(i.find("img"));i.attr("draggable","false");j.attr("draggable","false");l();h(true)};var h=function(p){if(!p){return}o.$on("draggable:start",f);o.$on("draggable:move",e);o.$on("draggable:end",g);m()};var m=function(){j.off("mousedown touchstart touchmove touchend touchcancel",c);j.on("mousedown touchstart touchmove touchend touchcancel",c)};var f=function(p,q){o.$apply(function(){o.clonedData=q.data});i.css("width",q.element.height());i.css("height",q.element.height());d(q.tx,q.ty)};var e=function(p,q){d(q.tx,q.ty)};var g=function(p,q){l()};var l=function(){i.css({left:0,top:0,position:"fixed","z-index":-1,visibility:"hidden"})};var d=function(p,q){i.css({left:p,top:q,position:"fixed","z-index":99999,visibility:"visible"})};var c=function(p){var q=p.originalEvent;q.preventDefault&&q.preventDefault();q.stopPropagation&&q.stopPropagation();q.cancelBubble=true;q.returnValue=false;return false};k()}}}]).directive("ngPreventDrag",["$parse","$timeout",function(b,a){return{restrict:"A",link:function(f,e,d){var c=function(){e.attr("draggable","false");g(true)};var g=function(i){if(!i){return}e.on("mousedown touchstart touchmove touchend touchcancel",h)};var h=function(i){var j=i.originalEvent;j.preventDefault&&j.preventDefault();j.stopPropagation&&j.stopPropagation();j.cancelBubble=true;j.returnValue=false;return false};c()}}}]);