!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