/*! * ____ __ ______ __________ _ _____________ ____________ * / __ \/ / / / __ \/_ __/ __ \ | / / _/ ____/ | / / ____/ __ \ * / /_/ / /_/ / / / / / / / / / / | / // // __/ | | /| / / __/ / /_/ / * / ____/ __ / /_/ / / / / /_/ /| |/ // // /___ | |/ |/ / /___/ _, _/ * /_/ /_/ /_/\____/ /_/ \____/ |___/___/_____/ |__/|__/_____/_/ |_| * * photoviewer - v3.6.2 * A JS plugin to view images just like in Windows * https://nzbin.github.io/photoviewer/ * * Copyright (c) 2018 nzbin * Released under MIT License */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).photoviewer=e()}(this,function(){"use strict";function n(t,e){for(var i=0;i]*>/,l=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,c=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,u=/^(?:body|html)$/i,d=["val","css","html","text","data","width","height","offset"],t=y.createElement("table"),f=y.createElement("tr"),p={tr:y.createElement("tbody"),tbody:t,thead:t,tfoot:t,td:f,th:f,"*":y.createElement("div")},g=/^[\w-]*$/,m={},v=m.toString,x=y.createElement("div"),z=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},$=y.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e=e&&e.parentNode;)if(e===t)return!0;return!1};function M(t){return null==t?String(t):m[v.call(t)]||"object"}function T(t){return"function"==M(t)}function C(t){return null!=t&&t==t.window}function L(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function H(t){return"object"==M(t)}function k(t){return H(t)&&!C(t)&&Object.getPrototypeOf(t)==Object.prototype}function D(t){var e=!!t&&"length"in t&&t.length,i=M(t);return"function"!=i&&!C(t)&&("array"==i||0===e||"number"==typeof e&&0")),void 0===e&&(e=h.test(t)&&RegExp.$1),(s=p[e=!(e in p)?"*":e]).innerHTML=""+t,o=w.each(b.call(s.childNodes),function(){s.removeChild(this)})),k(i)&&(n=w(o),w.each(i,function(t,e){-1\n \n ',maximize:'\n \n ',close:'\n \n ',zoomIn:'\n \n ',zoomOut:'\n \n ',prev:'\n \n ',next:'\n \n ',fullscreen:'\n \n ',actualSize:'\n \n ',rotateLeft:'\n \n ',rotateRight:'\n \n '},i18n:{minimize:"minimize",maximize:"maximize",close:"close",zoomIn:"zoom-in (+)",zoomOut:"zoom-out (-)",prev:"prev (←)",next:"next (→)",fullscreen:"fullscreen",actualSize:"actual-size (Ctrl+Alt+0)",rotateLeft:"rotate-left (Ctrl+,)",rotateRight:"rotate-right (Ctrl+.)"},multiInstances:!0,initAnimation:!0,animationDuration:400,fixedModalPos:!1,zIndex:1090,dragHandle:null,callbacks:{beforeOpen:Mt.noop,opened:Mt.noop,beforeClose:Mt.noop,closed:Mt.noop,beforeChange:Mt.noop,changed:Mt.noop},index:0,progressiveLoading:!0,appendTo:"body",customButtons:{},positionFixed:!0,initModalPos:null},Lt=window.document;function Ht(t,e,i,o){var n=o?t.h:t.w,t=o?t.w:t.h;(t>e.h||n>e.w)&&i.addClass("is-grab"),t<=e.h&&n<=e.w&&i.removeClass("is-grab")}function kt(){return"ontouchstart"in window||window.DocumentTouch&&Lt instanceof window.DocumentTouch}function Dt(t){return/^(?:body|html)$/i.test(t.nodeName)}function Vt(i,t){return t.reduce(function(t,e){return t+parseFloat(i.css(e))},0)}function Et(t){return"border-box"===t.css("box-sizing")}var It=Mt(window),Pt=Mt(Lt),_t="click",At="keydown",Rt="wheel mousewheel DOMMouseScroll",St=kt()?"touchstart":"mousedown",Ot=kt()?"touchmove":"mousemove",Ft=kt()?"touchend":"mouseup",Bt="photoviewer",jt="."+Bt,Nt="."+Bt,Yt={isMoving:!1,isResizing:!1,zIndex:0},t={draggable:function(i,t,e){var o=this,n=!1,s=0,a=0,r=0,h=0,l=function(t){var e;(t=t||window.event).preventDefault(),!n||Yt.isMoving||Yt.isResizing||o.isMaximized||(e="touchmove"===t.type?t.targetTouches[0].pageX:t.clientX,t="touchmove"===t.type?t.targetTouches[0].pageY:t.clientY,e=e-s,t=t-a,i.css({left:e+r,top:t+h}))},c=function t(){Pt.off(Ot+Nt,l).off(Ft+Nt,t),n=!1,i[0].focus()};Mt(t).on(St+Nt,function(t){if(t=t||window.event,i[0].blur(),Mt(t.target).closest(e).length)return!0;o.options.multiInstances&&i.css("z-index",++Yt.zIndex),n=!0,s="touchstart"===t.type?t.targetTouches[0].pageX:t.clientX,a="touchstart"===t.type?t.targetTouches[0].pageY:t.clientY,r=parseFloat(i.css("left")),h=parseFloat(i.css("top")),Pt.on(Ot+Nt,l).on(Ft+Nt,c)})}},Xt="html, body, .".concat(Bt,"-modal, .").concat(Bt,"-stage, .").concat(Bt,"-button, .").concat(Bt,"-resizable-handle"),f={movable:function(s,a){function r(){Pt.off(Ot+Nt,v).off(Ft+Nt,r),l=!1,Yt.isMoving=!1,Mt(Xt).removeClass("is-grabbing")}var h=this,l=!1,c=0,u=0,d=0,f=0,p=0,g=0,m=0,v=function(t){var e,i,o;(t=t||window.event).preventDefault(),l&&(i="touchmove"===t.type?t.targetTouches[0].pageX:t.clientX,o="touchmove"===t.type?t.targetTouches[0].pageY:t.clientY,t=(e=i-c)+d,o=(i=o-u)+f,0')),e=Mt('
')),i=Mt('
')),a=Mt('
')),r=Mt('
')),h=Mt('
')),d=Mt('
')),f=Mt('
')),p={e:t,s:i,se:r,n:a,w:e,nw:f,ne:d,sw:h};o.append(t,e,i,a,r,h,d,f);var g=!1,m=0,v=0,w={w:0,h:0,l:0,t:0},y={w:0,h:0,l:0,t:0},b={w:0,h:0,l:0,t:0},x=0,z=0,$=0,M="",T=function(t,e,i){var o=-e+w.w>c?e+w.l:w.l+w.w-c,n=-i+w.h>u?i+w.t:w.t+w.h-u;return{e:{width:Math.max(e+w.w,c)},s:{height:Math.max(i+w.h,u)},se:{width:Math.max(e+w.w,c),height:Math.max(i+w.h,u)},w:{width:Math.max(-e+w.w,c),left:o},n:{height:Math.max(-i+w.h,u),top:n},nw:{width:Math.max(-e+w.w,c),height:Math.max(-i+w.h,u),top:n,left:o},ne:{width:Math.max(e+w.w,c),height:Math.max(-i+w.h,u),top:n},sw:{width:Math.max(-e+w.w,c),height:Math.max(i+w.h,u),left:o}}[t]},C=function(t,e,i){var o=e+w.w>c?y.w-z+e-x:c-(w.w-y.w)-z-x,n=i+w.h>u?y.h-$+i+x:u-(w.h-y.h)-$+x,s=-e+w.w>c?y.w-z-e-x:c-(w.w-y.w)-z-x,a=-i+w.h>u?y.h-$-i+x:u-(w.h-y.h)-$+x,r=(0\n ').concat(o.options.icons[e],"\n "):o.options.customButtons[e]&&(s+='"))}),s}},{key:"_createTitle",value:function(){return this.options.title?'
'):""}},{key:"_createTemplate",value:function(){return'
\n
\n
\n
\n ').concat(this._createBtns(this.options.headerToolbar),"\n
\n ").concat(this._createTitle(),'\n
\n
\n \n
\n \n
\n
")}},{key:"build",value:function(){var t=this._createTemplate(),t=Mt(t);this.$photoviewer=t,this.$stage=t.find(jt+"-stage"),this.$title=t.find(jt+"-title"),this.$image=t.find(jt+"-image"),this.$close=t.find(jt+"-button-close"),this.$maximize=t.find(jt+"-button-maximize"),this.$minimize=t.find(jt+"-button-minimize"),this.$zoomIn=t.find(jt+"-button-zoomIn"),this.$zoomOut=t.find(jt+"-button-zoomOut"),this.$actualSize=t.find(jt+"-button-actualSize"),this.$fullscreen=t.find(jt+"-button-fullscreen"),this.$rotateLeft=t.find(jt+"-button-rotateLeft"),this.$rotateRight=t.find(jt+"-button-rotateRight"),this.$prev=t.find(jt+"-button-prev"),this.$next=t.find(jt+"-button-next"),this.$stage.addClass("stage-ready"),this.$image.addClass("image-ready"),this.$photoviewer.css("z-index",Yt.zIndex),this.options.positionFixed&&this.$photoviewer.css({position:"fixed"}),this.options.dragHandle&&this.options.dragHandle!==jt+"-modal"?this.dragHandle=this.$photoviewer.find(this.options.dragHandle):this.dragHandle=this.$photoviewer,Mt(this.options.appendTo).eq(0).append(this.$photoviewer),this._stageEdgeValue={horizontal:Vt(this.$stage,["left","right","border-left-width","border-right-width"]),vertical:Vt(this.$stage,["top","bottom","border-top-width","border-bottom-width"])},this._modalEdgeValue={horizontal:Vt(this.$photoviewer,["padding-left","padding-right","border-left-width","border-right-width"]),vertical:Vt(this.$photoviewer,["padding-top","padding-bottom","border-top-width","border-bottom-width"])},this._addEvents(),this._addCustomButtonEvents()}},{key:"open",value:function(){this._triggerHook("beforeOpen",this),this.options.multiInstances||Mt(jt+"-modal").eq(0).remove(),this.build(),this.setInitModalPos(),this._triggerHook("opened",this)}},{key:"close",value:function(){this._triggerHook("beforeClose",this),this.$photoviewer.remove(),this.isOpened=!1,this.isMaximized=!1,this.isRotated=!1,this.rotateAngle=0,Mt(jt+"-modal").length||(this.options.multiInstances&&(Yt.zIndex=this.options.zIndex),It.off("resize"+Nt)),this._triggerHook("closed",this)}},{key:"_getOffsetParentData",value:function(){var t=Mt(this.options.appendTo)[0];return{width:this.options.positionFixed||Dt(t)?It.width():t.clientWidth,height:this.options.positionFixed||Dt(t)?It.height():t.clientHeight,scrollLeft:this.options.positionFixed?0:Dt(t)?Pt.scrollLeft():t.scrollLeft,scrollTop:this.options.positionFixed?0:Dt(t)?Pt.scrollTop():t.scrollTop}}},{key:"setModalToCenter",value:function(){var t,e=0,i=0,o=0,n=0,s=0,a=0;Et(this.$photoviewer)||(s+=this._modalEdgeValue.horizontal,a+=this._modalEdgeValue.vertical),Mt.isPlainObject(this.options.initModalPos)?(e=this.options.initModalPos.left,i=this.options.initModalPos.top,o=this.options.initModalPos.right,n=this.options.initModalPos.bottom):(e=((t=this._getOffsetParentData()).width-this.options.modalWidth-s)/2+t.scrollLeft,i=(t.height-this.options.modalHeight-a)/2+t.scrollTop);n={width:this.modalData.width||this.options.modalWidth,height:this.modalData.height||this.options.modalHeight,left:this.modalData.left||e,top:this.modalData.top||i,right:this.modalData.right||o,bottom:this.modalData.bottom||n};this.$photoviewer.css(n)}},{key:"setInitModalPos",value:function(){this.options.initMaximized?(this.maximize(),this.isOpened=!0):this.setModalToCenter(),this.$photoviewer[0].focus()}},{key:"setModalSize",value:function(t){var e=this,i=this._getOffsetParentData(),o=t.width+this._stageEdgeValue.horizontal,n=t.height+this._stageEdgeValue.vertical,s=0,a=0;Et(this.$photoviewer)?(o+=this._modalEdgeValue.horizontal,n+=this._modalEdgeValue.vertical):(s+=this._modalEdgeValue.horizontal,a+=this._modalEdgeValue.vertical);var r=(0')),this.$stage.addClass("stage-ready"),this.$image.addClass("image-ready"),this.options.initAnimation&&!this.options.progressiveLoading&&this.$image.hide(),this.$image.attr("src",t),o=t,n=function(t){r.img=t,r.imageData={originalWidth:t.width,originalHeight:t.height},r.isMaximized||r.isOpened&&r.options.fixedModalPos?r.setImageSize(t):r.setModalSize(t),e&&e.call()},s=function(){r.$photoviewer.find(jt+"-loader").remove(),i&&i.call()},(a=new Image).onload=function(){n(a)},a.onerror=function(){s(a)},a.src=o,this.options.title&&this.setImageTitle(t)}},{key:"setImageTitle",value:function(t){t=this.groupData[this.groupIndex].title||t.replace(/^.*?\/*([^/?]*)\.[a-z]+(\?.+|$)/gi,"$1");this.$title.html(t)}},{key:"jump",value:function(t){this._triggerHook("beforeChange",[this,this.groupIndex]);var e=Date.now();e-this._lastTimestamp>=this.options.animationDuration&&(this.groupIndex=this.groupIndex+t,this.jumpTo(this.groupIndex),this._lastTimestamp=e)}},{key:"jumpTo",value:function(t){var e=this;0<=(t%=this.groupData.length)?t%=this.groupData.length:t<0&&(t=(this.groupData.length+t)%this.groupData.length),this.groupIndex=t,this.loadImage(this.groupData[t].src,function(){e._triggerHook("changed",[e,t])},function(){e._triggerHook("changed",[e,t])})}},{key:"wheel",value:function(t){t.preventDefault();var e=1;t.deltaY?e=0this.options.maxRatio||t