/*! * Draggabilly PACKAGED v1.1.2 * Make that shiz draggable * http://draggabilly.desandro.com * MIT license */ !function(a){function b(a){return new RegExp("(^|\\s+)"+a+"(\\s+|$)")}function c(a,b){var c=d(a,b)?f:e;c(a,b)}var d,e,f;"classList"in document.documentElement?(d=function(a,b){return a.classList.contains(b)},e=function(a,b){a.classList.add(b)},f=function(a,b){a.classList.remove(b)}):(d=function(a,c){return b(c).test(a.className)},e=function(a,b){d(a,b)||(a.className=a.className+" "+b)},f=function(a,c){a.className=a.className.replace(b(c)," ")});var g={hasClass:d,addClass:e,removeClass:f,toggleClass:c,has:d,add:e,remove:f,toggle:c};"function"==typeof define&&define.amd?define("classie/classie",g):a.classie=g}(window),function(){function a(){}function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function c(a){return function(){return this[a].apply(this,arguments)}}var d=a.prototype;d.getListeners=function(a){var b,c,d=this._getEvents();if("object"==typeof a){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;be;e++)if(b=c[e]+a,"string"==typeof d[b])return b}}var c="Webkit Moz ms Ms O".split(" "),d=document.documentElement.style;"function"==typeof define&&define.amd?define("get-style-property/get-style-property",[],function(){return b}):a.getStyleProperty=b}(window),function(a){function b(a){var b=parseFloat(a),c=-1===a.indexOf("%")&&!isNaN(b);return c&&b}function c(){for(var a={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},b=0,c=g.length;c>b;b++){var d=g[b];a[d]=0}return a}function d(a){function d(a){if("string"==typeof a&&(a=document.querySelector(a)),a&&"object"==typeof a&&a.nodeType){var d=f(a);if("none"===d.display)return c();var i={};i.width=a.offsetWidth,i.height=a.offsetHeight;for(var j=i.isBorderBox=!(!h||!d[h]||"border-box"!==d[h]),k=0,l=g.length;l>k;k++){var m=g[k],n=d[m],o=parseFloat(n);i[m]=isNaN(o)?0:o}var p=i.paddingLeft+i.paddingRight,q=i.paddingTop+i.paddingBottom,r=i.marginLeft+i.marginRight,s=i.marginTop+i.marginBottom,t=i.borderLeftWidth+i.borderRightWidth,u=i.borderTopWidth+i.borderBottomWidth,v=j&&e,w=b(d.width);w!==!1&&(i.width=w+(v?0:p+t));var x=b(d.height);return x!==!1&&(i.height=x+(v?0:q+u)),i.innerWidth=i.width-(p+t),i.innerHeight=i.height-(q+u),i.outerWidth=i.width+r,i.outerHeight=i.height+s,i}}var e,h=a("boxSizing");return function(){if(h){var a=document.createElement("div");a.style.width="200px",a.style.padding="1px 2px 3px 4px",a.style.borderStyle="solid",a.style.borderWidth="1px 2px 3px 4px",a.style[h]="border-box";var c=document.body||document.documentElement;c.appendChild(a);var d=f(a);e=200===b(d.width),c.removeChild(a)}}(),d}var e=document.defaultView,f=e&&e.getComputedStyle?function(a){return e.getComputedStyle(a,null)}:function(a){return a.currentStyle},g=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"];"function"==typeof define&&define.amd?define("get-size/get-size",["get-style-property/get-style-property"],d):a.getSize=d(a.getStyleProperty)}(window),function(a){function b(a,b){for(var c in b)a[c]=b[c];return a}function c(){}function d(d,e,g,j,k){function m(a,c){this.element="string"==typeof a?f.querySelector(a):a,this.options=b({},this.options),b(this.options,c),this._create()}function n(){return!1}function o(a,b){a.x=void 0!==b.pageX?b.pageX:b.clientX,a.y=void 0!==b.pageY?b.pageY:b.clientY}function p(a,b,c){return c=c||"round",b?Math[c](a/b)*b:a}var q=j("transform"),r=!!j("perspective");b(m.prototype,e.prototype),m.prototype.options={},m.prototype._create=function(){this.position={},this._getPosition(),this.startPoint={x:0,y:0},this.dragPoint={x:0,y:0},this.startPosition=b({},this.position);var a=h(this.element);"relative"!==a.position&&"absolute"!==a.position&&(this.element.style.position="relative"),this.enable(),this.setHandles()},m.prototype.setHandles=function(){this.handles=this.options.handle?this.element.querySelectorAll(this.options.handle):[this.element],this.bindHandles(!0)},m.prototype.bindHandles=function(b){var c;c=a.navigator.pointerEnabled?this.bindPointer:a.navigator.msPointerEnabled?this.bindMSPointer:this.bindMouseTouch,b=void 0===b?!0:!!b;for(var d=0,e=this.handles.length;e>d;d++){var f=this.handles[d];c.call(this,f,b)}},m.prototype.bindPointer=function(a,b){var c=b?"bind":"unbind";g[c](a,"pointerdown",this),a.style.touchAction=b?"none":""},m.prototype.bindMSPointer=function(a,b){var c=b?"bind":"unbind";g[c](a,"MSPointerDown",this),a.style.msTouchAction=b?"none":""},m.prototype.bindMouseTouch=function(a,b){var c=b?"bind":"unbind";g[c](a,"mousedown",this),g[c](a,"touchstart",this),b&&t(a)};var s="attachEvent"in f.documentElement,t=s?function(a){"IMG"===a.nodeName&&(a.ondragstart=n);for(var b=a.querySelectorAll("img"),c=0,d=b.length;d>c;c++){var e=b[c];e.ondragstart=n}}:c;m.prototype._getPosition=function(){var a=h(this.element),b=parseInt(a.left,10),c=parseInt(a.top,10);this.position.x=isNaN(b)?0:b,this.position.y=isNaN(c)?0:c,this._addTransformPosition(a)},m.prototype._addTransformPosition=function(a){if(q){var b=a[q];if(0===b.indexOf("matrix")){var c=b.split(","),d=0===b.indexOf("matrix3d")?12:4,e=parseInt(c[d],10),f=parseInt(c[d+1],10);this.position.x+=e,this.position.y+=f}}},m.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},m.prototype.getTouch=function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b];if(d.identifier===this.pointerIdentifier)return d}},m.prototype.onmousedown=function(a){var b=a.button;b&&0!==b&&1!==b||this.dragStart(a,a)},m.prototype.ontouchstart=function(a){this.isDragging||this.dragStart(a,a.changedTouches[0])},m.prototype.onMSPointerDown=m.prototype.onpointerdown=function(a){this.isDragging||this.dragStart(a,a)};var u={mousedown:["mousemove","mouseup"],touchstart:["touchmove","touchend","touchcancel"],pointerdown:["pointermove","pointerup","pointercancel"],MSPointerDown:["MSPointerMove","MSPointerUp","MSPointerCancel"]};m.prototype.dragStart=function(b,c){this.isEnabled&&(b.preventDefault?b.preventDefault():b.returnValue=!1,this.pointerIdentifier=void 0!==c.pointerId?c.pointerId:c.identifier,this._getPosition(),this.measureContainment(),o(this.startPoint,c),this.startPosition.x=this.position.x,this.startPosition.y=this.position.y,this.setLeftTop(),this.dragPoint.x=0,this.dragPoint.y=0,this._bindEvents({events:u[b.type],node:b.preventDefault?a:f}),d.add(this.element,"is-dragging"),this.isDragging=!0,this.emitEvent("dragStart",[this,b,c]),this.animate())},m.prototype._bindEvents=function(a){for(var b=0,c=a.events.length;c>b;b++){var d=a.events[b];g.bind(a.node,d,this)}this._boundEvents=a},m.prototype._unbindEvents=function(){var a=this._boundEvents;if(a&&a.events){for(var b=0,c=a.events.length;c>b;b++){var d=a.events[b];g.unbind(a.node,d,this)}delete this._boundEvents}},m.prototype.measureContainment=function(){var a=this.options.containment;if(a){this.size=k(this.element);var b=this.element.getBoundingClientRect(),c=i(a)?a:"string"==typeof a?f.querySelector(a):this.element.parentNode;this.containerSize=k(c);var d=c.getBoundingClientRect();this.relativeStartPosition={x:b.left-d.left,y:b.top-d.top}}},m.prototype.onmousemove=function(a){this.dragMove(a,a)},m.prototype.onMSPointerMove=m.prototype.onpointermove=function(a){a.pointerId===this.pointerIdentifier&&this.dragMove(a,a)},m.prototype.ontouchmove=function(a){var b=this.getTouch(a.changedTouches);b&&this.dragMove(a,b)},m.prototype.dragMove=function(a,b){o(this.dragPoint,b);var c=this.dragPoint.x-this.startPoint.x,d=this.dragPoint.y-this.startPoint.y,e=this.options.grid,f=e&&e[0],g=e&&e[1];c=p(c,f),d=p(d,g),c=this.containDrag("x",c,f),d=this.containDrag("y",d,g),c="y"===this.options.axis?0:c,d="x"===this.options.axis?0:d,this.position.x=this.startPosition.x+c,this.position.y=this.startPosition.y+d,this.dragPoint.x=c,this.dragPoint.y=d,this.emitEvent("dragMove",[this,a,b])},m.prototype.containDrag=function(a,b,c){if(!this.options.containment)return b;var d="x"===a?"width":"height",e=this.relativeStartPosition[a],f=p(-e,c,"ceil"),g=this.containerSize[d]-e-this.size[d];return g=p(g,c,"floor"),Math.min(g,Math.max(f,b))},m.prototype.onmouseup=function(a){this.dragEnd(a,a)},m.prototype.onMSPointerUp=m.prototype.onpointerup=function(a){a.pointerId===this.pointerIdentifier&&this.dragEnd(a,a)},m.prototype.ontouchend=function(a){var b=this.getTouch(a.changedTouches);b&&this.dragEnd(a,b)},m.prototype.dragEnd=function(a,b){this.isDragging=!1,delete this.pointerIdentifier,q&&(this.element.style[q]="",this.setLeftTop()),this._unbindEvents(),d.remove(this.element,"is-dragging"),this.emitEvent("dragEnd",[this,a,b])},m.prototype.onMSPointerCancel=m.prototype.onpointercancel=function(a){a.pointerId===this.pointerIdentifier&&this.dragEnd(a,a)},m.prototype.ontouchcancel=function(a){var b=this.getTouch(a.changedTouches);this.dragEnd(a,b)},m.prototype.animate=function(){if(this.isDragging){this.positionDrag();var a=this;l(function(){a.animate()})}};var v=r?function(a,b){return"translate3d( "+a+"px, "+b+"px, 0)"}:function(a,b){return"translate( "+a+"px, "+b+"px)"};return m.prototype.setLeftTop=function(){this.element.style.left=this.position.x+"px",this.element.style.top=this.position.y+"px"},m.prototype.positionDrag=q?function(){this.element.style[q]=v(this.dragPoint.x,this.dragPoint.y)}:m.prototype.setLeftTop,m.prototype.enable=function(){this.isEnabled=!0},m.prototype.disable=function(){this.isEnabled=!1,this.isDragging&&this.dragEnd()},m.prototype.destroy=function(){this.disable(),q&&(this.element.style[q]=""),this.element.style.left="",this.element.style.top="",this.element.style.position="",this.bindHandles(!1)},m}for(var e,f=a.document,g=f.defaultView,h=g&&g.getComputedStyle?function(a){return g.getComputedStyle(a,null)}:function(a){return a.currentStyle},i="object"==typeof HTMLElement?function(a){return a instanceof HTMLElement}:function(a){return a&&"object"==typeof a&&1===a.nodeType&&"string"==typeof a.nodeName},j=0,k="webkit moz ms o".split(" "),l=a.requestAnimationFrame,m=a.cancelAnimationFrame,n=0;n