text: /*
  	Copyright Kamil Pękala http://github.com/kamilkp
  	angular-sortable-view v0.0.13 2015/01/13
  */
  !function(a,b){"use strict";function c(a){if(!("clientX"in a||"clientY"in a)){var b=a.touches||a.originalEvent.touches;b&&b.length&&(a.clientX=b[0].clientX,a.clientY=b[0].clientY),a.preventDefault()}}function d(a){if(a=a[0],a.previousElementSibling)return b.element(a.previousElementSibling);for(var c=a.previousSibling;null!=c&&1!=c.nodeType;)c=c.previousSibling;return b.element(c)}function e(a,b){var c=d(a);c.length>0?c.after(b):a.parent().prepend(b)}function f(){return"scrollX"in a?a.scrollX:document[0].documentElement.scrollLeft}function g(){return"scrollY"in a?a.scrollY:document[0].documentElement.scrollTop}function h(a,c){if(a instanceof b.element&&(a=a[0]),null!==k)return a[k](c)}var i=b.module("angular-sortable-view",[]);i.directive("svRoot",[function(){function a(a,b,c){return c?a.x-b.x<0:a.y-b.y<0}function b(a){return k[a]}function c(a){delete k[a]}function d(a){return[{x:a.left,y:a.top},{x:a.left+a.width,y:a.top},{x:a.left,y:a.top+a.height},{x:a.left+a.width,y:a.top+a.height},{x:a.left+a.width/2,y:a.top+a.height/2}]}function i(a,b){return a.x>=b[0].x&&a.x<=b[1].x&&a.y>=b[0].y&&a.y<=b[2].y?0:Math.min.apply(Math,b.map(function(b){return(b.x-a.x)*(b.x-a.x)+(b.y-a.y)*(b.y-a.y)}))}var j,k=Object.create(null);return{restrict:"A",controller:["$scope","$attrs","$interpolate","$parse",function(l,m,n,o){var p=n(m.svRoot)(l)||l.$id;k[p]||(k[p]=[]);var q,r,s,t,u,v,w=!1,x=o(m.svOnSort);m.svOnStart=m.$$element[0].attributes["sv-on-start"],m.svOnStart=m.svOnStart&&m.svOnStart.value,m.svOnStop=m.$$element[0].attributes["sv-on-stop"],m.svOnStop=m.svOnStop&&m.svOnStop.value;var y=o(m.svOnStart),z=o(m.svOnStop);if(this.sortingInProgress=function(){return j},m.svGrid){if(null===(w="true"===m.svGrid||"false"!==m.svGrid&&null))throw"Invalid value of sv-grid attribute"}else l.$watchCollection(function(){return b(p)},function(a){w=!1;var b=a.filter(function(a){return!a.container}).map(function(a){return{part:a.getPart().id,y:a.element[0].getBoundingClientRect().top}}),c=Object.create(null);b.forEach(function(a){c[a.part]?c[a.part].push(a.y):c[a.part]=[a.y]}),Object.keys(c).forEach(function(a){c[a].sort(),c[a].forEach(function(b,d){d<c[a].length-1&&b>0&&b===c[a][d+1]&&(w=!0)})})});this.$moveUpdate=function(c,k,m,n,o,x,z){var A=m[0].getBoundingClientRect();"element"===c.tolerance&&(k.x=~~(A.left+A.width/2),k.y=~~(A.top+A.height/2)),j=!0,q=[],r||(o?(r=o.clone(),r.removeClass("ng-hide")):(r=n.clone(),r.addClass("sv-visibility-hidden"),r.addClass("sv-placeholder"),r.css({height:A.height+"px",width:A.width+"px"})),n.after(r),x.copyMode||n.addClass("ng-hide"),u=n,s=c,t=m,y(l,{$helper:{element:t},$part:x.model(x.scope),$index:z,$item:x.model(x.scope)[z]}),l.$root&&l.$root.$$phase||l.$apply()),t[0].reposition({x:k.x+2*f()-k.initialWindowScroll.x-k.offset.x*A.width,y:k.y+2*g()-k.initialWindowScroll.y-k.offset.y*A.height}),b(p).forEach(function(b,e){if(null==c.containment||h(b.element,c.containment)||h(b.element,c.containment+" *")){var f=b.element[0].getBoundingClientRect(),g=d(f),j={x:~~(f.left+f.width/2),y:~~(f.top+f.height/2)},l={x:~~(f.left+f.width/2),y:~~f.top},m={x:~~f.left,y:~~(f.top+f.height/2)};if(!b.container&&(b.element[0].scrollHeight||b.element[0].scrollWidth)){var n=b.getPart();q.push({element:b.element,q:i(k,g),view:n,targetIndex:b.getIndex(),after:a(j,k,"isGrid"in n?n.isGrid:w)})}if(b.container&&!b.element[0].querySelector("[sv-element]:not(.sv-placeholder):not(.sv-source)")){var o=j;"vertical"===b.centerVariant?o=m:"horizontal"===b.centerVariant&&(o=l),q.push({element:b.element,q:(o.x-k.x)*(o.x-k.x)+(o.y-k.y)*(o.y-k.y),view:b.getPart(),targetIndex:0,container:!0})}}});var B=r[0].getBoundingClientRect();q.push({q:i(k,d(B)),element:r,placeholder:!0}),q.sort(function(a,b){return a.q-b.q}),q.forEach(function(a,b){0!==b||a.placeholder||a.container?0===b&&a.container?(v=a,a.element.append(r)):a.element.removeClass("sv-candidate"):(v=a,a.element.addClass("sv-candidate"),a.after?a.element.after(r):e(a.element,r))})},this.$drop=function(a,b,c){function d(){if(j=!1,r.remove(),t.remove(),u.removeClass("ng-hide"),q=void 0,r=void 0,c=void 0,t=void 0,u=void 0,z(l,{$part:a.model(a.scope),$index:b,$item:a.model(a.scope)[b]}),v){v.element.removeClass("sv-candidate");var d=a.model(a.scope).splice(b,1),e=v.targetIndex;v.view===a&&v.targetIndex>b&&e--,v.after&&e++,v.view.model(v.view.scope).splice(e,0,d[0]),v.view===a&&b===e||x(l,{$partTo:v.view.model(v.view.scope),$partFrom:a.model(a.scope),$item:d[0],$indexTo:e,$indexFrom:b})}v=void 0,l.$root&&l.$root.$$phase||l.$apply()}if(r)if(!c.revert||v&&v.view&&v.view.noRevert)d();else{var e=r[0].getBoundingClientRect(),f=t[0].getBoundingClientRect(),g=Math.sqrt(Math.pow(f.top-e.top,2)+Math.pow(f.left-e.left,2)),h=+c.revert*g/200;h=Math.min(h,+c.revert),["-webkit-","-moz-","-ms-","-o-",""].forEach(function(a){void 0!==t[0].style[a+"transition"]&&(t[0].style[a+"transition"]="all "+h+"ms ease")}),setTimeout(d,h),t.css({top:e.top+document.body.scrollTop+"px",left:e.left+document.body.scrollLeft+"px"})}},this.addToSortableElements=function(a){b(p).push(a)},this.removeFromSortableElements=function(a){var d=b(p),e=d.indexOf(a);e>-1&&(d.splice(e,1),0===d.length&&c(p))}}]}}]),i.directive("svPart",["$parse",function(a){return{restrict:"A",require:"^svRoot",controller:["$scope",function(a){a.$ctrl=this,this.getPart=function(){return a.part},this.$drop=function(b,c){a.$sortableRoot.$drop(a.part,b,c)}}],scope:!0,link:function(b,c,d,e){if(!d.svPart)throw new Error("no model provided");var f=a(d.svPart);if(!f.assign)throw new Error("model not assignable");b.part={id:b.$id,element:c,model:f,copyMode:"true"===d.svCopy,noRevert:"true"===d.svNoRevert,scope:b},"isGrid"in d&&(b.part.isGrid="true"===d.isGrid),b.$sortableRoot=e;var g={element:c,getPart:b.$ctrl.getPart,container:!0,centerVariant:d.svCenter||"both"};e.addToSortableElements(g),b.$on("$destroy",function(){e.removeFromSortableElements(g)})}}}]),i.directive("svElement",["$parse","$window",function(a,d){return{restrict:"A",require:["^svPart","^svRoot"],controller:["$scope",function(a){a.$ctrl=this}],link:function(e,h,i,j){function k(d){function k(a){c(a),q||(h.parent().prepend(w),q=!0),j[1].$moveUpdate(t,{x:a.clientX,y:a.clientY,offset:z,initialWindowScroll:A},w,h,p,j[0].getPart(),e.$index),B=a}function m(){B&&k(B)}if(c(d),!j[1].sortingInProgress()&&(0==d.button||"mousedown"!==d.type)){var n=d.target.attributes["sv-handle-disabled"];if(!n||"true"!==n.value){q=!1;var t=a(i.svElement)(e);t=b.extend({},{tolerance:"pointer",revert:200,containment:"body",positionFixedAnchor:null},t);var u;if(t.containment)var v=l.call(h,t.containment)[0].getBoundingClientRect();t.positionFixedAnchor&&(u=l.call(h,t.positionFixedAnchor)[0].getBoundingClientRect());var w,x=h,y=h[0].getBoundingClientRect();o||(o=j[0].helper),p||(p=j[0].placeholder),o?(w=o.clone(),w.removeClass("ng-hide"),w.css({left:y.left+document.body.scrollLeft+"px",top:y.top+document.body.scrollTop+"px"}),x.addClass("sv-visibility-hidden")):(w=x.clone(),w.addClass("sv-helper").css({left:y.left+document.body.scrollLeft+"px",top:y.top+document.body.scrollTop+"px",width:y.width+"px"})),w[0].reposition=function(a){var b=a.x,c=a.y,d=w[0].getBoundingClientRect();document.body;v&&(c<v.top+g()&&(c=v.top+g()),c+d.height>v.top+g()+v.height&&(c=v.top+g()+v.height-d.height),b<v.left+f()&&(b=v.left+f()),b+d.width>v.left+f()+v.width&&(b=v.left+f()+v.width-d.width));var e=b-f(),h=c-g();u&&(e-=u.left,h-=u.top),this.style.left=e+"px",this.style.top=h+"px"};var z={x:(d.clientX-y.left)/y.width,y:(d.clientY-y.top)/y.height},A={x:f(),y:g()},B=null;r.addClass("sv-sorting-in-progress"),s.on("scroll",m),r.on("mousemove touchmove",k).on("mouseup touchend touchcancel",function a(b){r.off("mousemove touchmove",k),r.off("mouseup touchend touchcancel",a),s.off("scroll",m),B=null,r.removeClass("sv-sorting-in-progress"),q&&j[0].$drop(e.$index,t),h.removeClass("sv-visibility-hidden")})}}}var m={element:h,getPart:j[0].getPart,getIndex:function(){return e.$index}};j[1].addToSortableElements(m),e.$on("$destroy",function(){j[1].removeFromSortableElements(m)});var n=h;n.on("mousedown touchstart",k),e.$watch("$ctrl.handle",function(a){a&&(n.off("mousedown touchstart",k),n=a,n.on("mousedown touchstart",k))});var o;e.$watch("$ctrl.helper",function(a){a&&(o=a)});var p;e.$watch("$ctrl.placeholder",function(a){a&&(p=a)});var q,r=(b.element(document.body),b.element(document.documentElement)),s=b.element(d)}}}]),i.directive("svHandle",function(){return{require:"?^svElement",link:function(a,b,c,d){d&&(d.handle=b.add(d.handle))}}}),i.directive("svHelper",function(){return{require:["?^svPart","?^svElement"],link:function(a,b,c,d){b.addClass("sv-helper").addClass("ng-hide"),d[1]?d[1].helper=b:d[0]&&(d[0].helper=b)}}}),i.directive("svPlaceholder",function(){return{require:["?^svPart","?^svElement"],link:function(a,b,c,d){b.addClass("sv-placeholder").addClass("ng-hide"),d[1]?d[1].placeholder=b:d[0]&&(d[0].placeholder=b)}}}),b.element(document.head).append(["<style>.sv-helper{position: fixed !important;z-index: 99999;margin: 0 !important;}.sv-candidate{}.sv-placeholder{}.sv-sorting-in-progress{-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;}.sv-visibility-hidden{visibility: hidden !important;opacity: 0 !important;}</style>"].join(""));var j=document.documentElement,k=j.matches?"matches":j.matchesSelector?"matchesSelector":j.webkitMatches?"webkitMatches":j.webkitMatchesSelector?"webkitMatchesSelector":j.msMatches?"msMatches":j.msMatchesSelector?"msMatchesSelector":j.mozMatches?"mozMatches":j.mozMatchesSelector?"mozMatchesSelector":null;if(null==k)throw"This browser doesn't support the HTMLElement.matches method";var l=b.element.prototype.closest||function(a){for(var c=this[0].parentNode;c!==document.documentElement&&!c[k](a);)c=c.parentNode;return c[k](a)?b.element(c):b.element()};"function"!=typeof b.element.prototype.add&&(b.element.prototype.add=function(a){var c,d=b.element();for(a=b.element(a),c=0;c<this.length;c++)d.push(this[c]);for(c=0;c<a.length;c++)d.push(a[c]);return d})}(window,angular);