From ebf96b7ae02d16270d7042b2bfbe83bb88c3d840 Mon Sep 17 00:00:00 2001 From: nzbin Date: Tue, 10 Sep 2024 09:49:42 +0800 Subject: [PATCH] chore: release 3.10.3 --- dist/photoviewer.common.js | 5 ++--- dist/photoviewer.css | 2 +- dist/photoviewer.esm.js | 5 ++--- dist/photoviewer.js | 5 ++--- dist/photoviewer.min.css | 2 +- dist/photoviewer.min.js | 4 ++-- docs/css/photoviewer.css | 2 +- docs/js/photoviewer.js | 5 ++--- package.json | 2 +- 9 files changed, 14 insertions(+), 18 deletions(-) diff --git a/dist/photoviewer.common.js b/dist/photoviewer.common.js index cf7513d..97897d8 100644 --- a/dist/photoviewer.common.js +++ b/dist/photoviewer.common.js @@ -5,7 +5,7 @@ * / ____/ __ / /_/ / / / / /_/ /| |/ // // /___ | |/ |/ / /___/ _, _/ * /_/ /_/ /_/\____/ /_/ \____/ |___/___/_____/ |__/|__/_____/_/ |_| * - * photoviewer - v3.10.2 + * photoviewer - v3.10.3 * A JS plugin to view images just like in Windows. * https://nzbin.github.io/photoviewer/ * @@ -1426,7 +1426,6 @@ function debounce(fn, delay) { */ function preloadImage(src, success, error) { var img = new Image(); - img.crossOrigin = 'anonymous'; img.onload = function () { success(img); }; @@ -2064,7 +2063,7 @@ var PhotoViewer = /*#__PURE__*/function () { }, { key: "_createTemplate", value: function _createTemplate() { - var photoviewerHTML = "
\n
\n
\n
\n ").concat(this._createBtns(this.options.headerToolbar), "\n
\n ").concat(this._createTitle(), "\n
\n
\n \"\"\n
\n
\n
\n ").concat(this._createBtns(this.options.footerToolbar), "\n
\n
\n
\n
"); + var photoviewerHTML = "
\n
\n
\n
\n ").concat(this._createBtns(this.options.headerToolbar), "\n
\n ").concat(this._createTitle(), "\n
\n
\n \"\"\n
\n
\n
\n ").concat(this._createBtns(this.options.footerToolbar), "\n
\n
\n
\n
"); return photoviewerHTML.replace(/>\s+<'); } }, { diff --git a/dist/photoviewer.css b/dist/photoviewer.css index 18b2062..cc11b60 100644 --- a/dist/photoviewer.css +++ b/dist/photoviewer.css @@ -5,7 +5,7 @@ * / ____/ __ / /_/ / / / / /_/ /| |/ // // /___ | |/ |/ / /___/ _, _/ * /_/ /_/ /_/\____/ /_/ \____/ |___/___/_____/ |__/|__/_____/_/ |_| * - * photoviewer - v3.10.2 + * photoviewer - v3.10.3 * A JS plugin to view images just like in Windows. * https://nzbin.github.io/photoviewer/ * diff --git a/dist/photoviewer.esm.js b/dist/photoviewer.esm.js index dca2819..309da6c 100644 --- a/dist/photoviewer.esm.js +++ b/dist/photoviewer.esm.js @@ -5,7 +5,7 @@ * / ____/ __ / /_/ / / / / /_/ /| |/ // // /___ | |/ |/ / /___/ _, _/ * /_/ /_/ /_/\____/ /_/ \____/ |___/___/_____/ |__/|__/_____/_/ |_| * - * photoviewer - v3.10.2 + * photoviewer - v3.10.3 * A JS plugin to view images just like in Windows. * https://nzbin.github.io/photoviewer/ * @@ -1424,7 +1424,6 @@ function debounce(fn, delay) { */ function preloadImage(src, success, error) { var img = new Image(); - img.crossOrigin = 'anonymous'; img.onload = function () { success(img); }; @@ -2062,7 +2061,7 @@ var PhotoViewer = /*#__PURE__*/function () { }, { key: "_createTemplate", value: function _createTemplate() { - var photoviewerHTML = "
\n
\n
\n
\n ").concat(this._createBtns(this.options.headerToolbar), "\n
\n ").concat(this._createTitle(), "\n
\n
\n \"\"\n
\n
\n
\n ").concat(this._createBtns(this.options.footerToolbar), "\n
\n
\n
\n
"); + var photoviewerHTML = "
\n
\n
\n
\n ").concat(this._createBtns(this.options.headerToolbar), "\n
\n ").concat(this._createTitle(), "\n
\n
\n \"\"\n
\n
\n
\n ").concat(this._createBtns(this.options.footerToolbar), "\n
\n
\n
\n
"); return photoviewerHTML.replace(/>\s+<'); } }, { diff --git a/dist/photoviewer.js b/dist/photoviewer.js index 14f8d00..8d6a890 100644 --- a/dist/photoviewer.js +++ b/dist/photoviewer.js @@ -5,7 +5,7 @@ * / ____/ __ / /_/ / / / / /_/ /| |/ // // /___ | |/ |/ / /___/ _, _/ * /_/ /_/ /_/\____/ /_/ \____/ |___/___/_____/ |__/|__/_____/_/ |_| * - * photoviewer - v3.10.2 + * photoviewer - v3.10.3 * A JS plugin to view images just like in Windows. * https://nzbin.github.io/photoviewer/ * @@ -1430,7 +1430,6 @@ */ function preloadImage(src, success, error) { var img = new Image(); - img.crossOrigin = 'anonymous'; img.onload = function () { success(img); }; @@ -2068,7 +2067,7 @@ }, { key: "_createTemplate", value: function _createTemplate() { - var photoviewerHTML = "
\n
\n
\n
\n ").concat(this._createBtns(this.options.headerToolbar), "\n
\n ").concat(this._createTitle(), "\n
\n
\n \"\"\n
\n
\n
\n ").concat(this._createBtns(this.options.footerToolbar), "\n
\n
\n
\n
"); + var photoviewerHTML = "
\n
\n
\n
\n ").concat(this._createBtns(this.options.headerToolbar), "\n
\n ").concat(this._createTitle(), "\n
\n
\n \"\"\n
\n
\n
\n ").concat(this._createBtns(this.options.footerToolbar), "\n
\n
\n
\n
"); return photoviewerHTML.replace(/>\s+<'); } }, { diff --git a/dist/photoviewer.min.css b/dist/photoviewer.min.css index 1b6734d..e2cad99 100644 --- a/dist/photoviewer.min.css +++ b/dist/photoviewer.min.css @@ -5,7 +5,7 @@ * / ____/ __ / /_/ / / / / /_/ /| |/ // // /___ | |/ |/ / /___/ _, _/ * /_/ /_/ /_/\____/ /_/ \____/ |___/___/_____/ |__/|__/_____/_/ |_| * - * photoviewer - v3.10.2 + * photoviewer - v3.10.3 * A JS plugin to view images just like in Windows. * https://nzbin.github.io/photoviewer/ * diff --git a/dist/photoviewer.min.js b/dist/photoviewer.min.js index 7bcd870..f90045b 100644 --- a/dist/photoviewer.min.js +++ b/dist/photoviewer.min.js @@ -5,11 +5,11 @@ * / ____/ __ / /_/ / / / / /_/ /| |/ // // /___ | |/ |/ / /___/ _, _/ * /_/ /_/ /_/\____/ /_/ \____/ |___/___/_____/ |__/|__/_____/_/ |_| * - * photoviewer - v3.10.2 + * photoviewer - v3.10.3 * A JS plugin to view images just like in Windows. * https://nzbin.github.io/photoviewer/ * * Copyright (c) 2018-present 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 A(t,e){for(var i=0;i]*>/,Y=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,X=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,q=/^(?:body|html)$/i,Z=["val","css","html","text","data","width","height","offset"],t=w.createElement("table"),W=w.createElement("tr"),U={tr:w.createElement("tbody"),tbody:t,thead:t,tfoot:t,td:W,th:W,"*":w.createElement("div")},K=/^[\w-]*$/,Q={},G=Q.toString,J=w.createElement("div"),l=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},b=w.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):Q[G.call(t)]||"object"}function s(t){return"string"==typeof t}function c(t){return"function"==h(t)}function a(t){return null!=t&&t==t.window}function tt(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function r(t){return"object"==h(t)}function u(t){return r(t)&&!a(t)&&Object.getPrototypeOf(t)==Object.prototype}function et(t){var e=!!t&&"length"in t&&t.length,i=h(t);return"function"!=i&&!a(t)&&("array"==i||0===e||"number"==typeof e&&0")),void 0===e&&(e=N.test(t)&&RegExp.$1),(s=U[e=e in U?e:"*"]).innerHTML=""+t,o=E.each(y.call(s.childNodes),function(){s.removeChild(this)})),u(i)&&(n=E(o),E.each(i,function(t,e){-1{var e=t.e+"."+t.ns.split(" ").join(".");xt(i,e,t.fn,t.sel)})}var n,s,a,r;null!=this.parentNode&&this.parentNode.removeChild(this)})},empty:function(){return this.each(function(){this.innerHTML=""})},html:function(i){return 0 in arguments?this.each(function(t){var e=this.innerHTML;E(this).empty().append(p(this,i,t,e))}):0 in this?this[0].innerHTML:null},width:function(t){return rt.call(this,"width",t)},height:function(t){return rt.call(this,"height",t)},scrollTop:function(t){var e;if(this.length)return e="scrollTop"in this[0],void 0===t?e?this[0].scrollTop:(a(this[0])?this[0]:this[0].defaultView).pageYOffset:this.each(e?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})},scrollLeft:function(t){var e;if(this.length)return e="scrollLeft"in this[0],void 0===t?e?this[0].scrollLeft:(a(this[0])?this[0]:this[0].defaultView).pageXOffset:this.each(e?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})},offset:function(o){var t;return o?this.each(function(t){var e=E(this),t=p(this,o,t,e.offset()),i=e.offsetParent().offset(),t={top:t.top-i.top,left:t.left-i.left};"static"==e.css("position")&&(t.position="relative"),e.css(t)}):this.length?w.documentElement===this[0]||b(w.documentElement,this[0])?{left:(t=this[0].getBoundingClientRect()).left+window.pageXOffset,top:t.top+window.pageYOffset,width:Math.round(t.width),height:Math.round(t.height)}:{top:0,left:0}:null},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||w.body;t&&!q.test(t.nodeName)&&"static"==E(t).css("position");)t=t.offsetParent;return t})},position:function(){var t,e,i,o;if(this.length)return t=this[0],i=this.offsetParent(),o=q.test(i[0].nodeName)?{top:0,left:0}:i.offset(),"fixed"===E(t).css("position")?e=t.getBoundingClientRect():(e=this.offset(),o.top+=parseFloat(E(i[0]).css("border-top-width"))||0,o.left+=parseFloat(E(i[0]).css("border-left-width"))||0),{top:e.top-o.top-parseFloat(E(t).css("margin-top"))||0,left:e.left-o.left-parseFloat(E(t).css("margin-left"))||0}},on:function(u,d,f,p,g){var m,v,i=this;return u&&!s(u)?(E.each(u,function(t,e){i.on(t,d,f,e,g)}),i):(s(d)||c(p)||!1===p||(p=f,f=d,d=void 0),void 0!==p&&!1!==f||(p=f,f=void 0),!1===p&&(p=lt),i.each(function(t,i){var o,e,n,s,a,r,h,l,c;g&&(m=function(t){return xt(i,t.type,p),p.apply(this,arguments)}),e=u,n=p,s=f,r=(v=(a=d)?function(t){var e=E(t.target).closest(d,i).get(0);if(e&&e!==i)return t=E.extend(function(t){var e,i={originalEvent:t};for(e in t)pt.test(e)||void 0===t[e]||(i[e]=t[e]);return mt(i,t)}(t),{currentTarget:e,liveFired:i}),(m||p).apply(e,[t].concat(y.call(arguments,1)))}:v)||m,l=z(o=i),c=x[l]||(x[l]=[]),e.split(/\s/).forEach(function(t){if("ready"==t)return E(w).ready(n);var e=vt(t),i=(e.fn=n,e.sel=a,e.e in ft&&(n=function(t){t=t.relatedTarget;if(!t||t!==this&&!b(this,t))return e.fn.apply(this,arguments)}),(e.del=r)||n);e.proxy=function(t){var e;if(!(t=mt(t)).isImmediatePropagationStopped())return t.data=s,!1===(e=i.apply(o,null==t._args?[t]:[t].concat(t._args)))&&(t.preventDefault(),t.stopPropagation()),e},e.i=c.length,c.push(e),"addEventListener"in o&&o.addEventListener(bt(e.e),e.proxy,yt(e,h))})}))},off:function(t,i,e){var o=this;return t&&!s(t)?(E.each(t,function(t,e){o.off(t,i,e)}),o):(s(i)||c(e)||!1===e||(e=i,i=void 0),!1===e&&(e=lt),o.each(function(){xt(this,t,e,i)}))},show:function(t,e){return Pt.call(this),void 0===t?t=0:this.css("opacity",0),Rt(this,t,1,"1,1",e)},hide:function(t,e){return void 0===t?St.call(this):(i=e,Rt(this,t,0,"0,0",function(){St.call(E(this)),i&&i.call(this)}));var i},anim:function(t,e,i,o,n){var s,a,r,h={},l="",c=this,u=E.fx.transitionEnd,d=!1;if(void 0===e&&(e=E.fx.speeds._default/1e3),void 0===n&&(n=0),E.fx.off&&(e=0),"string"==typeof t)h[Et]=t,h[Ht]=e+"s",h[Vt]=n+"s",h[kt]=i||"linear",u=E.fx.animationEnd;else{for(s in a=[],t)Dt.test(s)?l+=s+"("+t[s]+") ":(h[s]=t[s],a.push(s.replace(/([A-Z])/g,"-$1").toLowerCase()));l&&(h[$t]=l,a.push($t)),0\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,animationEasing:"ease-in-out",fixedModalPos:!1,zIndex:1090,dragHandle:null,callbacks:{beforeOpen:E.noop,opened:E.noop,beforeClose:E.noop,closed:E.noop,beforeChange:E.noop,changed:E.noop},index:0,progressiveLoading:!0,appendTo:"body",customButtons:{},positionFixed:!0,initModalPos:null,errorMsg:""}),It=window.document;function Ot(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 Ft(){return"ontouchstart"in window||window.DocumentTouch&&It instanceof window.DocumentTouch}function $(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 H(t){return"border-box"===t.css("box-sizing")}function jt(t,e,i,o,n){return n?Math.min(i/e,o/t,1):Math.min(i/t,o/e,1)}var C=E(window),k=E(It),L="click",Bt=Ft()?"touchstart":"mousedown",V=Ft()?"touchmove":"mousemove",D=Ft()?"touchend":"mouseup",P="photoviewer",_="."+P,S="."+P,R={isMoving:!1,isResizing:!1,zIndex:0};var Nt="html, body, .".concat(P,"-modal, .").concat(P,"-stage, .").concat(P,"-button, .").concat(P,"-resizable-handle");var Yt="html, body, .".concat(P,"-modal, .").concat(P,"-stage, .").concat(P,"-button");t=function(){function i(t,e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");n(this,"isOpened",!1),n(this,"isMaximized",!1),n(this,"isRotated",!1),n(this,"rotationDegree",0),n(this,"imageData",{}),n(this,"modalData",{width:null,height:null,left:null,top:null}),n(this,"prevIndex",null),n(this,"_lastTimestamp",0),this.init(t,e)}var t,e,o;return t=i,(e=[{key:"init",value:function(t,e){this.options=E.extend(!0,{},At,e),e&&E.isArray(e.footerToolbar)&&(this.options.footerToolbar=e.footerToolbar),e&&E.isArray(e.headerToolbar)&&(this.options.headerToolbar=e.headerToolbar),R.zIndex=(0===R.zIndex?this.options:R).zIndex,this.open(),this.images=t,this.index=this.options.index,this._loadImage(this.index),this.options.draggable&&this.draggable(this.$photoviewer,this.dragHandle,_+"-button"),this.options.movable&&this.movable(this.$stage,this.$image),this.options.resizable&&this.resizable(this.$photoviewer,this.$stage,this.$image,this.options)}},{key:"_createBtns",value:function(t){var o=this,n=["minimize","maximize","close","zoomIn","zoomOut","prev","next","fullscreen","actualSize","rotateLeft","rotateRight"],s="";return E.each(t,function(t,e){var i="".concat(P,"-button ").concat(P,"-button-").concat(e);0<=n.indexOf(e)?s+='"):o.options.customButtons[e]&&(s+='"))}),s}},{key:"_createTitle",value:function(){return this.options.title?'
'):""}},{key:"_createTemplate",value:function(){return'").replace(/>\s+<")}},{key:"_build",value:function(){var t=this._createTemplate(),t=E(t);this.$photoviewer=t,this.$stage=t.find(_+"-stage"),this.$title=t.find(_+"-title"),this.$image=t.find(_+"-image"),this.$close=t.find(_+"-button-close"),this.$maximize=t.find(_+"-button-maximize"),this.$minimize=t.find(_+"-button-minimize"),this.$zoomIn=t.find(_+"-button-zoomIn"),this.$zoomOut=t.find(_+"-button-zoomOut"),this.$actualSize=t.find(_+"-button-actualSize"),this.$fullscreen=t.find(_+"-button-fullscreen"),this.$rotateLeft=t.find(_+"-button-rotateLeft"),this.$rotateRight=t.find(_+"-button-rotateRight"),this.$prev=t.find(_+"-button-prev"),this.$next=t.find(_+"-button-next"),this.$photoviewer.css("z-index",R.zIndex),this.options.positionFixed&&this.$photoviewer.css({position:"fixed"}),this.options.dragHandle&&this.options.dragHandle!==_+"-modal"?this.dragHandle=this.$photoviewer.find(this.options.dragHandle):this.dragHandle=this.$photoviewer,E(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&&0')),this.$stage.addClass(P+"-align-center"),this.options.initAnimation&&!this.options.progressiveLoading&&this.$image.hide(),null==(null==(s=this.images[t])?void 0:s.src)?"":this.images[t].src.toString()),a=(this.$image.attr("src",s),(null==(a=this.images[t])?void 0:a.title)||s.replace(/^.*?\/*([^/?]*)\.[a-z]+(\?.+|$)/gi,"$1"));this.options.title&&this.$title.html(a),this.$image.attr("alt",a),a=s,e=function(t){n.imageData={originalWidth:t.width,originalHeight:t.height},n.isMaximized||n.isOpened&&n.options.fixedModalPos?n._setImageSize():n._setModalSize()},i=function(){n.$photoviewer.find(_+"-loader").remove(),n._triggerHook("changed",[n,t]),n._setErrorMsg()},(o=new Image).crossOrigin="anonymous",o.onload=function(){e(o)},o.onerror=function(){i(o)},o.src=a}},{key:"_setErrorMsg",value:function(){var t=E.isFunction(this.options.errorMsg)?this.options.errorMsg(this,this.index):this.options.errorMsg;t&&(this.$stage.append('').concat(t,"")),this.$image.addClass(P+"-image-error"))}},{key:"_removeErrorMsg",value:function(){this.$stage.find(_+"-error-msg").remove(),this.$image.removeClass(P+"-image-error")}},{key:"jump",value:function(t){var e=Date.now();e-this._lastTimestamp>=this.options.animationDuration&&(t=this.index+t,this.jumpTo(t),this._lastTimestamp=e)}},{key:"jumpTo",value:function(t){this.prevIndex=this.index;t%=this.images.length;t<=0&&(t=(t+this.images.length)%this.images.length),this.index=t,this._loadImage(this.index)}},{key:"_wheel",value:function(t){t.preventDefault();var e=1,e=(t.deltaY?e=0this.options.maxRatio||t')),i=E('
')),n=E('
')),s=E('
')),h=E('
')),c=E('
')),u=E('
')),d=E('
')),f={e:e,s:n,se:h,n:s,w:i,nw:d,ne:u,sw:c},p=(o.append(e,i,n,s,h,c,u,d),0),g=0,m={w:0,h:0,x:0,y:0},v={w:0,h:0,x:0,y:0},w={w:0,h:0,x:0,y:0},y=0,b=0,x=0,z="",M=t.modalWidth,$=t.modalHeight,T=function(t,e,i){var o=-e+m.w>M?e+m.x:m.x+m.w-M,n=-i+m.h>$?i+m.y:m.y+m.h-$;return{e:{width:Math.max(e+m.w,M)},s:{height:Math.max(i+m.h,$)},se:{width:Math.max(e+m.w,M),height:Math.max(i+m.h,$)},w:{width:Math.max(-e+m.w,M),left:o},n:{height:Math.max(-i+m.h,$),top:n},nw:{width:Math.max(-e+m.w,M),height:Math.max(-i+m.h,$),top:n,left:o},ne:{width:Math.max(e+m.w,M),height:Math.max(-i+m.h,$),top:n},sw:{width:Math.max(-e+m.w,M),height:Math.max(i+m.h,$),left:o}}[t]},C=function(t,e,i){var o=e+m.w>M?v.w-b+e-y:M-(m.w-v.w)-b-y,n=i+m.h>$?v.h-x+i+y:$-(m.h-v.h)-x+y,e=-e+m.w>M?v.w-b-e-y:M-(m.w-v.w)-b-y,i=-i+m.h>$?v.h-x-i+y:$-(m.h-v.h)-x+y,s=l.position().left,a=l.position().top,r=(0]*>/,Y=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,X=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,q=/^(?:body|html)$/i,Z=["val","css","html","text","data","width","height","offset"],t=w.createElement("table"),W=w.createElement("tr"),U={tr:w.createElement("tbody"),tbody:t,thead:t,tfoot:t,td:W,th:W,"*":w.createElement("div")},K=/^[\w-]*$/,Q={},G=Q.toString,J=w.createElement("div"),l=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},b=w.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):Q[G.call(t)]||"object"}function s(t){return"string"==typeof t}function c(t){return"function"==h(t)}function a(t){return null!=t&&t==t.window}function tt(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function r(t){return"object"==h(t)}function u(t){return r(t)&&!a(t)&&Object.getPrototypeOf(t)==Object.prototype}function et(t){var e=!!t&&"length"in t&&t.length,i=h(t);return"function"!=i&&!a(t)&&("array"==i||0===e||"number"==typeof e&&0")),void 0===e&&(e=N.test(t)&&RegExp.$1),(s=U[e=e in U?e:"*"]).innerHTML=""+t,o=E.each(y.call(s.childNodes),function(){s.removeChild(this)})),u(i)&&(n=E(o),E.each(i,function(t,e){-1{var e=t.e+"."+t.ns.split(" ").join(".");xt(i,e,t.fn,t.sel)})}var n,s,a,r;null!=this.parentNode&&this.parentNode.removeChild(this)})},empty:function(){return this.each(function(){this.innerHTML=""})},html:function(i){return 0 in arguments?this.each(function(t){var e=this.innerHTML;E(this).empty().append(p(this,i,t,e))}):0 in this?this[0].innerHTML:null},width:function(t){return rt.call(this,"width",t)},height:function(t){return rt.call(this,"height",t)},scrollTop:function(t){var e;if(this.length)return e="scrollTop"in this[0],void 0===t?e?this[0].scrollTop:(a(this[0])?this[0]:this[0].defaultView).pageYOffset:this.each(e?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})},scrollLeft:function(t){var e;if(this.length)return e="scrollLeft"in this[0],void 0===t?e?this[0].scrollLeft:(a(this[0])?this[0]:this[0].defaultView).pageXOffset:this.each(e?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})},offset:function(o){var t;return o?this.each(function(t){var e=E(this),t=p(this,o,t,e.offset()),i=e.offsetParent().offset(),t={top:t.top-i.top,left:t.left-i.left};"static"==e.css("position")&&(t.position="relative"),e.css(t)}):this.length?w.documentElement===this[0]||b(w.documentElement,this[0])?{left:(t=this[0].getBoundingClientRect()).left+window.pageXOffset,top:t.top+window.pageYOffset,width:Math.round(t.width),height:Math.round(t.height)}:{top:0,left:0}:null},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||w.body;t&&!q.test(t.nodeName)&&"static"==E(t).css("position");)t=t.offsetParent;return t})},position:function(){var t,e,i,o;if(this.length)return t=this[0],i=this.offsetParent(),o=q.test(i[0].nodeName)?{top:0,left:0}:i.offset(),"fixed"===E(t).css("position")?e=t.getBoundingClientRect():(e=this.offset(),o.top+=parseFloat(E(i[0]).css("border-top-width"))||0,o.left+=parseFloat(E(i[0]).css("border-left-width"))||0),{top:e.top-o.top-parseFloat(E(t).css("margin-top"))||0,left:e.left-o.left-parseFloat(E(t).css("margin-left"))||0}},on:function(u,d,f,p,g){var m,v,i=this;return u&&!s(u)?(E.each(u,function(t,e){i.on(t,d,f,e,g)}),i):(s(d)||c(p)||!1===p||(p=f,f=d,d=void 0),void 0!==p&&!1!==f||(p=f,f=void 0),!1===p&&(p=lt),i.each(function(t,i){var o,e,n,s,a,r,h,l,c;g&&(m=function(t){return xt(i,t.type,p),p.apply(this,arguments)}),e=u,n=p,s=f,r=(v=(a=d)?function(t){var e=E(t.target).closest(d,i).get(0);if(e&&e!==i)return t=E.extend(function(t){var e,i={originalEvent:t};for(e in t)pt.test(e)||void 0===t[e]||(i[e]=t[e]);return mt(i,t)}(t),{currentTarget:e,liveFired:i}),(m||p).apply(e,[t].concat(y.call(arguments,1)))}:v)||m,l=z(o=i),c=x[l]||(x[l]=[]),e.split(/\s/).forEach(function(t){if("ready"==t)return E(w).ready(n);var e=vt(t),i=(e.fn=n,e.sel=a,e.e in ft&&(n=function(t){t=t.relatedTarget;if(!t||t!==this&&!b(this,t))return e.fn.apply(this,arguments)}),(e.del=r)||n);e.proxy=function(t){var e;if(!(t=mt(t)).isImmediatePropagationStopped())return t.data=s,!1===(e=i.apply(o,null==t._args?[t]:[t].concat(t._args)))&&(t.preventDefault(),t.stopPropagation()),e},e.i=c.length,c.push(e),"addEventListener"in o&&o.addEventListener(bt(e.e),e.proxy,yt(e,h))})}))},off:function(t,i,e){var o=this;return t&&!s(t)?(E.each(t,function(t,e){o.off(t,i,e)}),o):(s(i)||c(e)||!1===e||(e=i,i=void 0),!1===e&&(e=lt),o.each(function(){xt(this,t,e,i)}))},show:function(t,e){return Pt.call(this),void 0===t?t=0:this.css("opacity",0),Rt(this,t,1,"1,1",e)},hide:function(t,e){return void 0===t?St.call(this):(i=e,Rt(this,t,0,"0,0",function(){St.call(E(this)),i&&i.call(this)}));var i},anim:function(t,e,i,o,n){var s,a,r,h={},l="",c=this,u=E.fx.transitionEnd,d=!1;if(void 0===e&&(e=E.fx.speeds._default/1e3),void 0===n&&(n=0),E.fx.off&&(e=0),"string"==typeof t)h[Et]=t,h[Ht]=e+"s",h[Vt]=n+"s",h[kt]=i||"linear",u=E.fx.animationEnd;else{for(s in a=[],t)Dt.test(s)?l+=s+"("+t[s]+") ":(h[s]=t[s],a.push(s.replace(/([A-Z])/g,"-$1").toLowerCase()));l&&(h[$t]=l,a.push($t)),0\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,animationEasing:"ease-in-out",fixedModalPos:!1,zIndex:1090,dragHandle:null,callbacks:{beforeOpen:E.noop,opened:E.noop,beforeClose:E.noop,closed:E.noop,beforeChange:E.noop,changed:E.noop},index:0,progressiveLoading:!0,appendTo:"body",customButtons:{},positionFixed:!0,initModalPos:null,errorMsg:""}),It=window.document;function Ot(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 Ft(){return"ontouchstart"in window||window.DocumentTouch&&It instanceof window.DocumentTouch}function $(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 H(t){return"border-box"===t.css("box-sizing")}function jt(t,e,i,o,n){return n?Math.min(i/e,o/t,1):Math.min(i/t,o/e,1)}var C=E(window),k=E(It),L="click",Bt=Ft()?"touchstart":"mousedown",V=Ft()?"touchmove":"mousemove",D=Ft()?"touchend":"mouseup",P="photoviewer",_="."+P,S="."+P,R={isMoving:!1,isResizing:!1,zIndex:0};var Nt="html, body, .".concat(P,"-modal, .").concat(P,"-stage, .").concat(P,"-button, .").concat(P,"-resizable-handle");var Yt="html, body, .".concat(P,"-modal, .").concat(P,"-stage, .").concat(P,"-button");t=function(){function i(t,e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");n(this,"isOpened",!1),n(this,"isMaximized",!1),n(this,"isRotated",!1),n(this,"rotationDegree",0),n(this,"imageData",{}),n(this,"modalData",{width:null,height:null,left:null,top:null}),n(this,"prevIndex",null),n(this,"_lastTimestamp",0),this.init(t,e)}var t,e,o;return t=i,(e=[{key:"init",value:function(t,e){this.options=E.extend(!0,{},At,e),e&&E.isArray(e.footerToolbar)&&(this.options.footerToolbar=e.footerToolbar),e&&E.isArray(e.headerToolbar)&&(this.options.headerToolbar=e.headerToolbar),R.zIndex=(0===R.zIndex?this.options:R).zIndex,this.open(),this.images=t,this.index=this.options.index,this._loadImage(this.index),this.options.draggable&&this.draggable(this.$photoviewer,this.dragHandle,_+"-button"),this.options.movable&&this.movable(this.$stage,this.$image),this.options.resizable&&this.resizable(this.$photoviewer,this.$stage,this.$image,this.options)}},{key:"_createBtns",value:function(t){var o=this,n=["minimize","maximize","close","zoomIn","zoomOut","prev","next","fullscreen","actualSize","rotateLeft","rotateRight"],s="";return E.each(t,function(t,e){var i="".concat(P,"-button ").concat(P,"-button-").concat(e);0<=n.indexOf(e)?s+='"):o.options.customButtons[e]&&(s+='"))}),s}},{key:"_createTitle",value:function(){return this.options.title?'
'):""}},{key:"_createTemplate",value:function(){return'").replace(/>\s+<")}},{key:"_build",value:function(){var t=this._createTemplate(),t=E(t);this.$photoviewer=t,this.$stage=t.find(_+"-stage"),this.$title=t.find(_+"-title"),this.$image=t.find(_+"-image"),this.$close=t.find(_+"-button-close"),this.$maximize=t.find(_+"-button-maximize"),this.$minimize=t.find(_+"-button-minimize"),this.$zoomIn=t.find(_+"-button-zoomIn"),this.$zoomOut=t.find(_+"-button-zoomOut"),this.$actualSize=t.find(_+"-button-actualSize"),this.$fullscreen=t.find(_+"-button-fullscreen"),this.$rotateLeft=t.find(_+"-button-rotateLeft"),this.$rotateRight=t.find(_+"-button-rotateRight"),this.$prev=t.find(_+"-button-prev"),this.$next=t.find(_+"-button-next"),this.$photoviewer.css("z-index",R.zIndex),this.options.positionFixed&&this.$photoviewer.css({position:"fixed"}),this.options.dragHandle&&this.options.dragHandle!==_+"-modal"?this.dragHandle=this.$photoviewer.find(this.options.dragHandle):this.dragHandle=this.$photoviewer,E(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&&0')),this.$stage.addClass(P+"-align-center"),this.options.initAnimation&&!this.options.progressiveLoading&&this.$image.hide(),null==(null==(s=this.images[t])?void 0:s.src)?"":this.images[t].src.toString()),a=(this.$image.attr("src",s),(null==(a=this.images[t])?void 0:a.title)||s.replace(/^.*?\/*([^/?]*)\.[a-z]+(\?.+|$)/gi,"$1"));this.options.title&&this.$title.html(a),this.$image.attr("alt",a),a=s,e=function(t){n.imageData={originalWidth:t.width,originalHeight:t.height},n.isMaximized||n.isOpened&&n.options.fixedModalPos?n._setImageSize():n._setModalSize()},i=function(){n.$photoviewer.find(_+"-loader").remove(),n._triggerHook("changed",[n,t]),n._setErrorMsg()},(o=new Image).onload=function(){e(o)},o.onerror=function(){i(o)},o.src=a}},{key:"_setErrorMsg",value:function(){var t=E.isFunction(this.options.errorMsg)?this.options.errorMsg(this,this.index):this.options.errorMsg;t&&(this.$stage.append('').concat(t,"")),this.$image.addClass(P+"-image-error"))}},{key:"_removeErrorMsg",value:function(){this.$stage.find(_+"-error-msg").remove(),this.$image.removeClass(P+"-image-error")}},{key:"jump",value:function(t){var e=Date.now();e-this._lastTimestamp>=this.options.animationDuration&&(t=this.index+t,this.jumpTo(t),this._lastTimestamp=e)}},{key:"jumpTo",value:function(t){this.prevIndex=this.index;t%=this.images.length;t<=0&&(t=(t+this.images.length)%this.images.length),this.index=t,this._loadImage(this.index)}},{key:"_wheel",value:function(t){t.preventDefault();var e=1,e=(t.deltaY?e=0this.options.maxRatio||t')),i=E('
')),n=E('
')),s=E('
')),h=E('
')),c=E('
')),u=E('
')),d=E('
')),f={e:e,s:n,se:h,n:s,w:i,nw:d,ne:u,sw:c},p=(o.append(e,i,n,s,h,c,u,d),0),g=0,m={w:0,h:0,x:0,y:0},v={w:0,h:0,x:0,y:0},w={w:0,h:0,x:0,y:0},y=0,b=0,x=0,z="",M=t.modalWidth,$=t.modalHeight,T=function(t,e,i){var o=-e+m.w>M?e+m.x:m.x+m.w-M,n=-i+m.h>$?i+m.y:m.y+m.h-$;return{e:{width:Math.max(e+m.w,M)},s:{height:Math.max(i+m.h,$)},se:{width:Math.max(e+m.w,M),height:Math.max(i+m.h,$)},w:{width:Math.max(-e+m.w,M),left:o},n:{height:Math.max(-i+m.h,$),top:n},nw:{width:Math.max(-e+m.w,M),height:Math.max(-i+m.h,$),top:n,left:o},ne:{width:Math.max(e+m.w,M),height:Math.max(-i+m.h,$),top:n},sw:{width:Math.max(-e+m.w,M),height:Math.max(i+m.h,$),left:o}}[t]},C=function(t,e,i){var o=e+m.w>M?v.w-b+e-y:M-(m.w-v.w)-b-y,n=i+m.h>$?v.h-x+i+y:$-(m.h-v.h)-x+y,e=-e+m.w>M?v.w-b-e-y:M-(m.w-v.w)-b-y,i=-i+m.h>$?v.h-x-i+y:$-(m.h-v.h)-x+y,s=l.position().left,a=l.position().top,r=(0\n
\n
\n
\n ").concat(this._createBtns(this.options.headerToolbar), "\n
\n ").concat(this._createTitle(), "\n
\n
\n \"\"\n
\n
\n
\n ").concat(this._createBtns(this.options.footerToolbar), "\n
\n
\n
\n "); + var photoviewerHTML = "
\n
\n
\n
\n ").concat(this._createBtns(this.options.headerToolbar), "\n
\n ").concat(this._createTitle(), "\n
\n
\n \"\"\n
\n
\n
\n ").concat(this._createBtns(this.options.footerToolbar), "\n
\n
\n
\n
"); return photoviewerHTML.replace(/>\s+<'); } }, { diff --git a/package.json b/package.json index e4e8cf5..8ebfb7d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photoviewer", - "version": "3.10.2", + "version": "3.10.3", "description": "A JS plugin to view images just like in Windows.", "main": "src/js/photoviewer.js", "types": "types/index.d.ts",