';this.$magnify.append(e),this.options.initAnimation&&this.$image.hide(),this.$image.attr("src",t),function(t,i,e){var o=new Image;o.onload=function(){i(o)},o.onerror=function(){e(o)},o.src=t}(t,function(t){i.imageData={originalWidth:t.width,originalHeight:t.height},i.isMaximized||i.isOpened&&i.options.fixedModalPos?i.setImageSize(t):i.setModalSize(t),i.$stage.removeClass("stage-ready"),i.$image.removeClass("image-ready")},function(){i.$magnify.find(".magnify-loader").remove()}),this.options.title&&this.setImgTitle(t)},getImgGroup:function(e,o){var a=this;a.groupData=[],t(e).each(function(e,n){var s=i(this);a.groupData.push({src:s,caption:t(this).attr("data-caption")}),o===s&&(a.groupIndex=e)})},setImgTitle:function(t){var i=this.groupIndex,e=(e=this.groupData[i].caption)||function(t){return t.replace(/^.*?\/*([^/?]*)\.[a-z]+(\?.+|$)/gi,"$1")}(t);this.$title.text(e)},jump:function(t){this.groupIndex=this.groupIndex+t,this.jumpTo(this.groupIndex)},jumpTo:function(t){(t%=this.groupData.length)>=0?t%=this.groupData.length:t<0&&(t=(this.groupData.length+t)%this.groupData.length),this.groupIndex=t,this._triggerHook("beforeChange",t),this.loadImg(this.groupData[t].src),this._triggerHook("changed",t)},wheel:function(t){t.preventDefault();var i=1;t.originalEvent.deltaY?i=t.originalEvent.deltaY>0?1:-1:t.originalEvent.wheelDelta?i=-t.originalEvent.wheelDelta/120:t.originalEvent.detail&&(i=t.originalEvent.detail>0?1:-1);var e=-i*this.options.ratioThreshold,o={x:t.originalEvent.clientX-this.$stage.offset().left+g.scrollLeft(),y:t.originalEvent.clientY-this.$stage.offset().top+g.scrollTop()};this.zoom(e,o,t)},zoom:function(t,i,e){(t=t<0?1/(1-t):1+t)>.95&&t<1.05&&(t=1),t=this.$image.width()/this.imageData.originalWidth*t,t=Math.max(t,this.options.minRatio),t=Math.min(t,this.options.maxRatio),this.zoomTo(t,i,e)},zoomTo:function(i,e,a){var n=this.$image,s=this.$stage,h={w:this.imageData.width,h:this.imageData.height,x:this.imageData.left,y:this.imageData.top},l={w:s.width(),h:s.height(),x:s.offset().left,y:s.offset().top},r=this.imageData.originalWidth*i,g=this.imageData.originalHeight*i,f=e.x-(e.x-h.x)/h.w*r,d=e.y-(e.y-h.y)/h.h*g,m=this.isRotated?(r-g)/2:0,c=this.isRotated?g:r,p=this.isRotated?r:g,u=l.w-r,y=l.h-g;
// The conditions with image rotate 90 degree drive me crazy alomst!
-m=p<=l.h?(l.h-g)/2:m>d?d:m>y-d?m:y-d,f=c<=l.w?(l.w-r)/2:f>-d?-d:f>u+d?f:u+d,n.css({width:Math.round(r)+"px",height:Math.round(g)+"px",left:Math.round(f)+"px",top:Math.round(m)+"px"}),t.extend(this.imageData,{width:r,height:g,left:f,top:m}),o({w:Math.round(c),h:Math.round(p)},{w:l.w,h:l.h},this.$stage)},rotate:function(t){this.rotateAngle=this.rotateAngle+t,this.rotateAngle/90%2==0?this.isRotated=!1:this.isRotated=!0,this.rotateTo(this.rotateAngle)},rotateTo:function(t){this.$image.css({transform:"rotate("+t+"deg)"}),this.setImageSize({width:this.imageData.originalWidth,height:this.imageData.originalHeight}),this.$stage.removeClass("is-grab")},resize:function(){var t=this;return function(t,i){var e=null;return function(){var o=this,a=arguments;clearTimeout(e),e=setTimeout(function(){t.apply(o,a)},i)}}(function(){t.isOpened&&(t.isMaximized?t.setImageSize({width:t.imageData.originalWidth,height:t.imageData.originalHeight}):t.setModalSize({width:t.imageData.originalWidth,height:t.imageData.originalHeight}))},500)},maximize:function(){this.isMaximized?(this.$magnify.removeClass("magnify-maximize"),this.$magnify.css({width:this.modalData.width?this.modalData.width:this.options.modalWidth,height:this.modalData.height?this.modalData.height:this.options.modalHeight,left:this.modalData.left?this.modalData.left:(r.width()-this.options.modalWidth)/2+g.scrollLeft(),top:this.modalData.top?this.modalData.top:(r.height()-this.options.modalHeight)/2+g.scrollTop()}),this.isMaximized=!1):(this.modalData={width:this.$magnify.width(),height:this.$magnify.height(),left:this.$magnify.offset().left,top:this.$magnify.offset().top},this.$magnify.addClass("magnify-maximize"),this.$magnify.css({width:"100%",height:"100%",left:0,top:0}),this.isMaximized=!0),this.setImageSize({width:this.imageData.originalWidth,height:this.imageData.originalHeight})},fullscreen:function(){!function(t){t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen()}(this.$magnify[0])},keydown:function(t){if(!this.options.keyboard)return!1;var i=t.keyCode||t.which||t.charCode,e=t.ctrlKey||t.metaKey,o=t.altKey||t.metaKey;switch(i){case 37:this.jump(-1);break;case 39:this.jump(1);break;case 187:this.zoom(3*this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 189:this.zoom(3*-this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 61:this.zoom(3*this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 173:this.zoom(3*-this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 48:e&&o&&this.zoomTo(1,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 188:e&&this.rotate(-90);break;case 190:e&&this.rotate(90)}},addEvents:function(){var t=this;this.$close.off("click.magnify").on("click.magnify",function(i){t.close()}),this.$stage.off("wheel mousewheel DOMMouseScroll.magnify").on("wheel mousewheel DOMMouseScroll.magnify",function(i){t.wheel(i)}),this.$zoomIn.off("click.magnify").on("click.magnify",function(i){t.zoom(3*t.options.ratioThreshold,{x:t.$stage.width()/2,y:t.$stage.height()/2},i)}),this.$zoomOut.off("click.magnify").on("click.magnify",function(i){t.zoom(3*-t.options.ratioThreshold,{x:t.$stage.width()/2,y:t.$stage.height()/2},i)}),this.$actualSize.off("click.magnify").on("click.magnify",function(i){t.zoomTo(1,{x:t.$stage.width()/2,y:t.$stage.height()/2},i)}),this.$prev.off("click.magnify").on("click.magnify",function(){t.jump(-1)}),this.$fullscreen.off("click.magnify").on("click.magnify",function(){t.fullscreen()}),this.$next.off("click.magnify").on("click.magnify",function(){t.jump(1)}),this.$rotateLeft.off("click.magnify").on("click.magnify",function(){t.rotate(-90)}),this.$rotateRight.off("click.magnify").on("click.magnify",function(){t.rotate(90)}),this.$maximize.off("click.magnify").on("click.magnify",function(){t.maximize()}),g.off("keydown.magnify").on("keydown.magnify",function(i){t.keydown(i)}),r.on("resize.magnify",t.resize())},_triggerHook:function(i,e){this.options.callbacks[i]&&this.options.callbacks[i].apply(this,t.isArray(e)?e:[e])}},t.magnify={instance:u.prototype},t.fn.magnify=function(i){m=t(this);for(var e in i)"string"!=typeof i[e]||isNaN(i[e])||(i[e]=parseFloat(i[e]));var o=t.extend(!0,{},f,i);return p=o.zIndex,"string"==typeof i||("dblclick"===o.initEvent&&m.off("click.magnify").on("click.magnify",function(t){t.preventDefault(),t.stopPropagation()}),m.off(o.initEvent+l).on(o.initEvent+l,function(e){e.preventDefault(),e.stopPropagation(),t(this).data("magnify",new u(this,i))})),m},g.on("click.magnify","[data-magnify]",function(i){m=t("[data-magnify]"),i.preventDefault(),t(this).data("magnify",new u(this,{}))});t.extend(u.prototype,{draggable:function(i,e,o){var a=this,r=!1,f=0,m=0,u=0,y=0,x=function(e){if((e=e||window.event).preventDefault(),r&&!d&&!c&&!a.isMaximized){var o="touchmove"===e.type?e.originalEvent.targetTouches[0].pageX:e.clientX,n="touchmove"===e.type?e.originalEvent.targetTouches[0].pageY:e.clientY,s=o-f,h=n-m;t(i).css({left:s+u+"px",top:h+y+"px"})}},w=function(t){g.off(s+l,x).off(h+l,w),r=!1};t(e).on(n+l,function(e){if(e=e||window.event,a.options.multiInstances&&i.css("z-index",++p),t(e.target).closest(o).length)return!0;r=!0,f="touchstart"===e.type?e.originalEvent.targetTouches[0].pageX:e.clientX,m="touchstart"===e.type?e.originalEvent.targetTouches[0].pageY:e.clientY,u=t(i).offset().left,y=t(i).offset().top,g.on(s+l,x).on(h+l,w)})}});t.extend(u.prototype,{movable:function(i,e){var o=this,a=!1,r=0,f=0,m=0,c=0,p=0,u=0,y=0,x=function(i){if((i=i||window.event).preventDefault(),a){var n="touchmove"===i.type?i.originalEvent.targetTouches[0].pageX:i.clientX,s="touchmove"===i.type?i.originalEvent.targetTouches[0].pageY:i.clientY,h=n-r,l=s-f,g=h+m,d=l+c;u>0?l+c>y?d=y:l+c<-u+y&&(d=-u+y):d=c,p>0?h+m>-y?g=-y:h+m<-p-y&&(g=-p-y):g=m,t(e).css({left:g+"px",top:d+"px"}),t.extend(o.imageData,{left:g,top:d})}},w=function(i){g.off(s+l,x).off(h+l,w),a=!1,d=!1,t("html,body,.magnify-modal,.magnify-stage,.magnify-button,.magnify-resizable-handle").removeClass("is-grabbing")};t(i).on(n+l,function(n){(n=n||window.event).preventDefault();var b=t(e).width(),v=t(e).height(),z=t(i).width(),$=t(i).height();r="touchstart"===n.type?n.originalEvent.targetTouches[0].pageX:n.clientX,f="touchstart"===n.type?n.originalEvent.targetTouches[0].pageY:n.clientY,y=o.isRotated?(b-v)/2:0,p=o.isRotated?v-z:b-z,u=o.isRotated?b-$:v-$,a=p>0||u>0,d=p>0||u>0,m=t(e).position().left-y,c=t(e).position().top+y,i.hasClass("is-grab")&&t("html,body,.magnify-modal,.magnify-stage,.magnify-button,.magnify-resizable-handle").addClass("is-grabbing"),g.on(s+l,x).on(h+l,w)})}});t.extend(u.prototype,{resizable:function(i,e,a,r,f){var m=this,d=t(''),p=t(''),u=t(''),y=t(''),x=t(''),w=t(''),b=t(''),v=t(''),z={e:d,s:u,se:x,n:y,w:p,nw:v,ne:b,sw:w};t(i).append(d,p,u,y,x,w,b,v);var $=!1,M=0,T=0,D={w:0,h:0,l:0,t:0},k={w:0,h:0,l:0,t:0},I={w:0,h:0,l:0,t:0},R=0,E=0,H=0,C="",S=function(o,n){(n=n||window.event).preventDefault(),$=!0,c=!0,M="touchstart"===n.type?n.originalEvent.targetTouches[0].pageX:n.clientX,T="touchstart"===n.type?n.originalEvent.targetTouches[0].pageY:n.clientY,D={w:t(i).width(),h:t(i).height(),l:t(i).offset().left,t:t(i).offset().top},k={w:t(e).width(),h:t(e).height(),l:t(e).offset().left,t:t(e).offset().top},I={w:t(a).width(),h:t(a).height(),l:t(a).position().left,t:t(a).position().top},R=m.isRotated?(I.w-I.h)/2:0,E=m.isRotated?I.h:I.w,H=m.isRotated?I.w:I.h,C=o,t("html,body,.magnify-modal,.magnify-stage,.magnify-button").css("cursor",o+"-resize"),g.on(s+l,O).on(h+l,W)},O=function(e){if((e=e||window.event).preventDefault(),$&&!m.isMaximized){var o="touchmove"===e.type?e.originalEvent.targetTouches[0].pageX:e.clientX,n="touchmove"===e.type?e.originalEvent.targetTouches[0].pageY:e.clientY,s=o-M,h=n-T,l=function(t,i,e){var o=-i+D.w>r?i+D.l:D.l+D.w-r,a=-e+D.h>f?e+D.t:D.t+D.h-f;return{e:{width:Math.max(i+D.w,r)+"px"},s:{height:Math.max(e+D.h,f)+"px"},se:{width:Math.max(i+D.w,r)+"px",height:Math.max(e+D.h,f)+"px"},w:{width:Math.max(-i+D.w,r)+"px",left:o+"px"},n:{height:Math.max(-e+D.h,f)+"px",top:a+"px"},nw:{width:Math.max(-i+D.w,r)+"px",height:Math.max(-e+D.h,f)+"px",top:a+"px",left:o+"px"},ne:{width:Math.max(i+D.w,r)+"px",height:Math.max(-e+D.h,f)+"px",top:a+"px"},sw:{width:Math.max(-i+D.w,r)+"px",height:Math.max(e+D.h,f)+"px",left:o+"px"}}[t]}(C,s,h);t(i).css(l);var g=function(i,e,o){var n=e+D.w>r?k.w-E+e-R:r-(D.w-k.w)-E-R,s=o+D.h>f?k.h-H+o+R:f-(D.h-k.h)-H+R,h=-e+D.w>r?k.w-E-e-R:r-(D.w-k.w)-E-R,l=-o+D.h>f?k.h-H-o+R:f-(D.h-k.h)-H+R,g=t(a).position().left-R,m=t(a).position().top+R;return{e:{left:n>=-R?(n-R)/2+"px":g>n?g+"px":n+"px"},s:{top:s>=R?(s+R)/2+"px":m>s?m+"px":s+"px"},se:{top:s>=R?(s+R)/2+"px":m>s?m+"px":s+"px",left:n>=-R?(n-R)/2+"px":g>n?g+"px":n+"px"},w:{left:h>=-R?(h-R)/2+"px":g>h?g+"px":h+"px"},n:{top:l>=R?(l+R)/2+"px":m>l?m+"px":l+"px"},nw:{top:l>=R?(l+R)/2+"px":m>l?m+"px":l+"px",left:h>=-R?(h-R)/2+"px":g>h?g+"px":h+"px"},ne:{top:l>=R?(l+R)/2+"px":m>l?m+"px":l+"px",left:n>=-R?(n-R)/2+"px":g>n?g+"px":n+"px"},sw:{top:s>=R?(s+R)/2+"px":m>s?m+"px":s+"px",left:h>=-R?(h-R)/2+"px":g>h?g+"px":h+"px"}}[i]}(C,s,h);t(a).css(g)}},W=function(i){g.off(s+l,O).off(h+l,W),c&&o({w:E,h:H},{w:t(e).width(),h:t(e).height()},e),$=!1,c=!1,t("html,body,.magnify-modal,.magnify-stage,.magnify-button").css("cursor","")};t.each(z,function(t,i){i.on(n+l,function(i){S(t,i)})})}})});
\ No newline at end of file
+d=p<=l.h?(l.h-g)/2:d>m?m:d>y-m?d:y-m,f=c<=l.w?(l.w-r)/2:f>-m?-m:f>u+m?f:u+m,n.css({width:Math.round(r)+"px",height:Math.round(g)+"px",left:Math.round(f)+"px",top:Math.round(d)+"px"}),t.extend(this.imageData,{width:r,height:g,left:f,top:d}),o({w:Math.round(c),h:Math.round(p)},{w:l.w,h:l.h},this.$stage)},rotate:function(t){this.rotateAngle=this.rotateAngle+t,this.rotateAngle/90%2==0?this.isRotated=!1:this.isRotated=!0,this.rotateTo(this.rotateAngle)},rotateTo:function(t){this.$image.css({transform:"rotate("+t+"deg)"}),this.setImageSize({width:this.imageData.originalWidth,height:this.imageData.originalHeight}),this.$stage.removeClass("is-grab")},resize:function(){var t=this;return function(t,i){var e=null;return function(){var o=this,a=arguments;clearTimeout(e),e=setTimeout(function(){t.apply(o,a)},i)}}(function(){t.isOpened&&(t.isMaximized?t.setImageSize({width:t.imageData.originalWidth,height:t.imageData.originalHeight}):t.setModalSize({width:t.imageData.originalWidth,height:t.imageData.originalHeight}))},500)},maximize:function(){this.isMaximized?(this.$magnify.removeClass("magnify-maximize"),this.$magnify.css({width:this.modalData.width?this.modalData.width:this.options.modalWidth,height:this.modalData.height?this.modalData.height:this.options.modalHeight,left:this.modalData.left?this.modalData.left:(r.width()-this.options.modalWidth)/2+g.scrollLeft(),top:this.modalData.top?this.modalData.top:(r.height()-this.options.modalHeight)/2+g.scrollTop()}),this.isMaximized=!1):(this.modalData={width:this.$magnify.width(),height:this.$magnify.height(),left:this.$magnify.offset().left,top:this.$magnify.offset().top},this.$magnify.addClass("magnify-maximize"),this.$magnify.css({width:"100%",height:"100%",left:0,top:0}),this.isMaximized=!0),this.setImageSize({width:this.imageData.originalWidth,height:this.imageData.originalHeight})},fullscreen:function(){!function(t){t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen()}(this.$magnify[0])},keydown:function(t){if(!this.options.keyboard)return!1;var i=t.keyCode||t.which||t.charCode,e=t.ctrlKey||t.metaKey,o=t.altKey||t.metaKey;switch(i){case 37:this.jump(-1);break;case 39:this.jump(1);break;case 187:this.zoom(3*this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 189:this.zoom(3*-this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 61:this.zoom(3*this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 173:this.zoom(3*-this.options.ratioThreshold,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 48:e&&o&&this.zoomTo(1,{x:this.$stage.width()/2,y:this.$stage.height()/2},t);break;case 188:e&&this.rotate(-90);break;case 190:e&&this.rotate(90)}},addEvents:function(){var t=this;this.$close.off("click.magnify").on("click.magnify",function(i){t.close()}),this.$stage.off("wheel mousewheel DOMMouseScroll.magnify").on("wheel mousewheel DOMMouseScroll.magnify",function(i){t.wheel(i)}),this.$zoomIn.off("click.magnify").on("click.magnify",function(i){t.zoom(3*t.options.ratioThreshold,{x:t.$stage.width()/2,y:t.$stage.height()/2},i)}),this.$zoomOut.off("click.magnify").on("click.magnify",function(i){t.zoom(3*-t.options.ratioThreshold,{x:t.$stage.width()/2,y:t.$stage.height()/2},i)}),this.$actualSize.off("click.magnify").on("click.magnify",function(i){t.zoomTo(1,{x:t.$stage.width()/2,y:t.$stage.height()/2},i)}),this.$prev.off("click.magnify").on("click.magnify",function(){t.jump(-1)}),this.$fullscreen.off("click.magnify").on("click.magnify",function(){t.fullscreen()}),this.$next.off("click.magnify").on("click.magnify",function(){t.jump(1)}),this.$rotateLeft.off("click.magnify").on("click.magnify",function(){t.rotate(-90)}),this.$rotateRight.off("click.magnify").on("click.magnify",function(){t.rotate(90)}),this.$maximize.off("click.magnify").on("click.magnify",function(){t.maximize()}),g.off("keydown.magnify").on("keydown.magnify",function(i){t.keydown(i)}),r.on("resize.magnify",t.resize())},_triggerHook:function(i,e){this.options.callbacks[i]&&this.options.callbacks[i].apply(this,t.isArray(e)?e:[e])}},t.magnify={instance:u.prototype},t.fn.magnify=function(i){d=t(this);for(var e in i)"string"!=typeof i[e]||isNaN(i[e])||(i[e]=parseFloat(i[e]));var o=t.extend(!0,{},f,i);return p=o.zIndex,"string"==typeof i||("dblclick"===o.initEvent&&d.off("click.magnify").on("click.magnify",function(t){t.preventDefault(),t.stopPropagation()}),d.off(o.initEvent+l).on(o.initEvent+l,function(e){e.preventDefault(),e.stopPropagation(),t(this).data("magnify",new u(this,i))})),d},g.on("click.magnify","[data-magnify]",function(i){d=t("[data-magnify]"),i.preventDefault(),t(this).data("magnify",new u(this,f))});t.extend(u.prototype,{draggable:function(i,e,o){var a=this,r=!1,f=0,d=0,u=0,y=0,x=function(e){if((e=e||window.event).preventDefault(),r&&!m&&!c&&!a.isMaximized){var o="touchmove"===e.type?e.originalEvent.targetTouches[0].pageX:e.clientX,n="touchmove"===e.type?e.originalEvent.targetTouches[0].pageY:e.clientY,s=o-f,h=n-d;t(i).css({left:s+u+"px",top:h+y+"px"})}},w=function(t){g.off(s+l,x).off(h+l,w),r=!1};t(e).on(n+l,function(e){if(e=e||window.event,a.options.multiInstances&&i.css("z-index",++p),t(e.target).closest(o).length)return!0;r=!0,f="touchstart"===e.type?e.originalEvent.targetTouches[0].pageX:e.clientX,d="touchstart"===e.type?e.originalEvent.targetTouches[0].pageY:e.clientY,u=t(i).offset().left,y=t(i).offset().top,g.on(s+l,x).on(h+l,w)})}});t.extend(u.prototype,{movable:function(i,e){var o=this,a=!1,r=0,f=0,d=0,c=0,p=0,u=0,y=0,x=function(i){if((i=i||window.event).preventDefault(),a){var n="touchmove"===i.type?i.originalEvent.targetTouches[0].pageX:i.clientX,s="touchmove"===i.type?i.originalEvent.targetTouches[0].pageY:i.clientY,h=n-r,l=s-f,g=h+d,m=l+c;u>0?l+c>y?m=y:l+c<-u+y&&(m=-u+y):m=c,p>0?h+d>-y?g=-y:h+d<-p-y&&(g=-p-y):g=d,t(e).css({left:g+"px",top:m+"px"}),t.extend(o.imageData,{left:g,top:m})}},w=function(i){g.off(s+l,x).off(h+l,w),a=!1,m=!1,t("html,body,.magnify-modal,.magnify-stage,.magnify-button,.magnify-resizable-handle").removeClass("is-grabbing")};t(i).on(n+l,function(n){(n=n||window.event).preventDefault();var b=t(e).width(),v=t(e).height(),z=t(i).width(),$=t(i).height();r="touchstart"===n.type?n.originalEvent.targetTouches[0].pageX:n.clientX,f="touchstart"===n.type?n.originalEvent.targetTouches[0].pageY:n.clientY,y=o.isRotated?(b-v)/2:0,p=o.isRotated?v-z:b-z,u=o.isRotated?b-$:v-$,a=p>0||u>0,m=p>0||u>0,d=t(e).position().left-y,c=t(e).position().top+y,i.hasClass("is-grab")&&t("html,body,.magnify-modal,.magnify-stage,.magnify-button,.magnify-resizable-handle").addClass("is-grabbing"),g.on(s+l,x).on(h+l,w)})}});t.extend(u.prototype,{resizable:function(i,e,a,r,f){var d=this,m=t(''),p=t(''),u=t(''),y=t(''),x=t(''),w=t(''),b=t(''),v=t(''),z={e:m,s:u,se:x,n:y,w:p,nw:v,ne:b,sw:w};t(i).append(m,p,u,y,x,w,b,v);var $=!1,M=0,T=0,D={w:0,h:0,l:0,t:0},k={w:0,h:0,l:0,t:0},I={w:0,h:0,l:0,t:0},R=0,H=0,E=0,C="",S=function(o,n){(n=n||window.event).preventDefault(),$=!0,c=!0,M="touchstart"===n.type?n.originalEvent.targetTouches[0].pageX:n.clientX,T="touchstart"===n.type?n.originalEvent.targetTouches[0].pageY:n.clientY,D={w:t(i).width(),h:t(i).height(),l:t(i).offset().left,t:t(i).offset().top},k={w:t(e).width(),h:t(e).height(),l:t(e).offset().left,t:t(e).offset().top},I={w:t(a).width(),h:t(a).height(),l:t(a).position().left,t:t(a).position().top},R=d.isRotated?(I.w-I.h)/2:0,H=d.isRotated?I.h:I.w,E=d.isRotated?I.w:I.h,C=o,t("html,body,.magnify-modal,.magnify-stage,.magnify-button").css("cursor",o+"-resize"),g.on(s+l,O).on(h+l,W)},O=function(e){if((e=e||window.event).preventDefault(),$&&!d.isMaximized){var o="touchmove"===e.type?e.originalEvent.targetTouches[0].pageX:e.clientX,n="touchmove"===e.type?e.originalEvent.targetTouches[0].pageY:e.clientY,s=o-M,h=n-T,l=function(t,i,e){var o=-i+D.w>r?i+D.l:D.l+D.w-r,a=-e+D.h>f?e+D.t:D.t+D.h-f;return{e:{width:Math.max(i+D.w,r)+"px"},s:{height:Math.max(e+D.h,f)+"px"},se:{width:Math.max(i+D.w,r)+"px",height:Math.max(e+D.h,f)+"px"},w:{width:Math.max(-i+D.w,r)+"px",left:o+"px"},n:{height:Math.max(-e+D.h,f)+"px",top:a+"px"},nw:{width:Math.max(-i+D.w,r)+"px",height:Math.max(-e+D.h,f)+"px",top:a+"px",left:o+"px"},ne:{width:Math.max(i+D.w,r)+"px",height:Math.max(-e+D.h,f)+"px",top:a+"px"},sw:{width:Math.max(-i+D.w,r)+"px",height:Math.max(e+D.h,f)+"px",left:o+"px"}}[t]}(C,s,h);t(i).css(l);var g=function(i,e,o){var n=e+D.w>r?k.w-H+e-R:r-(D.w-k.w)-H-R,s=o+D.h>f?k.h-E+o+R:f-(D.h-k.h)-E+R,h=-e+D.w>r?k.w-H-e-R:r-(D.w-k.w)-H-R,l=-o+D.h>f?k.h-E-o+R:f-(D.h-k.h)-E+R,g=(n>0?t(a).position().left:t(a).position().left<0?t(a).position().left:0)-R,d=(s>0?t(a).position().top:t(a).position().top<0?t(a).position().top:0)+R,m=(h>0?t(a).position().left:t(a).position().left<0?t(a).position().left:0)-R,c=(l>0?t(a).position().top:t(a).position().top<0?t(a).position().top:0)+R;return{e:{left:n>=-R?(n-R)/2+"px":g>n?g+"px":n+"px"},s:{top:s>=R?(s+R)/2+"px":d>s?d+"px":s+"px"},se:{top:s>=R?(s+R)/2+"px":d>s?d+"px":s+"px",left:n>=-R?(n-R)/2+"px":g>n?g+"px":n+"px"},w:{left:h>=-R?(h-R)/2+"px":m>h?m+"px":h+"px"},n:{top:l>=R?(l+R)/2+"px":c>l?c+"px":l+"px"},nw:{top:l>=R?(l+R)/2+"px":c>l?c+"px":l+"px",left:h>=-R?(h-R)/2+"px":m>h?m+"px":h+"px"},ne:{top:l>=R?(l+R)/2+"px":c>l?c+"px":l+"px",left:n>=-R?(n-R)/2+"px":g>n?g+"px":n+"px"},sw:{top:s>=R?(s+R)/2+"px":d>s?d+"px":s+"px",left:h>=-R?(h-R)/2+"px":m>h?m+"px":h+"px"}}[i]}(C,s,h);t(a).css(g)}},W=function(i){g.off(s+l,O).off(h+l,W),c&&o({w:H,h:E},{w:t(e).width(),h:t(e).height()},e),$=!1,c=!1,t("html,body,.magnify-modal,.magnify-stage,.magnify-button").css("cursor","")};t.each(z,function(t,i){i.on(n+l,function(i){S(t,i)})})}})});
\ No newline at end of file
diff --git a/docs/index.html b/docs/index.html
index ba5a80d..546271b 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -857,7 +857,7 @@
Options
Events
- You can define callbacks in callbacks option. In each callback this is the Magnify instance. You can also get the element clicked of plugin's init from arguments of Function.
+ You can define callbacks in callbacks option. In each callback this is the Magnify instance. You can also get the element clicked of plugin's init from arguments el of Function.
},
closed: function(el){
// Will fire after modal is closed
+ },
+ beforeChange: function(index){
+ // Will fire before image is changed
+ // The arguments is the index of image group
+ },
+ changed: function(index){
+ // Will fire after image is changed
+ // The arguments is the index of image group
}
}
});
@@ -923,7 +931,7 @@
Bugs & Contributin
initAnimation: true,
fixedModalPos: false,
zIndex: 1090,
- dragHandle: '',
+ dragHandle: '.magnify-modal',
};
var vm = new Vue({
diff --git a/docs/js/jquery.magnify.js b/docs/js/jquery.magnify.js
index 676b12c..9edb40a 100644
--- a/docs/js/jquery.magnify.js
+++ b/docs/js/jquery.magnify.js
@@ -6,7 +6,7 @@
* | | | | _ | \_/ | |\ |_| |_| | | |
* |__| |__|__| |__|\____/|_|__| \__|_____|__| |__|
*
- * jquery.magnify.js v0.8.1
+ * jquery.magnify.js v1.0.0
*
* A jQuery plugin to view images just like in windows
*
@@ -158,7 +158,7 @@ var $W = $(window),
zIndex: 1090,
// Selector of drag handler
- dragHandle: '',
+ dragHandle: false,
// Callback events
callbacks: {
@@ -383,7 +383,11 @@ Magnify.prototype = {
this.$magnify.css('z-index', zIndex);
// Set handle element of draggable
- this.dragHandle = this.options.dragHandle ? this.$magnify.find(this.options.dragHandle) : this.$magnify;
+ if (!this.options.dragHandle || this.options.dragHandle === '.magnify-modal') {
+ this.dragHandle = this.$magnify;
+ } else {
+ this.dragHandle = this.$magnify.find(this.options.dragHandle);
+ }
},
open: function () {
@@ -409,7 +413,7 @@ Magnify.prototype = {
this.build();
this._triggerHook('beforeOpen', this.$el);
-
+
// Add Magnify to DOM
$('body').append(this.$magnify);
diff --git a/package.json b/package.json
index c028d47..410bc0e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "magnify",
- "version": "0.8.1",
+ "version": "1.0.0",
"description": "A jQuery plugin to view images just like in Windows",
"main": "magnify.js",
"homepage": "https://github.com/nzbin/magnify#readme",
diff --git a/src/js/core.js b/src/js/core.js
index 47efb15..c25a594 100644
--- a/src/js/core.js
+++ b/src/js/core.js
@@ -124,7 +124,7 @@ var $W = $(window),
zIndex: 1090,
// Selector of drag handler
- dragHandle: '',
+ dragHandle: false,
// Callback events
callbacks: {
@@ -349,7 +349,11 @@ Magnify.prototype = {
this.$magnify.css('z-index', zIndex);
// Set handle element of draggable
- this.dragHandle = this.options.dragHandle ? this.$magnify.find(this.options.dragHandle) : this.$magnify;
+ if (!this.options.dragHandle || this.options.dragHandle === '.magnify-modal') {
+ this.dragHandle = this.$magnify;
+ } else {
+ this.dragHandle = this.$magnify.find(this.options.dragHandle);
+ }
},
open: function () {
@@ -375,7 +379,7 @@ Magnify.prototype = {
this.build();
this._triggerHook('beforeOpen', this.$el);
-
+
// Add Magnify to DOM
$('body').append(this.$magnify);
diff --git a/src/js/intro.js b/src/js/intro.js
index f5c1391..7379ee1 100644
--- a/src/js/intro.js
+++ b/src/js/intro.js
@@ -6,7 +6,7 @@
* | | | | _ | \_/ | |\ |_| |_| | | |
* |__| |__|__| |__|\____/|_|__| \__|_____|__| |__|
*
- * jquery.magnify.js v0.8.1
+ * jquery.magnify.js v1.0.0
*
* A jQuery plugin to view images just like in windows
*