EnVisageOnline/Main/Source/EnVisage/Scripts/Angular/angular-dnd.min.js

9 lines
42 KiB
JavaScript

(function(n,t,i,r){
/**
* @license AngularJS-DND v0.1.13
* (c) 2014-2015 Alexander Afonin (toafonin@gmail.com, http://github.com/Tuch)
* License: MIT
*/
function o(){}function d(){return!1}function ut(){return!0}function a(n,t){return function(){t.apply(n,arguments)}}function tt(n){return n*(Math.PI/180)}function it(n){return n*(180/Math.PI)}function p(n,t,i){return t<n?n:t>i?i:t}function ft(n){var i=n.data("events");return i!==t?i:(i=f.data(n,"events"),i!==t)?i:(i=f._data(n,"events"),i!==t)?i:(i=f._data(n[0],"events"),i!==t)?i:t}function g(n,t,i,r){arguments.length===3&&typeof i!="boolean"&&(r=i,i=!1);var u;return function(){var f=arguments;r=r||this;i&&!u&&n.apply(r,f);clearTimeout(u);u=setTimeout(function(){i||n.apply(r,f);u=null},t)}}function nt(n,t,i){var r,u;return function(){r||(u=arguments,i=i||this,n.apply(i,u),r=setTimeout(function(){r=null},t))}}function s(n,t){isNaN(t)&&(t=0);var i=Math.pow(10,t);return Math.round(n*i)/i}var e;"use strict";var f=n.element,et=f(i),h=f(r),c,w,y,v={mode:!1,helpers:{}},b=n.forEach,l=n.extend;(function(){i.console=i.console||{log:o,info:o,warn:o,error:o}})(),function(){var n=navigator.userAgent;/webkit\//i.test(n)?(c="-webkit-transform",w="-webkit-transform-origin",y="webkitMatchesSelector"):/gecko\//i.test(n)?(c="-moz-transform",w="-moz-transform-origin",y="mozMatchesSelector"):/trident\//i.test(n)?(c="-ms-transform",w="ms-transform-origin",y="msMatchesSelector"):/presto\//i.test(n)?(c="-o-transform",w="-o-transform-origin",y="oMatchesSelector"):(c="transform",w="transform-origin",y="matches")}();var u=function(){function n(n,t){typeof n=="object"&&(t=n.y||n.top,n=n.x||n.left);this.x=n||0;this.y=t||0}return n.prototype={equal:function(t){return t instanceof n||(t=new n(t)),this.x===t.x&&this.y===t.y},plus:function(t){return t instanceof n||(t=new n(t)),new n(this.x+t.x,this.y+t.y)},minus:function(t){return t instanceof n||(t=new n(t)),new n(this.x-t.x,this.y-t.y)},scale:function(t){return new n(this.x*t,this.y*t)},magnitude:function(){return this.distance(new n(0,0),this)},distance:function(t){return t instanceof n||(t=new n(t)),Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},angle:function(n,t){var i=Math.atan2(n.y-this.y,n.x-this.x);return t===!0&&(i*=180/Math.PI),i},deltaAngle:function(n,i,r){i=i===t?{x:0,y:0}:i;var u=this.angle(i)-n.angle(i);return u<0&&(u=Math.PI*2+u),r===!0&&(u*=180/Math.PI),u},transform:function(n){return n.transformPoint(this)},deltaTransform:function(n){return n.deltaTransformPoint(this)},rotate:function(n,t){var i=(new k).rotate(n,t);return this.transform(i)},getAsCss:function(){return{top:this.y,left:this.x}}},function(t,i){return new n(t,i)}}(),k=function(){function n(n,i,r,u,f,e){this.a=n!==t?n:1;this.b=i||0;this.c=r||0;this.d=u!==t?u:1;this.tx=f||0;this.ty=e||0}n.prototype={concat:function(t){return new n(this.a*t.a+this.c*t.b,this.b*t.a+this.d*t.b,this.a*t.c+this.c*t.d,this.b*t.c+this.d*t.d,this.a*t.tx+this.c*t.ty+this.tx,this.b*t.tx+this.d*t.ty+this.ty)},inverse:function(){var t=this.a*this.d-this.b*this.c;return new n(this.d/t,-this.b/t,-this.c/t,this.a/t,(this.c*this.ty-this.d*this.tx)/t,(this.b*this.tx-this.a*this.ty)/t)},rotate:function(t,i){var r=new n(Math.cos(t),Math.sin(t),-Math.sin(t),Math.cos(t));return i&&(r=this.translate(i.x,i.y).concat(r).translate(-i.x,-i.y)),this.concat(r)},scale:function(t,i,r){i=i||t;var u=new n(t,0,0,i);return r&&(u=u.translate(r.x,r.y).translate(-r.x,-r.y)),u},translate:function(t,i){var r=new n(1,0,0,1,t,i);return this.concat(r)},transformPoint:function(n){return new u(this.a*n.x+this.c*n.y+this.tx,this.b*n.x+this.d*n.y+this.ty)},deltaTransformPoint:function(n){return new u(this.a*n.x+this.c*n.y,this.b*n.x+this.d*n.y)},toStyle:function(){var n=s(this.a,3),t=s(this.b,3),i=s(this.c,3),r=s(this.d,3),u=s(this.tx,3),f=s(this.ty,3);return"matrix("+n+", "+t+", "+i+", "+r+", "+u+", "+f+")"}};var i=function(t,i,r,u,f,e){return new n(t,i,r,u,f,e)};return i.IDENTITY=new n,i.HORIZONTAL_FLIP=new n(-1,0,0,1),i.VERTICAL_FLIP=new n(1,0,0,-1),i}(),rt=function(){function n(n,t,i,r){this.tl=n;this.tr=t;this.bl=i;this.br=r}n.prototype={applyMatrix:function(i,r){var e,o,s,h,u=new k(1,0,0,1,r.x,r.y),f=new k(1,0,0,1,-r.x,-r.y);return r!==t?(e=this.tl.transform(f).transform(i).transform(u),o=this.tr.transform(f).transform(i).transform(u),s=this.bl.transform(f).transform(i).transform(u),h=this.br.transform(f).transform(i).transform(u)):(e=this.tl.transform(i),o=this.tr.transform(i),s=this.bl.transform(i),h=this.br.transform(i)),new n(e,o,s,h)},width:function(){var n=this.tl.x-this.tr.x,t=this.tl.y-this.tr.y;return Math.sqrt(n*n+t*t)},height:function(){var n=this.tl.x-this.bl.x,t=this.tl.y-this.bl.y;return Math.sqrt(n*n+t*t)},client:function(){var n=Math.min(this.tl.y,this.tr.y,this.bl.y,this.br.y),t=Math.min(this.tl.x,this.tr.x,this.bl.x,this.br.x),i=Math.max(this.tl.y,this.tr.y,this.bl.y,this.br.y)-n,r=Math.max(this.tl.x,this.tr.x,this.bl.x,this.br.x)-t;return{top:s(n,1),left:s(t,1),height:s(i,1),width:s(r,1),bottom:s(n+i,1),right:s(t+r,1)}},getAngle:function(){var n=this.tl.y-this.tr.y,t=this.tl.x-this.tr.x;return Math.tan(t/n)*180/Math.PI}};var i=function(t,i,r,f){var e=arguments;return typeof e[0]=="object"&&(i=e[0].top,t=e[0].left,r=e[0].width,f=e[0].height),new n(new u(t,i),new u(t+r,i),new u(t,i+f),new u(t+r,i+f))};return i.fromPoints=function(t,i,r,u){return new n(t,i,r,u)},i}();l(f.prototype,{dndDisableSelection:function(){this.on("dragstart selectstart",d).dndCss({"-moz-user-select":"none","-khtml-user-select":"none","-webkit-user-select":"none","-o-user-select":"none","-ms-user-select":"none","user-select":"none"})},dndEnableSelection:function(){this.off("dragstart selectstart",d).dndCss({"-moz-user-select":"auto","-khtml-user-select":"auto","-webkit-user-select":"auto","-o-user-select":"auto","-ms-user-select":"auto","user-select":"auto"})},dndClientRect:function(){if(this[0]){var n=this[0]===i?{top:0,bottom:0,left:0,right:0,width:0,height:0}:this[0].getBoundingClientRect();return{bottom:n.bottom,height:n.height,left:n.left,right:n.right,top:n.top,width:n.width}}},dndStyleRect:function(){var n=this.dndCss(["width","height","top","left"]),t=parseFloat(n.width),i=parseFloat(n.height),r=n.top==="auto"?0:parseFloat(n.top),u=n.left==="auto"?0:parseFloat(n.left);return{top:r,right:u+t,bottom:r+i,left:u,width:t,height:i}},dndGetParentScrollArea:function(){var t=[],l=this.dndClosest(),u,e,o,s,h,c,n,a=r.documentElement;return b(l,function(i){n=f(i).dndCss(["padding-top","padding-right","padding-bottom","padding-left"]);u=i.scrollWidth;e=i.clientWidth;o=i.scrollHeight;s=i.clientHeight;c=parseFloat(n["padding-top"])+parseFloat(n["padding-bottom"]);h=parseFloat(n["padding-left"])+parseFloat(n["padding-right"]);(u-h!==e||o-c!==s)&&t.push(i)}),t.push(i),f(t)},dndGetFirstNotStaticParent:function(){var n,t,i=this.dndClosest();return b(i,function(i){return t=f(i).dndCss("position"),t==="absolute"||t==="relative"||t==="fixed"?(n=i,!1):void 0}),n||(n=r.documentElement),f(n)},dndClosest:function(n){n=n||"*";for(var t=this[0],i=[];t;)t[y](n)&&i.push(t),t=t.parentElement;return f(i)},dndGetAngle:function(n){var i=this.dndCss(c);if(i==="none"||i==="")return 0;var r=i.split("(")[1].split(")")[0].split(","),u=r[0],f=r[1],t=Math.atan2(f,u);return t=t<0?t+=Math.PI*2:t,n?Math.round(t*180/Math.PI):t},dndCloneByStyles:function(){for(var r,u=[],t=0,f=this.length;t<f;t++)r=this[t].cloneNode(),n.element(r).append(n.element(this[0].childNodes).dndCloneByStyles()),this[t].nodeType===1&&(r.style.cssText=i.getComputedStyle(this[t],"").cssText),u.push(r);return n.element(u)},dndCss:function(){function e(n){return n.replace(u,function(n,t,i,r){return r?i.toUpperCase():i}).replace(f,"Moz$1")}function h(){var n=arguments,t;return n.length===1&&(n[0]instanceof Array||typeof n[0]=="string")?s(this,n[0]):n.length===1&&typeof n[0]=="object"?r(this,n[0]):n.length===2?(t={},t[n[0]]=n[1],r(this,t)):this}var u=/([\:\-\_\.]+(.))/g,f=/^moz([A-Z])/,n={};(function(){b({width:["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],height:["paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"]},function(t,r){n[r]={get:function(n){var e=i.getComputedStyle(n),u=e[r],f;if(e.boxSizing!=="border-box"||u[u.length-1]==="%")return u;for(u=parseFloat(u),f=0;f<t.length;f++)u-=parseFloat(e[t[f]]);return u+"px"}}})})();var o={columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},r=function(n,t){var u={},i,r;for(i in t)r=t[i],typeof r!="number"||o[i]||(r+="px"),u[e(i)]=r;return n.css(u),n},s=function(r,u){var s={},e,o,f;if(!r[0])return t;if(e=r[0].style,o=i.getComputedStyle(r[0],null),typeof u=="string")return e[u]?e[u]:n[u]&&"get"in n[u]?n[u].get(r[0]):o.getPropertyValue(u);for(f=0;f<u.length;f++)s[u[f]]=e[u[f]]?e[u[f]]:n[u[f]]&&"get"in n[u[f]]?n[u[f]].get(r[0]):o.getPropertyValue(u[f]);return s};return h}()});e=n.module("dnd",[]),function(){function o(n){this.dnd=n;this.manipulator=new e(n);this.mousedown=a(this,this.mousedown);this.mousemove=a(this,this.mousemove);this.mouseup=a(this,this.mouseup);this.manipulator.getClientAxis=this.getClientAxis;n.$el.on("mousedown",this.mousedown)}function s(n,t){this.dnd=n;this.te=t;this.manipulator=new e(n);this.touchstart=a(this,this.touchstart);this.touchmove=a(this,this.touchmove);this.touchend=a(this,this.touchend);this.manipulator.getClientAxis=this.getClientAxis;n.$el.on(this.te.start,this.touchstart)}var c=function(){function t(t){n[t]||(n[t]=[]);this.layer=function(){return t}}var n={};return t.prototype={get:function(){return n[this.layer()]},remove:function(n){var t=this.get().indexOf(n);t>-1&&this.get().splice(t,1)},has:function(n){return this.get().indexOf(n)>-1},add:function(n){if(!this.has(n)){this.get().push(n);var t=this;f(n).on("$destroy",function(){t.remove(n)})}}},t}(),l=function(){function e(n,t){this.el=n;this.$el=f(n);this.listeners={dragstart:[],drag:[],dragend:[],dragenter:[],dragover:[],dragleave:[],drop:[]};this.regions=new c(t);this.layer=function(){return t};this.setCurrentManipulator(null)}var h=["dragstart","drag","dragend","dragenter","dragover","dragleave","drop"],n=["dragstart","drag","dragend"],t=["dragenter","dragover","dragleave","drop"],u;return n.has=t.has=function(n){return this.indexOf(n)>-1},u="ontouchstart"in r.documentElement?{start:"touchstart",move:"touchmove",end:"touchend",cancel:"touchcancel"}:"pointerEnabled"in i.navigator?{start:"pointerdown",move:"pointermove",end:"pointerup",cancel:"pointercancel"}:"msPointerEnabled"in i.navigator?{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp",cancel:"MSPointerCancel"}:{start:"touchstart",move:"touchmove",end:"touchend",cancel:"touchcancel"},e.prototype={_isEmptyListeners:function(n){if(n instanceof Array){for(var t=0;t<n.length;t++)if(!this._isEmptyListeners(n[t]))return!1}else if(this.listeners[n].length>0)return!1;return!0},addListener:function(r,f){return h.indexOf(r)===-1?(console.error("jquery.dnd: invalid event name - ",r),this):(this.listeners[r].push(f),t.has(r)?this.regions.add(this.el):!n.has(r)||this.mouse||this.touch||("onmousedown"in i&&(this.mouse=new o(this)),("ontouchstart"in i||"onmsgesturechange"in i)&&(this.touch=new s(this,u))),this)},removeListener:function(i,r){var e=arguments,o,f,u;if(e.length===0)for(o in this.listeners)this.listeners[o].length=0;else if(e.length===1)this.listeners[i].length=0;else for(f=this.listeners[i],u=0;u<f.length;u++)f[u]===r&&f[i].splice(u,1);return this._isEmptyListeners(t)?this.regions.remove(this.el):this._isEmptyListeners(n)&&this.destroy(),this},trigger:function(n,t,i){for(var r=0;r<this.listeners[n].length;r++)this.listeners[n][r].call(this.$el,t,i);return this},destroy:function(){return this.mouse&&(this.mouse.destroy(),delete this.mouse),this.touch&&(this.touch.destroy(),delete this.touch),this},setCurrentManipulator:function(n){return this._manipulator=n,this},getCurrentManipulator:function(){return this._manipulator}},e}(),y=function(){function t(n){this._manipulator=n}return t.prototype={getAxis:function(){return this._manipulator.getClientAxis.apply(this._manipulator,arguments)},getBorderedAxis:function(){return this._manipulator.getBorderedAxis.apply(this._manipulator,arguments)},getRelBorderedAxis:function(){return this._manipulator.getRelBorderedAxis.apply(this._manipulator,arguments)},getDragTarget:function(){return this._manipulator.dnd.el},getDropTarget:function(){return this._manipulator.target},getEvent:function(){return this._manipulator.event},isTarget:function(){return this._manipulator.isTarget.apply(this._manipulator,arguments)},unTarget:function(){this._manipulator.removeFromTargets()},useAsPoint:function(n){return this._manipulator.asPoint=n===!1?!1:!0},setBounderElement:function(t){this._manipulator.$bounder=n.element(t);this.clearCache()},setReferenceElement:function(t){this._manipulator.$reference=n.element(t)},getBorders:function(){return this._manipulator.getBorders.apply(this._manipulator,arguments)},getReferencePoint:function(){return this._manipulator.getReferencePoint.apply(this._manipulator,arguments)},clearCache:function(){this._manipulator.clearCache.apply(this._manipulator,arguments)}},t}(),e=function(){function i(n){this.dnd=n;this.onscroll=a(this,this.onscroll)}var t=[];return i.prototype={getBorders:function(n){var t,i;if(this.$bounder)return t=this.getCache("borders"),t||(i=this.$bounder.dndClientRect(),t=this.setCache("borders",{top:i.top,left:i.left,right:i.right,bottom:i.bottom})),{top:t.top+(n?n.top:0),left:t.left+(n?n.left:0),right:t.right+(n?n.right:0),bottom:t.bottom+(n?n.bottom:0)}},getReferencePoint:function(){var n=this.getCache("referencePoint"),t;return n||(t=this.$reference.dndClientRect(),n=this.setCache("referencePoint",new u(t.left,t.top))),n},getBorderedAxis:function(n,t){var r=this.getClientAxis(t),i=this.getBorders(n);return i?new u(p(i.left,r.x,i.right),p(i.top,r.y,i.bottom)):r},getRelBorderedAxis:function(n,t){return this.getBorderedAxis(n,t).minus(this.getReferencePoint())},addToTargets:function(){t.push(this)},removeFromTargets:function(){for(var n;n!==-1;)n=t.indexOf(this),n>-1&&t.splice(n,1)},getTarget:function(){return t[0]},isTarget:function(){return this.getTarget()===this},start:function(){this.started=!0;this.targets=[];this.asPoint=!1;this.api=new y(this);this.$scrollareas=this.dnd.$el.dndGetParentScrollArea();this.$reference=this.dnd.$el.dndGetFirstNotStaticParent();this.$scrollareas.on("scroll",this.onscroll);this.dnd.trigger("dragstart",this.api)},onscroll:function(){this.clearCache();this.dnd.trigger("drag",this.api)},getCache:function(n){return this.cache[n]},setCache:function(n,t){return this.cache[n]=t},clearCache:function(){this.cache={}},stop:function(){if(this.$scrollareas.off("scroll",this.onscroll),this.targets.length)for(var n=0,t=this.targets.length;n<t;n++)f(this.targets[n]).data("dnd")[this.dnd.layer()].trigger("drop",this.api,this.dnd.el);this.dnd.trigger("dragend",this.api,this.targets)},prepareRegions:function(){var t=this.dnd.regions.get(),i=[],r,n,u;for(r in t)(n=f(t[r]).data("dnd")[this.dnd.layer()],u=n.$el.dndClientRect(),this.dnd!==n)&&i.push({dnd:n,rect:u});return i},begin:function(t){return this.dnd.getCurrentManipulator()||f(t.target).dndClosest("[dnd-pointer-none]").length?!1:(this.dnd.setCurrentManipulator(this),this.addToTargets(),this.event=t,this.started=!1,this.clearCache(),n.element(r.body).dndDisableSelection(),!0)},progress:function(n){var i,r;this.event=n;this.started||this.start();i=this.getCache("regions");i||(i=this.setCache("regions",this.prepareRegions()),v.mode&&this.showRegioins());this.dnd.trigger("drag",this.api);var e=this.getBorderedAxis(),o=e.x,s=e.y,k=this.asPoint,h=[],c=[],l=[];for(r=0;r<i.length;r++){var t=i[r],a=t.rect.left,p=a+t.rect.width,y=t.rect.top,w=y+t.rect.height,b=o>a&&o<p&&s>y&&s<w,u=this.targets.indexOf(t.dnd.el);b?u===-1?(this.targets.push(t.dnd.el),h.push(t.dnd)):c.push(t.dnd):u!==-1&&(l.push(f(this.targets[u]).data("dnd")[this.dnd.layer()]),this.targets.splice(u,1))}this._triggerArray(l,"dragleave");this._triggerArray(h,"dragenter");this._triggerArray(c,"dragover")},_triggerArray:function(n,t){for(var i=0;i<n.length;i++)n[i].trigger(t,this.api,this.dnd.el)},end:function(t){this.event=t;this.started&&this.stop();n.element(r.body).dndEnableSelection();this.removeFromTargets();v.mode&&this.hideRegions();this.dnd.setCurrentManipulator(null)},showRegioins:function(){var i,e,t;this.hideRegions();var u=this.getCache("regions"),o=n.element(r.body),f=o.dndClientRect();for(i=0,e=u.length;i<e;i++)t=u[i],v.helpers.renderRect(t.rect.left-f.left,t.rect.top-f.top,t.rect.width,t.rect.height)},hideRegions:function(){for(var t=r.querySelectorAll(".dnd-debug-rect"),n=0,i=t.length;n<i;n++)t[n].remove()}},i}();o.prototype={getClientAxis:function(n){return new u(this.event.clientX+(n?n.x:0),this.event.clientY+(n?n.y:0))},mousedown:function(n){if(this.manipulator.begin(n)){h.on("mousemove",this.mousemove);h.on("mouseup",this.mouseup)}},mousemove:function(n){this.manipulator.progress(n)},mouseup:function(n){this.manipulator.end(n);h.off("mousemove",this.mousemove);h.off("mouseup",this.mouseup);this.dnd.setCurrentManipulator(null)},destroy:function(){this.dnd.$el.off("mousedown",this.mousedown)}};s.prototype={getClientAxis:function(n){var t=this.event.originalEvent||this.event;return t.changedTouches?u(t.changedTouches[0].clientX+(n?n.x:0),t.changedTouches[0].clientY+(n?n.y:0)):u(t.clientX+(n?n.x:0),t.clientY+(n?n.y:0))},touchstart:function(n){if(this.manipulator.begin(n)){h.on(this.te.move,this.touchmove);h.on(this.te.end+" "+this.te.cancel,this.touchend)}},touchmove:function(n){n.preventDefault();this.manipulator.progress(n)},touchend:function(n){this.manipulator.end(n);h.off(this.te.move,this.touchmove);h.off(this.te.end+" "+this.te.cancel,this.touchend);this.dnd.setCurrentManipulator(null)},destroy:function(){this.dnd.$el.off(this.te.start,this.touchstart)}};f.prototype.dndBind=function(n,i){var u,e,s,o,c,h,r;if(!this.length)return this;if(u=[],c=this,typeof n=="object"){s=n;for(h in s)for(e=h.replace(/\s+/g," ").split(" "),r=0;r<e.length;r++)u.push({event:e[r],handler:s[h]})}else if(typeof n=="string"&&typeof i=="function")for(e=n.trim().replace(/\s+/g," ").split(" "),r=0;r<e.length;r++)u.push({event:e[r],handler:i});else return this;return u.length?(b(this,function(r){var e=f(r).data(),s;for(e.dnd||(e.dnd={}),s=0;s<u.length;s++)n=u[s].event,i=u[s].handler,n=n.split("."),n[1]===t&&(n[1]=n[0],n[0]="common"),o=n[0],n=n[1],e.dnd[o]||(e.dnd[o]=new l(r,o)),e.dnd[o].addListener(n,i)}),this):this};f.prototype.dndUnbind=function(){var n=arguments,r=[],e="common",i,u;if(!this.length)return this;if(typeof n[0]=="string")if(n[0]=n[0].trim().replace(/\s+/g," ").split(" "),typeof n[1]=="function")for(i=0;i<n[0].length;i++)r.push({event:n[0][i],handler:n[1]});else for(i=0;i<n[0].length;i++)r.push({event:n[0][i]});else if(typeof n[0]=="object")for(u in n[0])n[0].hasOwnProperty(u)&&r.push({event:u.trim(),handler:n[0][u]});else if(n.length!==0)return this;return b(this,function(i){var o=f(i).data(),h,u,s;if(o.dnd)if(n.length===0)for(s in o.dnd)o.dnd[s].removeListener();else for(h=0;h<r.length;h++)if(u=r[h],u.event=u.event.split("."),u.event[1]===t&&(u.event[1]=u.event[0],u.event[0]=e),u.event[0]==="*")for(s in o.dnd)o.dnd[s].removeListener(u.event[1]);else o.dnd[u.event[0]]&&(u.handler?o.dnd[u.event[0]].removeListener(u.event[1],u.handler):o.dnd[u.event[0]].removeListener(u.event[1]))}),this}}();v.helpers.renderPoint=function(t){var i=n.element(r.createElement("div"));i.dndCss({position:"absolute",left:t.x,top:t.y,height:3,width:3,background:"rgba(0, 0, 0, 0.5)","pointer-events":"none","z-index":1e5});i.addClass("dnd-debug-point");n.element(r.body).append(i)};v.helpers.renderRect=function(t,i,u,f){var e=n.element(r.createElement("div"));e.dndCss({position:"absolute",left:t,top:i,height:f,width:u,background:"rgba(249, 255, 0, 0.1)","pointer-events":"none","z-index":1e5,"box-sizing":"border-box",border:"2px dotted #000"});e.addClass("dnd-debug-rect");n.element(r.body).append(e)};n.dnd={version:"0.1.13",noop:o,doTrue:ut,doFalse:d,proxy:a,radToDeg:it,degToRad:tt,getNumFromSegment:p,findEvents:ft,throttle:nt,debounce:g,debug:v};e.directive("dndDraggable",["$timeout","$parse","$http","$compile","$q","$templateCache","EventEmitter",function(i,e,o,s,h,c){function p(u,f,o,s){function ut(i){c=!1;var f=nt(u);(f=f===t||f,(!f||d&&d!==i.getEvent().target)&&i.unTarget(),i.isTarget())&&(p.init(i),c=!0,i.useAsPoint(h.useAsPoint),i.dragmodel=w?w.get():null,i.setBounderElement(b?b.get():n.element(r.body)),u.$dragged=!0,tt(u,{$dragmodel:i.dragmodel,$dropmodel:i.dropmodel,$api:i}),u.$apply())}function ft(n){c&&(p.updatePosition(),it(u,{$dragmodel:n.dragmodel,$dropmodel:n.dropmodel,$api:n}),u.$apply())}function et(n){c&&(p.destroy(),rt(u,{$dragmodel:n.dragmodel,$dropmodel:n.dropmodel,$api:n}),i(function(){u.$dragged=!1}))}var g=s[0],w=s[1],b=s[2],k={layer:"common",useAsPoint:!1,helper:null,handle:""},nt=e(o.dndDraggable),h=l({},k,e(o.dndDraggableOpts)(u)||{}),tt=e(o.dndOnDragstart),it=e(o.dndOnDrag),rt=e(o.dndOnDragend),p=h.helper?new y(f,h.helper,u):new a(f,g),c,d=h.handle?f[0].querySelector(h.handle):"",v={};h.layer=h.layer||k.layer;v[h.layer+".dragstart"]=ut;v[h.layer+".drag"]=ft;v[h.layer+".dragend"]=et;f.dndBind(v);u.$dragged=!1}var a=function(){function n(n,t){var i=n.dndCss("position");i!=="fixed"&&i!=="absolute"&&i!=="relative"&&(i="relative",n.dndCss("position",i));this.element=n;this.rect=t}return n.prototype={initBorderOffset:function(){var t=this.api.getBorderedAxis(),n=this.element.dndClientRect();this.borderOffset={top:t.y-n.top,left:t.x-n.left,bottom:t.y-n.top-n.height,right:t.x-n.left-n.width}},init:function(n){this.api=n;delete this.start;this.initBorderOffset()},updatePosition:function(){var t=this.api.getRelBorderedAxis(this.borderOffset),n;this.start||(this.start=new u(this.element.dndStyleRect()).minus(t));n=new u(this.start).plus(t);this.rect?this.rect.update(n.getAsCss()):this.element.dndCss(n.getAsCss())},destroy:function(){}},n}(),y=function(){function i(t,i,r){this.mainElement=n.element(t);this.scope=r;this.templateUrl=i;i!=="clone"?this.createTemplateByUrl(i):this.ready=!0}var t=f('<div class = "angular-dnd-draggable-helper"><\/div>').dndCss({position:"absolute"});return i.prototype={init:function(n){return delete this.start,delete this.element,this.api=n,this.ready=!1,this.templateUrl==="clone"?this.createElementByClone():this.createElementByTemplate(),this.wrap().appendTo(f(r.body)),this.scope.$apply(),n.setReferenceElement(r.body),this.initBorderOffset(),this},createTemplateByUrl:function(t){return t=n.isFunction(t)?t():t,o.get(t,{cache:c}).then(function(n){this.template=n.data;this._offset=u();this.ready=!0}.bind(this))},createElementByClone:function(){return this.element=this.mainElement.dndCloneByStyles().dndCss("position","static"),this._offset=u(this.mainElement.dndClientRect()).minus(this.api.getBorderedAxis()),this.ready=!0,this},createElementByTemplate:function(){return this.element=s(this.template)(this.scope),this},wrap:function(){return t.html(""),t.append(this.element),this},appendTo:function(n){return n.append(t),this},initBorderOffset:function(){var i=this.api.getBorderedAxis(),n;this.templateUrl==="clone"?(n=this.mainElement.dndClientRect(),this.borderOffset={top:i.y-n.top,left:i.x-n.left,bottom:i.y-n.top-n.height,right:i.x-n.left-n.width}):(n=t.dndClientRect(),this.borderOffset={top:0,left:0,bottom:-n.height,right:-n.width})},updatePosition:function(){var n=this.api.getRelBorderedAxis(this.borderOffset).plus(this._offset);v.mode&&console.log(this.api.getRelBorderedAxis());t.dndCss(n.getAsCss())},destroy:function(){this.element.remove()}},i}();return{require:["?dndRect","?dndModel","?dndContainment"],scope:!0,link:p}}]);e.directive("dndDroppable",["$parse","$timeout",function(n){return{require:"?dndModel",scope:!0,link:function(i,r,u,f){function p(n){var r=n.droplocal={};(n.dropmodel=f?f.get():f,r.droppable=h(i,{$dragmodel:n.dragmodel,$dropmodel:n.dropmodel,$api:n}),r.droppable=r.droppable===t?!0:r.droppable,r.droppable)&&(c(i,{$dragmodel:n.dragmodel,$dropmodel:n.dropmodel,$api:n}),i.$apply())}function w(n){var t=n.droplocal;t.droppable&&(a(i,{$dragmodel:n.dragmodel,$dropmodel:n.dropmodel,$api:n}),i.$apply())}function b(n){var r=n.droplocal;r.droppable&&(v(i,{$dragmodel:n.dragmodel,$dropmodel:n.dropmodel,$api:n}),n.dropmodel=t,i.$apply())}function k(n){y(i,{$dragmodel:n.dragmodel,$dropmodel:n.dropmodel,$api:n})}var s={layer:"common"},h=n(u.dndDroppable),e=l({},s,n(u.dndDroppableOpts)(i)||{}),c=n(u.dndOnDragenter),a=n(u.dndOnDragover),v=n(u.dndOnDragleave),y=n(u.dndOnDrop),o={};e.layer=e.layer||s.layer;o[e.layer+".dragenter"]=p;o[e.layer+".dragover"]=w;o[e.layer+".dragleave"]=b;o[e.layer+".drop"]=k;r.dndBind(o)}}}]);e.directive("dndRotatable",["$parse","$timeout",function(i,f){function e(e,o,s,h){function ut(i){var f=i.local={},s;(f.rotatable=b(e),f.rotatable=f.rotatable===t?!0:f.rotatable,f.rotatable||i.unTarget(),i.isTarget())&&(f.started=!0,i.setBounderElement(y?y.get():n.element(r.body)),s=i.getRelBorderedAxis(),f.srect=o.dndStyleRect(),f.currAngle=o.dndGetAngle(),f.startPoint=u(s),f.borders=i.getBorders(),f.center=u(f.srect).plus(u(f.srect.width/2,f.srect.height/2)),e.$rotated=!0,d(e),e.$apply())}function ft(n){var t=n.local;if(t.started){var h=n.getRelBorderedAxis(),c=u(h).deltaAngle(t.startPoint,t.center),f=it(t.currAngle+c);f=Math.round(f/p.step)*p.step;var l=tt(f),s=k().rotate(l),i=rt(t.center.x-t.srect.width/2,t.center.y-t.srect.height/2,t.srect.width,t.srect.height).applyMatrix(s,t.center).client(),r=n.getReferencePoint();t.borders&&(i.left+r.x<t.borders.left-1||i.top+r.y<t.borders.top-1||i.left+r.x+i.width>t.borders.right+1||i.top+r.y+i.height>t.borders.bottom+1)||(v?v.update("transform",s.toStyle()):o.dndCss("transform",s.toStyle()),g(e),e.$apply())}}function et(n){var t=n.local;t.started&&(nt(e),f(function(){e.$rotated=!1}))}var v=h[0],y=h[1],b=i(s.dndRotatable),p=l({},{step:5},i(s.dndRotatableOpts)(e)||{}),d=i(s.dndOnRotatestart),g=i(s.dndOnRotate),nt=i(s.dndOnRotateend),c=o.dndCss("position"),a,w;c!="fixed"&&c!="absolute"&&c!="relative"&&(c="relative",o.dndCss("position",c));a=n.element('<div class = "angular-dnd-rotatable-handle"><\/div>');o.append(a);e.$rotated=!1;w={"$$rotatable.dragstart":ut,"$$rotatable.drag":ft,"$$rotatable.dragend":et};a.dndBind(w)}return{require:["?dndRect","?dndContainment"],scope:!0,link:e}}]);e.directive("dndResizable",["$parse","$timeout",function(i,f){function o(t){return n.element("<div><\/div>").addClass("angular-dnd-resizable-handle angular-dnd-resizable-handle-"+t)}function e(n,t){return t=typeof t=="object"?t:{x:1,y:1},new u(n.left+n.width*t.x/2,n.top+n.height*t.y/2)}function s(s,h,c,a){function ft(i){function o(i){var u=i.local={};if(u.resizable=nt(s),u.resizable=u.resizable===t?!0:u.resizable,u.resizable||i.unTarget(),i.isTarget()){i.setBounderElement(g?g.get():n.element(r.body));u.started=!0;u.$parent=h.parent();u.rads=h.dndGetAngle();u.rotateMatrix=k.IDENTITY.rotate(u.rads);u.inverseRotateMatrix=u.rotateMatrix.inverse();u.parentRect=u.$parent.dndClientRect();var o=i.getBorderedAxis(),e=h.dndClientRect(),f=u.rect=h.dndStyleRect();u.borders=i.getBorders();u.startAxis=o;u.minScaleX=v.minWidth/f.width;u.minScaleY=v.minHeight/f.height;u.maxScaleX=v.maxWidth/f.width;u.maxScaleY=v.maxHeight/f.height;u.deltaX=e.left-f.left+e.width/2-f.width/2;u.deltaY=e.top-f.top+e.height/2-f.height/2;s.$resized=!0;tt(s);s.$apply()}}function c(n){var t=n.local,y,w,b,a,g,k;if(t.started){var nt=n.getBorderedAxis(),v=u(nt).minus(t.startAxis).transform(t.inverseRotateMatrix),r={x:1,y:1},f=t.rect.width,o=t.rect.height,c=t.rect.top,l=t.rect.left;switch(i){case"n":r.y=(o-v.y)/o;break;case"e":r.x=(f+v.x)/f;break;case"s":r.y=(o+v.y)/o;break;case"w":r.x=(f-v.x)/f;break;case"ne":r.x=(f+v.x)/f;r.y=(o-v.y)/o;break;case"se":r.x=(f+v.x)/f;r.y=(o+v.y)/o;break;case"sw":r.x=(f-v.x)/f;r.y=(o+v.y)/o;break;case"nw":r.x=(f-v.x)/f;r.y=(o-v.y)/o}r.x=p(t.minScaleX,r.x,t.maxScaleX);r.y=p(t.minScaleY,r.y,t.maxScaleY);w=e(t.rect);b=e(t.rect,r);switch(i){case"n":y=u(l,c+o*r.y).rotate(t.rads,b).minus(u(l,c+o).rotate(t.rads,w));break;case"e":y=u(l,c).rotate(t.rads,b).minus(u(l,c).rotate(t.rads,w));break;case"s":y=u(l,c).rotate(t.rads,b).minus(u(l,c).rotate(t.rads,w));break;case"w":y=u(l+f*r.x,c).rotate(t.rads,b).minus(u(l+f,c).rotate(t.rads,w));break;case"ne":y=u(l,c+o*r.y).rotate(t.rads,b).minus(u(l,c+o).rotate(t.rads,w));break;case"se":y=u(l,c).rotate(t.rads,b).minus(u(l,c).rotate(t.rads,w));break;case"sw":y=u(l+f*r.x,c).rotate(t.rads,b).minus(u(l+f,c).rotate(t.rads,w));break;case"nw":y=u(l+f*r.x,c+o*r.y).rotate(t.rads,b).minus(u(l+f,c+o).rotate(t.rads,w))}(a={},a.width=f*r.x,a.height=o*r.y,a.left=l-y.x,a.top=c-y.y,g=u(a.left+t.deltaX+a.width/2,a.top+t.deltaY+a.height/2),k=rt(a.left+t.deltaX,a.top+t.deltaY,a.width,a.height).applyMatrix(t.rotateMatrix,g).client(),t.borders&&(k.left+1<t.borders.left||k.top+1<t.borders.top||k.right-1>t.borders.right||k.bottom-1>t.borders.bottom))||(d?d.update(a):h.dndCss(a),it(s),s.$apply())}}function l(n){var t=n.local;t.started&&(ut(s),f(function(){s.$resized=!1}))}return{"$$resizable.dragstart":o,"$$resizable.drag":c,"$$resizable.dragend":l}}var d=a[0],g=a[1],nt=i(c.dndResizable),v=l({},{handles:"ne, se, sw, nw, n, e, s, w",minWidth:20,minHeight:20,maxWidth:1e4,maxHeight:1e4},i(c.dndResizableOpts)(s)||{}),tt=i(c.dndOnResizestart),it=i(c.dndOnResize),ut=i(c.dndOnResizeend),y=h.dndCss("position"),b,w;for(y!=="fixed"&&y!=="absolute"&&y!=="relative"&&(y="relative",h.dndCss("position",y)),b=v.handles.replace(/\s/g,"").split(","),w=0;w<b.length;w++)h.append(o(b[w]).dndBind(ft(b[w])));s.$resized=!1}return{require:["?dndRect","?dndContainment"],scope:!0,link:s}}]);e.directive("dndSortable",["$parse","$compile",function(t){function r(n,t,i){return Object.getOwnPropertyNames(n).map(function(i){return[i,n[i]].join(t)}).join(i)}function u(n){return"{"+r(n,":",",")+"}"}function e(n){return r(n,'="','" ')+'"'}function s(i,r){var h=i[0].nodeName.toLowerCase(),l=r.ngRepeat||"",o=l.match(f),s,c;if(!o)throw"dnd-sortable-item requires ng-repeat as dependence";return s=n.extend({layer:"'common'"},t(r.dndSortableOpts)()),c={"ng-transclude":"","dnd-draggable":"","dnd-draggable-opts":u({helper:"'clone'",useAsPoint:!0,layer:s.layer}),"dnd-droppable":"","dnd-droppable-opts":u({layer:s.layer}),"dnd-on-dragstart":"$$onDragStart($api, $dropmodel, $dragmodel)","dnd-on-dragend":"$$onDragEnd($api, $dropmodel, $dragmodel)","dnd-on-dragover":"$$onDragOver($api, $dropmodel, $dragmodel)","dnd-on-drag":"$$onDrag($api, $dropmodel, $dragmodel)","dnd-model":"{item: "+o[1]+", list: "+o[2]+", index: $index}"},"<"+h+" "+e(c)+"><\/"+h+">"}function h(r,u,f){function g(n,t){var i=u.dndClientRect();return(b?(t.x-i.left)/i.width:(t.y-i.top)/i.height)>.5}function nt(n,t,i,r){r=r||t;r.splice(i,0,t.splice(n,1)[0])}var s=u[0].parentNode,c=n.element(s),e=c.data("dnd-sortable"),h=t(f.dndModel)||o,y=u.dndCss(["float","display"]),b=/left|right|inline/.test(y.float+y.display),a=l({},{layer:"common"},t(f.dndSortableOpts)(r)||{}),k=t(f.dndOnSortstart),p=t(f.dndOnSort),w=t(f.dndOnSortchange),d=t(f.dndOnSortend),tt=t(f.dndOnSortenter),it=t(f.dndOnSortleave),v;e&&e[a.layer]||(e=e||{},e[a.layer]=!0,v={},v[a.layer+".dragover"]=function(n){n.getEvent().target!==s||h(r).list.length>1||(n.$sortable.model=h(r),n.$sortable.insertBefore=!0,c.append(i[0]))},c.dndBind(v).data("dnd-sortable",e));r.$$onDragStart=function(n){k(r);i=u.clone();u.addClass("ng-hide");i.addClass("angular-dnd-placeholder");s.insertBefore(i[0],u[0]);n.$sortable={};n.clearCache();r.$apply()};r.$$onDragOver=function(t){var e=g(t.getDragTarget(),t.getBorderedAxis()),f;e?s.insertBefore(i[0],u[0].nextSibling):s.insertBefore(i[0],u[0]);f=h(r);w===n.noop||t.$sortable.model&&t.$sortable.model.index===f.index||(w(r),r.$apply());t.$sortable.model=f;t.$sortable.insertBefore=!e;t.clearCache()};r.$$onDragEnd=function(n){if(u.removeClass("ng-hide"),i.addClass("ng-hide"),n.$sortable.model){var f=r.$index,t=n.$sortable.model.index,e=h(r).list,o=n.$sortable.model.list;o===e?t<f?n.$sortable.insertBefore||t++:n.$sortable.insertBefore&&t--:n.$sortable.insertBefore||t++;nt(f,e,t,o);n.clearCache();d(r);r.$apply()}};p!==n.noop&&(r.$$onDrag=function(){p(r);r.$apply()})}var i,f=/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/;return{scope:!0,transclude:!0,template:s,replace:!0,link:h}}]);e.directive("dndSelectable",["$parse",function(n){function i(i,r,u){var s=n(r.dndModelSelecting),f=s.assign||o,h=n(r.dndModelSelected),e=h.assign||o,c=n(r.dndSelectable),p=c.assign||o,l=n(r.dndOnSelected),a=n(r.dndOnUnselected),v=n(r.dndOnSelecting),y=n(r.dndOnUnselecting);e(i,!1);f(i,!1);this.getElement=function(){return u};this.isSelected=function(){return h(i)};this.isSelecting=function(){return s(i)};this.isSelectable=function(){var n=c(i);return n===t||n};this.toggleSelected=function(n){return n=n===t?!this.isSelected():n,n?this.selected():this.unselected()};this.selecting=function(){return this.isSelectable()&&v(i)!==!1&&f(i,!0),this};this.unselecting=function(){return y(i)!==!1&&f(i,!1),this};this.selected=function(){return this.isSelectable()&&l(i)!==!1&&e(i,!0),this};this.unselected=function(){return a(i)!==!1&&e(i,!1),this};this.hit=function(n){var i=this.rectCtrl.getClient();for(var r in i)i[r]=parseFloat(i[r]);return i.bottom=i.bottom==t?i.top+i.height:i.bottom,i.right=i.right==t?i.left+i.width:i.right,n.bottom=n.bottom==t?n.top+n.height:n.bottom,n.right=n.right==t?n.left+n.width:n.right,n.top<=i.top&&i.top<=n.bottom&&(n.left<=i.left&&i.left<=n.right||n.left<=i.right&&i.right<=n.right)||n.top<=i.bottom&&i.bottom<=n.bottom&&(n.left<=i.left&&i.left<=n.right||n.left<=i.right&&i.right<=n.right)||n.left>=i.left&&n.right<=i.right&&(i.top<=n.bottom&&n.bottom<=i.bottom||i.bottom>=n.top&&n.top>=i.top||n.top<=i.top&&n.bottom>=i.bottom)||n.top>=i.top&&n.bottom<=i.bottom&&(i.left<=n.right&&n.right<=i.right||i.right>=n.left&&n.left>=i.left||n.left<=i.left&&n.right>=i.right)||n.top>=i.top&&n.right<=i.right&&n.bottom<=i.bottom&&n.left>=i.left}}function r(n){this.$element=n}return i.$inject=["$scope","$attrs","$element"],r.prototype={getClient:function(){return this.$element.dndClientRect()}},{restrict:"A",require:["dndSelectable","^dndLassoArea","?dndRect"],controller:i,scope:!0,link:function(i,u,f,e){function v(){e[1].remove(e[0]);i.$$phase||i.$apply()}var a;i.$dndSelectable=e[0];a=e[2];e[0].rectCtrl=a?a:new r(u);e[1].add(e[0]);u.on("$destroy",v);var s=n(f.dndOnSelected),h=n(f.dndOnUnselected),c=n(f.dndOnSelecting),l=n(f.dndOnUnselecting);(s||h)&&(s=s||o,h=h||o,i.$watch(f.dndModelSelected,function(n,r){n!==t&&r!==t&&n!==r&&(n?s(i):h(i))}));(c||l)&&(c=c||o,l=l||o,i.$watch(f.dndModelSelecting,function(n,r){n!==t&&r!==t&&n!==r&&(n?c(i):l(i))}))}}}]);e.directive("dndRect",["$parse",function(n){function r(r,f,e){function l(n){var f,s,o,r;for(n=typeof n=="object"?n:{},s=0;s<i.length;s++)(o=i[s],n[o]===t)&&(f||(f=e.dndCss(u)),n[o]=o=="transform"?f[c]=="none"?"matrix(1, 0, 0, 1, 0, 0)":f[c]:f[o]);for(r in n)n[r.toLowerCase()]=n[r];for(r in n)i.has(r)?typeof n[r]=="number"&&(n[r]=n[r]+"px"):delete n[r];return n}var o=n(f.dndRect),s=o.assign,h;this.update=function(n,u){var f,c=o(r)||{},e,h;for(typeof n!="object"?(f={},f[n]=u):f=n,e=0;e<i.length;e++)h=i[e],f[h]!==t&&(c[h]=f[h]);s(r,c)};this.get=function(){return o(r)};this.getClient=function(){return e.dndClientRect()};r.$parent.$watch(function(){var n=o(r.$parent);n!==h&&s(r,n)});r.$watch(f.dndRect,function(n,r){var s,u,f,o;if(n&&typeof n=="object"){for(r==t&&(r={}),s=n=l(n),u={},o=0;o<i.length;o++)f=i[o],n[f]==t&&r[f]!=t?u[f]="":n[f]!=t&&(u[f]=n[f]);u.transform&&(u[c]=u.transform);e.dndCss(u)}},!0)}var i=["top","left","width","height","transform"],u=["top","left","width","height",c];return i.has=function(n){return this.indexOf(n)>-1},r.$inject=["$scope","$attrs","$element"],{restrict:"A",controller:r}}]);e.directive("dndModel",["$parse",function(n){function t(t,i){var r=n(i.dndModel),u=r.assign;this.set=function(n){u(t,n)};this.get=function(){return r(t)}}return t.$inject=["$scope","$attrs"],{restrict:"A",controller:t}}]);e.directive("dndLassoArea",["DndLasso","$parse","$timeout","dndKey",function(n,i,r){function f(){var n=[],i={};this.data=function(){return i};this.add=function(t){n.push(t)};this.remove=function(t){for(var i=0;i<n.length;i++)if(n[i]===t)return n.splice(i,1),!0;return!1};this.getSelectable=function(i){for(var r=0;r<n.length;r++)if(n[r].getElement()[0]==i)return n[r];return t};this.empty=function(){return!n.length};this.get=function(i){return i===t?n:n[i]}}f.$inject=[];var u=[];return u.remove=function(n){for(var t=0;t<this.length;t++)if(this[t]===n)return this.splice(t,1),!0;return!1},{restrict:"A",controller:f,require:"dndLassoArea",priority:-1,link:function(t,f,e,o){function b(n){var r,i;if(!o.empty()){if(c){s.toggleSelected();return}for(r=o.get(),i=0;i<r.length;i++)r[i].unselected().unselecting();s&&s.selected()}w(t,{$event:n});t.$apply()}function k(n){var r,i;if(t.$dragged=!0,n.isActive()){if(v(t),!o.empty()&&!c)for(r=o.get(),i=0;i<r.length;i++)r[i].unselected().unselecting();t.$apply()}}function d(n){var r,u,i;if(t.$dragged=!0,n.isActive()){if(!o.empty())for(r=o.get(),u=n.getClientRect(),i=0;i<r.length;i++)r[i].hit(u)?r[i].selecting():r[i].unselecting();y(t,{$rect:n.getRect()});t.$apply()}}function g(n){var u,i;if(n.isActive()){if(u=o.get(),!o.empty()){for(i=0;i<u.length;i++)u[i].isSelecting()&&u[i].toggleSelected();t.$apply()}if(p(t,{$rect:n.getRect()}),!o.empty()){for(i=0;i<u.length;i++)u[i].unselecting();t.$apply()}r(function(){t.$dragged=!1})}}var tt=i(e.dndLassoArea),a=l({},{selectAdditionals:!0},i(e.dndLassoAreaOpts)(t)||{}),v=i(e.dndOnLassostart),y=i(e.dndOnLasso),p=i(e.dndOnLassoend),w=i(e.dndLassoOnclick),h=new n({$el:f}),s,c;u.push(o);f.on("mousedown touchstart",nt(function(n){t.$dragged=!1;t.$keypressed=c=a.selectAdditionals?n.shiftKey||n.ctrlKey||n.metaKey:!1;o.empty()||(s=o.getSelectable(n.target));t.$apply()},300));f.on("click",function(n){t.$dragged||b(n);t.$keypressed&&r(function(){t.$keypressed=!1})});h.on("start",k);h.on("drag",d);h.on("end",g);f.on("$destroy",function(){u.remove(o);t.$apply()});t.$dragged=!1}}}]);e.directive("dndFittext",["$timeout","$window",function(n,i){function e(n){var n=u.text(n).html().replace(/\s+/g," ");return(u[0].tagName=="INPUT"||u[0].tagName=="TEXTAREA")&&(n=n.replace(/\s/g,"&nbsp;")),n}function o(n,t){u.html(e(n)).dndCss(t);var i=u[0].getBoundingClientRect();return{width:parseFloat(i.width),height:parseFloat(i.height)}}function s(n,t,i){var r=n[0].getBoundingClientRect();return{width:parseFloat(r.width)*(100-t)/100,height:parseFloat(r.height)*(100-i)/100}}var u=f("<span><\/span>").dndCss({position:"absolute",left:-99999,top:-99999,opacity:0,"z-index":-9999});return f(r.body).append(u),{restrict:"A",link:function(n,r,u){function e(i){var l,v,h,c,e,a;i=i===t?{}:i;var b=r.dndCss(["font-size","font-family","font-weight","text-transform","border-top","border-right","border-bottom","border-left","padding-top","padding-right","padding-bottom","padding-left"]),g=i.text==t?r.text()||r.val():i.text,f=[];i.width===t&&f.push("width");i.height===t&&f.push("height");f.length&&(f=r.dndCss(f));for(l in f){if(v=f[l],v[v.length-1]=="%")return;i[l]=f[l]}if(h=o(g,b),c=s(r,0,0),!h.width||!h.height){r.dndCss("font-size","");return}c.width=parseFloat(i.width);c.height=parseFloat(i.height);var k=c.height/h.height,d=c.width/h.width,y=n.$eval(u.dndFittextMax),w=n.$eval(u.dndFittextMin);(w==t&&(w=0),y==t&&(y=Number.POSITIVE_INFINITY),e=k<d?k:d,e*=.85,e>.95&&e<=1||e>=1&&e<1.05)||(a=e*parseFloat(b["font-size"]),a=p(w,a,y),r.dndCss("font-size",a+"px"))}n.$watch(u.dndFittext,nt(function(n){e(n)}),!0);f(i).on("resize",function(){e()})}}}]);e.directive("dndKeyModel",["$parse","dndKey",function(n,i){return{restrict:"A",link:function(r,u,f){var e=n(f.dndKeyModel),o=e.assign;r.$watch(function(){return i.get()},function(n){n!==t&&o(r,n)})}}}]);e.directive("dndContainment",["$parse",function(n){function t(t,i,r){var u=n(i.dndContainment);this.get=function(){var n=u(r);return n?t.dndClosest(n).eq(0):t.parent()}}return t.$inject=["$element","$attrs","$scope"],{restrict:"EAC",controller:t}}]);e.factory("dndKey",["$rootScope",function(n){function i(){}function f(i){var r=i.keyCode;(u(i),t.indexOf(r)>-1)||(t.push(r),n.$digest())}function r(i){var u=i.keyCode,r=t.indexOf(u);r!==-1&&(t.splice(r,1),n.$digest())}var t=[],u;i.prototype={get:function(){return t},isset:function(n){var i=t.indexOf(n);return i!==-1}};u=g(r,1e3);h.on("keydown",f);h.on("keyup",r);return new i}]);e.factory("DndLasso",[function(){function u(i){this.getRect=function(){return this.isActive?i.rect:t};this.getClientRect=function(){return this.isActive?n.dndClientRect():t};this.isActive=function(){return i.active}}function e(n){var t=n.isTarget(),i=new u(this);this.isTarget=function(){return t};this.handler=function(){return i};this.getEvent=function(){return n.getEvent()}}function o(t){function h(i){var r=i.local=new e(i);if(!r.isTarget()){o.trigger("start",r.handler());return}r.active=!0;o.trigger("start",r.handler());i.setReferenceElement(t.$el);i.setBounderElement(t.$el);r.startAxis=i.getRelBorderedAxis();n.removeAttr("class style").removeClass("ng-hide").addClass(t.className);t.$el.append(n)}function c(i){var u=i.local,f,r;if(!u.active){o.trigger("drag",u.handler());return}f=i.getRelBorderedAxis().minus(u.startAxis);r={top:u.startAxis.y,left:u.startAxis.x,width:f.x,height:f.y};r.width<0&&(r.width=-r.width,r.left=r.left-r.width);r.height<0&&(r.height=-r.height,r.top=r.top-r.height);u.rect=r;r.top+=t.offsetY;r.left+=t.offsetX;n.dndCss(r);o.trigger("drag",u.handler())}function a(t){var i=t.local;if(!i.active){o.trigger("end",i.handler());return}n.addClass("ng-hide");f(r.body).append(n);o.trigger("end",i.handler())}var o=this,s,u;t=l({},i,t);s={"$$lasso.dragstart":h,"$$lasso.drag":c,"$$lasso.dragend":a};t.$el.dndBind(s);this.destroy=function(){t.$el.dndUnbind()};u={};this.on=function(n,t){u[n]=u[n]||[];u[n].push(t)};this.trigger=function(n,t){u[n]=u[n]||[];t=t||typeof t=="string"?[t]:[];u[n].forEach(function(n){n.apply(this,t)})}}var n=f("<div><\/div>").dndCss({position:"absolute"}),i={className:"angular-dnd-lasso",offsetX:0,offsetY:0};return o}]);e.factory("EventEmitter",[function(){function n(){var n={};this.on=function(t,i){n[t]=n[t]||[];n[t].push(i)};this.off=function(t,i){if(n[t])for(var r=0,u=n[t].length;r<u;r++)n[t][r]===i&&n[t].splice(r,1)};this.trigger=function(t,i){n[t]=n[t]||[];i=i||typeof i=="string"?[i]:[];n[t].forEach(function(n){n.apply(this,i)})}}return n}])})(angular,undefined,window,document);
//# sourceMappingURL=angular-dnd.min.js.map