/*! * ____ __ ______ __________ _ _____________ ____________ * / __ \/ / / / __ \/_ __/ __ \ | / / _/ ____/ | / / ____/ __ \ * / /_/ / /_/ / / / / / / / / / / | / // // __/ | | /| / / __/ / /_/ / * / ____/ __ / /_/ / / / / /_/ /| |/ // // /___ | |/ |/ / /___/ _, _/ * /_/ /_/ /_/\____/ /_/ \____/ |___/___/_____/ |__/|__/_____/_/ |_| * * photoviewer - v3.7.1 * 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 D(t,e){for(var i=0;i]*>/,N=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,X=/^(?:body|html)$/i,W=["val","css","html","text","data","width","height","offset"],t=y.createElement("table"),e=y.createElement("tr"),q={tr:y.createElement("tbody"),tbody:t,thead:t,tfoot:t,td:e,th:e,"*":y.createElement("div")},Z=/^[\w-]*$/,U={},K=U.toString,Q=y.createElement("div"),l=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},x=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 h(t){return null==t?String(t):U[K.call(t)]||"object"}function c(t){return"function"==h(t)}function n(t){return null!=t&&t==t.window}function G(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function s(t){return"object"==h(t)}function u(t){return s(t)&&!n(t)&&Object.getPrototypeOf(t)==Object.prototype}function J(t){var e=!!t&&"length"in t&&t.length,i=h(t);return"function"!=i&&!n(t)&&("array"==i||0===e||"number"==typeof e&&0")),void 0===e&&(e=B.test(t)&&RegExp.$1),(s=q[e=e in q?e:"*"]).innerHTML=""+t,o=w.each(b.call(s.childNodes),function(){s.removeChild(this)})),u(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 (Alt+X)",close:"Close (Q)",zoomIn:"Zoom-in (+)",zoomOut:"Zoom-out (-)",prev:"Prev (←)",next:"Next (→)",fullscreen:"Fullscreen (F)",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:H.noop,opened:H.noop,beforeClose:H.noop,closed:H.noop,beforeChange:H.noop,changed:H.noop},index:0,progressiveLoading:!0,appendTo:"body",customButtons:{},positionFixed:!0,initModalPos:null}),Rt=window.document;function St(t,e,i,o){var n=o?t.h:t.w,o=o?t.w:t.h;(o>e.h||n>e.w)&&i.addClass("is-grab"),o<=e.h&&n<=e.w&&i.removeClass("is-grab")}function At(){return"ontouchstart"in window||window.DocumentTouch&&Rt instanceof window.DocumentTouch}function v(t){return/^(?:body|html)$/i.test(t.nodeName)}function T(i,t){return t.reduce(function(t,e){return t+parseFloat(i.css(e))},0)}function k(t){return"border-box"===t.css("box-sizing")}var Ot=H(window),V=H(Rt),C="click",Ft="keydown",jt="wheel mousewheel DOMMouseScroll",Bt=At()?"touchstart":"mousedown",E=At()?"touchmove":"mousemove",P=At()?"touchend":"mouseup",I="photoviewer",L="."+I,_="."+I,R={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||R.isMoving||R.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(){V.off(E+_,l).off(P+_,t),n=!1,i[0].focus()};H(t).on(Bt+_,function(t){if(t=t||window.event,i[0].blur(),H(t.target).closest(e).length)return!0;o.options.multiInstances&&i.css("z-index",++R.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")),i.css({left:r,top:h,right:"",bottom:""}),V.on(E+_,l).on(P+_,c)})}},Nt="html, body, .".concat(I,"-modal, .").concat(I,"-stage, .").concat(I,"-button, .").concat(I,"-resizable-handle"),e={movable:function(s,a){function r(){V.off(E+_,v).off(P+_,r),l=!1,R.isMoving=!1,H(Nt).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&&(e="touchmove"===t.type?t.targetTouches[0].pageX:t.clientX,t="touchmove"===t.type?t.targetTouches[0].pageY:t.clientY,i=(e=e-c)+d,o=(t=t-u)+f,0')),e=H('
')),i=H('
')),a=H('
')),r=H('
')),h=H('
')),d=H('
')),f=H('
')),p={e:t,s:i,se:r,n:a,w:e,nw:f,ne:d,sw:h},g=(o.append(t,e,i,a,r,h,d,f),!1),m=0,v=0,w={w:0,h:0,x:0,y:0},y={w:0,h:0,x:0,y:0},b={w:0,h:0,x:0,y:0},x=0,z=0,$=0,M="",T=function(t,e,i){var o=-e+w.w>c?e+w.x:w.x+w.w-c,n=-i+w.h>u?i+w.y:w.y+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,e=-e+w.w>c?y.w-z-e-x:c-(w.w-y.w)-z-x,i=-i+w.h>u?y.h-$-i+x:u-(w.h-y.h)-$+x,s=(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=H(t);this.$photoviewer=t,this.$stage=t.find(L+"-stage"),this.$title=t.find(L+"-title"),this.$image=t.find(L+"-image"),this.$close=t.find(L+"-button-close"),this.$maximize=t.find(L+"-button-maximize"),this.$minimize=t.find(L+"-button-minimize"),this.$zoomIn=t.find(L+"-button-zoomIn"),this.$zoomOut=t.find(L+"-button-zoomOut"),this.$actualSize=t.find(L+"-button-actualSize"),this.$fullscreen=t.find(L+"-button-fullscreen"),this.$rotateLeft=t.find(L+"-button-rotateLeft"),this.$rotateRight=t.find(L+"-button-rotateRight"),this.$prev=t.find(L+"-button-prev"),this.$next=t.find(L+"-button-next"),this.$stage.addClass("stage-ready"),this.$image.addClass("image-ready"),this.$photoviewer.css("z-index",R.zIndex),this.options.positionFixed&&this.$photoviewer.css({position:"fixed"}),this.options.dragHandle&&this.options.dragHandle!==L+"-modal"?this.dragHandle=this.$photoviewer.find(this.options.dragHandle):this.dragHandle=this.$photoviewer,H(this.options.appendTo).eq(0).append(this.$photoviewer),this._stageEdgeValue={horizontal:T(this.$stage,["left","right","border-left-width","border-right-width"]),vertical:T(this.$stage,["top","bottom","border-top-width","border-bottom-width"])},this._modalEdgeValue={horizontal:T(this.$photoviewer,["padding-left","padding-right","border-left-width","border-right-width"]),vertical:T(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||H(L+"-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.rotationDegree=0,H(L+"-modal").length||(this.options.multiInstances&&(R.zIndex=this.options.zIndex),Ot.off("resize"+_)),this._triggerHook("closed",this)}},{key:"_getOffsetParentData",value:function(){var t=H(this.options.appendTo)[0];return{width:this.options.positionFixed||v(t)?Ot.width():t.clientWidth,height:this.options.positionFixed||v(t)?Ot.height():t.clientHeight,scrollLeft:this.options.positionFixed?0:v(t)?V.scrollLeft():t.scrollLeft,scrollTop:this.options.positionFixed?0:v(t)?V.scrollTop():t.scrollTop}}},{key:"setModalToCenter",value:function(){var t,e,i,o,n,s=0,a=0,s=(k(this.$photoviewer)||(s+=this._modalEdgeValue.horizontal,a+=this._modalEdgeValue.vertical),H.isPlainObject(this.options.initModalPos)?(o=this.options.initModalPos.left,n=this.options.initModalPos.top,t=this.options.initModalPos.right,e=this.options.initModalPos.bottom):(o=((i=this._getOffsetParentData()).width-this.options.modalWidth-s)/2+i.scrollLeft,n=(i.height-this.options.modalHeight-a)/2+i.scrollTop),{width:this.modalData.width||this.options.modalWidth,height:this.modalData.height||this.options.modalHeight,left:this.modalData.left||o,top:this.modalData.top||n,right:this.modalData.right||t,bottom:this.modalData.bottom||e});this.$photoviewer.css(s)}},{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,i,o,n,s=this,a=this._getOffsetParentData(),r=t.width+this._stageEdgeValue.horizontal,h=t.height+this._stageEdgeValue.vertical,l=0,c=0,u=(k(this.$photoviewer)?(r+=this._modalEdgeValue.horizontal,h+=this._modalEdgeValue.vertical):(l+=this._modalEdgeValue.horizontal,c+=this._modalEdgeValue.vertical),(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(L+"-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,e=(t.deltaY?e=0this.options.maxRatio||t