/** * @license jquery.panzoom.js v1.8.5 * Updated: Fri Nov 22 2013 * Add pan and zoom functionality to any element * Copyright (c) 2013 timmy willison * Released under the MIT license * https://github.com/timmywil/jquery.panzoom/blob/master/MIT-License.txt */ !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],b):"object"==typeof exports?b(require("jquery")):b(a.jQuery)}(this,function(a){"use strict";function b(a,b){for(var c=a.length;--c;)if(+a[c]!==+b[c])return!1;return!0}function c(b){var c={range:!0,animate:!0};return"boolean"==typeof b?c.animate=b:a.extend(c,b),c}function d(b,c,d,e,f,g,h,i,j){this.elements="array"===a.type(b)?[+b[0],+b[2],+b[4],+b[1],+b[3],+b[5],0,0,1]:[b,c,d,e,f,g,h||0,i||0,j||1]}function e(a,b,c){this.elements=[a,b,c]}function f(b,c){1!==b.nodeType&&a.error("Panzoom called on non-Element node"),a.contains(document,b)||a.error("Panzoom element must be attached to the document");var d=a.data(b,h);if(d)return d;if(!(this instanceof f))return new f(b,c);this.options=c=a.extend({},f.defaults,c),this.elem=b;var e=this.$elem=a(b);this.$doc=a(b.ownerDocument||document),this.$parent=e.parent(),this.isSVG=k.test(b.namespaceURI)&&"svg"!==b.nodeName.toLowerCase(),this.panning=!1,this._buildTransform(),this.isSVG||(this._transform=a.cssProps.transform.replace(j,"-$1").toLowerCase()),this._buildTransition(),this.resetDimensions();var g=a(),i=this;a.each(["$zoomIn","$zoomOut","$zoomRange","$reset"],function(a,b){i[b]=c[b]||g}),this.enable(),a.data(b,h,this)}var g={props:["touches","pageX","pageY"],filter:function(a,b){var c;return!b.pageX&&b.touches&&(c=b.touches[0])&&(a.pageX=c.pageX,a.pageY=c.pageY),a}};a.each(["touchstart","touchmove","touchend"],function(b,c){a.event.fixHooks[c]=g});var h="__pz__",i=Array.prototype.slice,j=/([A-Z])/g,k=/^http:[\w\.\/]+svg$/,l=/^inline/,m="(\\-?[\\d\\.e]+)",n="\\,?\\s*",o=new RegExp("^matrix\\("+m+n+m+n+m+n+m+n+m+n+m+"\\)$");return d.prototype={x:function(a){var b=a instanceof e,c=this.elements,f=a.elements;return b&&3===f.length?new e(c[0]*f[0]+c[1]*f[1]+c[2]*f[2],c[3]*f[0]+c[4]*f[1]+c[5]*f[2],c[6]*f[0]+c[7]*f[1]+c[8]*f[2]):f.length===c.length?new d(c[0]*f[0]+c[1]*f[3]+c[2]*f[6],c[0]*f[1]+c[1]*f[4]+c[2]*f[7],c[0]*f[2]+c[1]*f[5]+c[2]*f[8],c[3]*f[0]+c[4]*f[3]+c[5]*f[6],c[3]*f[1]+c[4]*f[4]+c[5]*f[7],c[3]*f[2]+c[4]*f[5]+c[5]*f[8],c[6]*f[0]+c[7]*f[3]+c[8]*f[6],c[6]*f[1]+c[7]*f[4]+c[8]*f[7],c[6]*f[2]+c[7]*f[5]+c[8]*f[8]):!1},inverse:function(){var a=1/this.determinant(),b=this.elements;return new d(a*(b[8]*b[4]-b[7]*b[5]),a*-(b[8]*b[1]-b[7]*b[2]),a*(b[5]*b[1]-b[4]*b[2]),a*-(b[8]*b[3]-b[6]*b[5]),a*(b[8]*b[0]-b[6]*b[2]),a*-(b[5]*b[0]-b[3]*b[2]),a*(b[7]*b[3]-b[6]*b[4]),a*-(b[7]*b[0]-b[6]*b[1]),a*(b[4]*b[0]-b[3]*b[1]))},determinant:function(){var a=this.elements;return a[0]*(a[8]*a[4]-a[7]*a[5])-a[3]*(a[8]*a[1]-a[7]*a[2])+a[6]*(a[5]*a[1]-a[4]*a[2])}},e.prototype.e=d.prototype.e=function(a){return this.elements[a]},f.rmatrix=o,f.defaults={eventNamespace:".panzoom",transition:!0,cursor:"move",disablePan:!1,disableZoom:!1,increment:.3,minScale:.4,maxScale:5,rangeStep:.05,duration:200,easing:"ease-in-out",contain:!1},f.prototype={constructor:f,instance:function(){return this},enable:function(){this._initStyle(),this._bind(),this.disabled=!1},disable:function(){this.disabled=!0,this._resetStyle(),this._unbind()},isDisabled:function(){return this.disabled},destroy:function(){this.disable(),a.removeData(this.elem,h)},resetDimensions:function(){var b=this.$parent;this.container={width:b.width(),height:b.height()};var c=this.elem,d=this.$elem,e=this.dimensions=this.isSVG?{left:c.getAttribute("x")||0,top:c.getAttribute("y")||0,width:c.getAttribute("width")||d.outerWidth(),height:c.getAttribute("height")||d.outerHeight(),margin:{left:0,top:0}}:{left:a.css(c,"left",!0)||0,top:a.css(c,"top",!0)||0,width:d.outerWidth(),height:d.outerHeight(),margin:{top:a.css(c,"marginTop",!0)||0,left:a.css(c,"marginLeft",!0)||0}};e.widthBorder=a.css(c,"borderLeftWidth",!0)+a.css(c,"borderRightWidth",!0)||0,e.heightBorder=a.css(c,"borderTopWidth",!0)+a.css(c,"borderBottomWidth",!0)||0},reset:function(a){a=c(a);var b=this.setMatrix(this._origTransform,a);a.silent||this._trigger("reset",b)},resetZoom:function(a){a=c(a);var b=this.getMatrix(this._origTransform);a.dValue=b[3],this.zoom(b[0],a)},resetPan:function(a){var b=this.getMatrix(this._origTransform);this.pan(b[4],b[5],c(a))},getTransform:function(b){var c=this.elem,d=this.isSVG?"attr":"style";return b?a[d](c,"transform",b):b=a[d](c,"transform"),"none"===b||o.test(b)||this.isSVG||(b=a.css(c,"transform"),a.style(c,"transform",b)),b||"none"},getMatrix:function(a){var b=o.exec(a||this.getTransform());return b&&b.shift(),b||[1,0,0,1,0,0]},setMatrix:function(b,c){if(!this.disabled){c||(c={}),"string"==typeof b&&(b=this.getMatrix(b));var d,e,f,g,h,i,j,k,m=+b[0],n=this.$parent,o=this.elem,p="undefined"!=typeof c.contain?c.contain:this.options.contain;return p&&(d=this._checkDims(),e=this.container,f=(d.width*m-e.width)/2,g=(d.height*m-e.height)/2,"invert"===p?(h=d.width>e.width?d.width-e.width:0,i=d.height>e.height?d.height-e.height:0,f+=(e.width-d.width)/2,g+=(e.height-d.height)/2,j=d.left+d.margin.left,k=d.top+d.margin.top,b[4]=Math.max(Math.min(b[4],f-j),-f-j-h),b[5]=Math.max(Math.min(b[5],g-k),-g-k-i+d.heightBorder)):(i=e.height>d.height?e.height-d.height:0,"center"===n.css("textAlign")&&l.test(a.css(o,"display"))?h=0:(h=e.width>d.width?e.width-d.width:0,f=g=0),b[4]=Math.min(Math.max(b[4],f-d.left),-f-d.left+h),b[5]=Math.min(Math.max(b[5],g-d.top),-g-d.top+i))),"skip"!==c.animate&&this.transition(!c.animate),c.range&&this.$zoomRange.val(m),a[this.isSVG?"attr":"style"](o,"transform","matrix("+b.join(",")+")"),c.silent||this._trigger("change",b),b}},isPanning:function(){return this.panning},transition:function(b){var c=b||!this.options.transition?"none":this._transition;a.style(this.elem,"transition")!==c&&a.style(this.elem,"transition",c)},pan:function(a,b,c){if(!this.options.disablePan){c||(c={});var d=c.matrix;d||(d=this.getMatrix()),c.relative?(d[4]=+d[4]+a,d[5]=+d[5]+b):(d[4]=a,d[5]=b),this.setMatrix(d,c),c.silent||this._trigger("pan",a,b)}},zoom:function(b,c){"object"==typeof b?(c=b,b=null):c||(c={});var f=a.extend({},this.options,c);if(!f.disableZoom){var g=!1,h=f.matrix||this.getMatrix();"number"!=typeof b&&(b=+h[0]+f.increment*(b?-1:1),g=!0),b>f.maxScale?b=f.maxScale:b