!function(t,e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],function(t){e(t)}):"object"==typeof module&&module.exports?module.exports=t.easyzoom=e(require("jquery")):t.easyzoom=e(t.jquery)}(this,function(t){"use strict";function e(e,o){this.$target=t(e),this.opts=t.extend({},r,o,this.$target.data()),void 0===this.isopen&&this._init()}var o,i,s,h,n,a,r={loadingnotice:"loading image",errornotice:"the image could not be loaded",errorduration:2500,linkattribute:"href",preventclicks:!0,beforeshow:t.noop,beforehide:t.noop,onshow:t.noop,onhide:t.noop,onmove:t.noop};return e.prototype._init=function(){this.$link=this.$target.find("a"),this.$image=this.$target.find("img"),this.$flyout=t('
'),this.$notice=t('
'),this.$target.on({"mousemove.easyzoom touchmove.easyzoom":t.proxy(this._onmove,this),"mouseleave.easyzoom touchend.easyzoom":t.proxy(this._onleave,this),"mouseenter.easyzoom touchstart.easyzoom":t.proxy(this._onenter,this)}),this.opts.preventclicks&&this.$target.on("click.easyzoom",function(t){t.preventdefault()})},e.prototype.show=function(t,e){var n=this;if(!1!==this.opts.beforeshow.call(this)){if(!this.isready)return this._loadimage(this.$link.attr(this.opts.linkattribute),function(){!n.ismouseover&&e||n.show(t)});this.$target.append(this.$flyout);var a=this.$target.outerwidth(),r=this.$target.outerheight(),c=this.$flyout.width(),d=this.$flyout.height(),l=this.$zoom.width(),p=this.$zoom.height();(o=l-c)<0&&(o=0),(i=p-d)<0&&(i=0),s=o/a,h=i/r,this.isopen=!0,this.opts.onshow.call(this),t&&this._move(t)}},e.prototype._onenter=function(t){var e=t.originalevent.touches;this.ismouseover=!0,e&&1!=e.length||(t.preventdefault(),this.show(t,!0))},e.prototype._onmove=function(t){this.isopen&&(t.preventdefault(),this._move(t))},e.prototype._onleave=function(){this.ismouseover=!1,this.isopen&&this.hide()},e.prototype._onload=function(t){t.currenttarget.width&&(this.isready=!0,this.$notice.detach(),this.$flyout.html(this.$zoom),this.$target.removeclass("is-loading").addclass("is-ready"),t.data.call&&t.data())},e.prototype._onerror=function(){var t=this;this.$notice.text(this.opts.errornotice),this.$target.removeclass("is-loading").addclass("is-error"),this.detachnotice=settimeout(function(){t.$notice.detach(),t.detachnotice=null},this.opts.errorduration)},e.prototype._loadimage=function(e,o){var i=new image;this.$target.addclass("is-loading").append(this.$notice.text(this.opts.loadingnotice)),this.$zoom=t(i).on("error",t.proxy(this._onerror,this)).on("load",o,t.proxy(this._onload,this)),i.style.position="absolute",i.src=e},e.prototype._move=function(t){if(0===t.type.indexof("touch")){var e=t.touches||t.originalevent.touches;n=e[0].pagex,a=e[0].pagey}else n=t.pagex||n,a=t.pagey||a;var r=this.$target.offset(),c=a-r.top,d=n-r.left,l=math.ceil(c*h),p=math.ceil(d*s);if(p<0||l<0||o