@redot-src/glare 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -8
- package/dist/core/animation.d.ts +7 -0
- package/dist/core/bind.d.ts +8 -0
- package/dist/core/dom.d.ts +18 -0
- package/dist/core/glare.d.ts +65 -0
- package/dist/core/idle.d.ts +9 -0
- package/dist/core/interactions.d.ts +3 -0
- package/dist/core/loaders.d.ts +5 -0
- package/dist/core/options.d.ts +5 -0
- package/dist/core/registry.d.ts +9 -0
- package/dist/core/zoom.d.ts +36 -0
- package/dist/defaults.d.ts +5 -5
- package/dist/esm.d.ts +3 -0
- package/dist/glare.css +1 -1
- package/dist/glare.esm.js +1038 -1171
- package/dist/glare.esm.js.map +1 -1
- package/dist/glare.js +25 -23
- package/dist/glare.js.map +1 -1
- package/dist/i18n.d.ts +4 -0
- package/dist/icons.d.ts +12 -13
- package/dist/index.d.ts +5 -7
- package/dist/media/detect.d.ts +4 -0
- package/dist/media/items.d.ts +6 -0
- package/dist/media/providers.d.ts +6 -0
- package/dist/modules/fullscreen.d.ts +15 -0
- package/dist/modules/gestures.d.ts +45 -0
- package/dist/modules/hash.d.ts +22 -0
- package/dist/modules/share.d.ts +17 -0
- package/dist/modules/slideshow.d.ts +25 -0
- package/dist/modules/thumbs.d.ts +22 -0
- package/dist/modules/wheel.d.ts +19 -0
- package/dist/templates.d.ts +7 -0
- package/dist/types.d.ts +117 -131
- package/dist/umd.d.ts +3 -0
- package/dist/utils/dom.d.ts +20 -0
- package/dist/utils/env.d.ts +5 -0
- package/dist/utils/object.d.ts +3 -0
- package/dist/utils/template.d.ts +5 -0
- package/package.json +18 -24
- package/dist/defaults.d.ts.map +0 -1
- package/dist/fullscreen.d.ts +0 -14
- package/dist/fullscreen.d.ts.map +0 -1
- package/dist/gestures.d.ts +0 -24
- package/dist/gestures.d.ts.map +0 -1
- package/dist/hash.d.ts +0 -20
- package/dist/hash.d.ts.map +0 -1
- package/dist/icons.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/instance.d.ts +0 -103
- package/dist/instance.d.ts.map +0 -1
- package/dist/media.d.ts +0 -5
- package/dist/media.d.ts.map +0 -1
- package/dist/share.d.ts +0 -13
- package/dist/share.d.ts.map +0 -1
- package/dist/slideshow.d.ts +0 -19
- package/dist/slideshow.d.ts.map +0 -1
- package/dist/thumbs.d.ts +0 -17
- package/dist/thumbs.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -31
- package/dist/utils.d.ts.map +0 -1
- package/dist/wheel.d.ts +0 -11
- package/dist/wheel.d.ts.map +0 -1
package/dist/glare.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<div class="glare-caption"></div>
|
|
13
|
-
</div>
|
|
1
|
+
(function(T,C){typeof exports=="object"&&typeof module<"u"?module.exports=C():typeof define=="function"&&define.amd?define(C):(T=typeof globalThis<"u"?globalThis:T||self,T.Glare=C())})(this,(function(){"use strict";const T={CLOSE:"Close",NEXT:"Next",PREV:"Previous",ERROR:"The requested content cannot be loaded.<br/>Please try again later.",LOADING:"Loading",LIGHTBOX:"Media lightbox",GO_TO_SLIDE:"Go to slide {{index}}",VIDEO_UNSUPPORTED:"Your browser does not support HTML5 video.",PLAY_START:"Start slideshow",PLAY_STOP:"Pause slideshow",FULL_SCREEN:"Full screen",FULL_SCREEN_EXIT:"Exit full screen",THUMBS:"Thumbnails",DOWNLOAD:"Download",SHARE:"Share",COPY:"Copy link",ZOOM:"Zoom",ZOOM_OUT:"Zoom out"};function C(e){const t=e.lang??"en";return{...T,...e.i18n?.en,...e.i18n?.[t]}}function y(e,t){return e.replace(/\{\{(\w+)\}\}/g,(s,i)=>t[i]??"")}function lt(e){return Object.entries(e).map(([t,s])=>`${encodeURIComponent(t)}=${encodeURIComponent(String(s))}`).join("&")}function ct(e,t){return e.replace(/\$(\d+)/g,(s,i)=>t[Number(i)]??"")}const ht={youtube:{matcher:/(?:youtube\.com|youtu\.be|youtube-nocookie\.com)\/(?:watch\?(?:.*&)?v=|v\/|u\/\w\/|embed\/|shorts\/)?([\w-]{11})/i,type:"iframe",url:"https://www.youtube-nocookie.com/embed/$1",thumb:"https://img.youtube.com/vi/$1/hqdefault.jpg",params:{autoplay:1,rel:0,modestbranding:1,playsinline:1}},vimeo:{matcher:/vimeo\.com\/(?:video\/)?(\d+)/i,type:"iframe",url:"https://player.vimeo.com/video/$1",params:{autoplay:1,title:0,byline:0,portrait:0}},gmap:{matcher:/(?:maps\.)?google\.([a-z]{2,3}(?:\.[a-z]{2})?)\/(?:maps\/(?:place\/[^/]+\/)?@([^/]+)|maps\?q=([^&]+)|maps\/search\/([^/?]+))/i,type:"iframe",url:e=>{const[,t,s,i,o]=e;if(s){const[r,a,l]=s.split(","),f=l?Math.floor(parseFloat(l)):14;return`https://maps.google.${t}/maps?ll=${r},${a}&z=${f}&output=embed`}const n=encodeURIComponent(decodeURIComponent(i||o||""));return`https://maps.google.${t}/maps?q=${n}&output=embed`}}};function U(e,t,s){if(typeof e=="function")return e(t,s);if(typeof e=="string")return ct(e,t)}function ut(e,t){for(const s of Object.values(t??{})){const i=e.match(s.matcher);if(!i)continue;let o=U(s.url,i,e)??e;return s.params&&(o+=(o.includes("?")?"&":"?")+lt(s.params)),{src:o,type:s.type??"iframe",thumb:U(s.thumb,i,e)}}return null}const d=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e}</svg>`,u={close:d('<path d="M18 6 6 18"/><path d="m6 6 12 12"/>'),next:d('<path d="m9 18 6-6-6-6"/>'),prev:d('<path d="m15 18-6-6 6-6"/>'),zoomIn:d('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M11 8v6"/><path d="M8 11h6"/>'),zoomOut:d('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/><path d="M8 11h6"/>'),download:d('<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>'),share:d('<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" x2="15.42" y1="13.51" y2="17.49"/><line x1="15.41" x2="8.59" y1="6.51" y2="10.49"/>'),thumbs:d('<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18"/><path d="M9 21V9"/>'),play:d('<polygon points="6 3 20 12 6 21 6 3"/>'),pause:d('<rect width="4" height="16" x="6" y="4"/><rect width="4" height="16" x="14" y="4"/>'),fullscreen:d('<path d="M8 3H5a2 2 0 0 0-2 2v3"/><path d="M21 8V5a2 2 0 0 0-2-2h-3"/><path d="M3 16v3a2 2 0 0 0 2 2h3"/><path d="M16 21h3a2 2 0 0 0 2-2v-3"/>'),fullscreenExit:d('<path d="M8 3v3a2 2 0 0 1-2 2H3"/><path d="M21 8h-3a2 2 0 0 1-2-2V3"/><path d="M3 16h3a2 2 0 0 1 2 2v3"/><path d="M16 21v-3a2 2 0 0 1 2-2h3"/>')},b=(e,t,s,i="")=>`<button type="button" class="glare-button glare-button--${e}" data-glare-${e} title="{{${t}}}" aria-label="{{${t}}}"${i}>${s}</button>`,dt=`
|
|
2
|
+
<div class="glare-container" role="dialog" aria-modal="true" tabindex="-1">
|
|
3
|
+
<div class="glare-bg"></div>
|
|
4
|
+
<div class="glare-progress" hidden></div>
|
|
5
|
+
<div class="glare-inner">
|
|
6
|
+
<div class="glare-live glare-sr-only" aria-live="polite" aria-atomic="true"></div>
|
|
7
|
+
<div class="glare-infobar"><span class="glare-infobar-index"></span></div>
|
|
8
|
+
<div class="glare-toolbar"></div>
|
|
9
|
+
<div class="glare-navigation">
|
|
10
|
+
${b("prev","PREV",u.prev)}
|
|
11
|
+
${b("next","NEXT",u.next)}
|
|
14
12
|
</div>
|
|
15
|
-
`,btnTpl:{download:`<a class="glare-button glare-button--download" data-glare-download download title="{{DOWNLOAD}}" aria-label="{{DOWNLOAD}}" href="javascript:;">${u.download}</a>`,zoom:`<button type="button" class="glare-button glare-button--zoom" data-glare-zoom title="{{ZOOM}}" aria-label="{{ZOOM}}">${u.zoomIn}</button>`,close:`<button type="button" class="glare-button glare-button--close" data-glare-close title="{{CLOSE}}" aria-label="{{CLOSE}}">${u.close}</button>`,share:`<button type="button" class="glare-button glare-button--share" data-glare-share title="{{SHARE}}" aria-label="{{SHARE}}">${u.share}</button>`,thumbs:`<button type="button" class="glare-button glare-button--thumbs" data-glare-thumbs title="{{THUMBS}}" aria-label="{{THUMBS}}">${u.thumbs}</button>`,slideshow:`<button type="button" class="glare-button glare-button--slideshow" data-glare-slideshow title="{{PLAY_START}}" aria-label="{{PLAY_START}}">${u.play}</button>`,fullscreen:`<button type="button" class="glare-button glare-button--fullscreen" data-glare-fullscreen title="{{FULL_SCREEN}}" aria-label="{{FULL_SCREEN}}">${u.fullscreen}</button>`,smallBtn:`<button type="button" class="glare-button glare-close-small" data-glare-close title="{{CLOSE}}" aria-label="{{CLOSE}}">${u.close}</button>`}};function H(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function C(r,...t){const e={...r};for(const s of t)if(!(!s||typeof s!="object"))for(const[i,n]of Object.entries(s)){if(n===void 0)continue;const o=e[i];H(o)&&H(n)&&!Array.isArray(n)?e[i]=C(o,n):e[i]=n}return e}function g(r,t=document){return t.querySelector(r)}function $(r,t=document){return Array.from(t.querySelectorAll(r))}function w(r,t,e){const s=document.createElement(r);return t&&(s.className=t),e!==void 0&&(s.innerHTML=e),s}function c(r,t,e,s){return r.addEventListener(t,e,s),()=>r.removeEventListener(t,e,s)}function m(r,t){for(const[e,s]of Object.entries(t))s==null?r.style.removeProperty(Y(e)):r.style[e]=String(s)}function Y(r){return r.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function x(r,t,e){return Math.min(e,Math.max(t,r))}function V(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||navigator.maxTouchPoints>1&&window.matchMedia("(pointer: coarse)").matches}function G(){return window.innerWidth-document.documentElement.clientWidth}function Z(r){const t=document.documentElement;if(r){const e=G();t.classList.add("glare-lock"),e>0&&(t.style.marginRight=`${e}px`)}else document.querySelector(".glare-container")||(t.classList.remove("glare-lock"),t.style.marginRight="")}function S(r,t){return r.replace(/\{\{(\w+)\}\}/g,(e,s)=>t[s]??"")}function A(r){return r.getBoundingClientRect()}function B(r){return window.requestAnimationFrame(r)}function M(r){B(()=>B(r))}function I(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function K(r){return Object.entries(r).map(([t,e])=>`${encodeURIComponent(t)}=${encodeURIComponent(String(e))}`).join("&")}function N(r,t){const e=r.x-t.x,s=r.y-t.y;return Math.hypot(e,s)}function Q(r,t){return{x:(r.x+t.x)/2,y:(r.y+t.y)/2}}function P(r){return"touches"in r?Array.from(r.touches).map(t=>({x:t.clientX,y:t.clientY})):[{x:r.clientX,y:r.clientY}]}class J{constructor(t){this.state={isPanning:!1,isSwiping:!1,isZooming:!1,startPoints:[],lastPoints:[],startDistance:0,startScale:1,startTranslate:{x:0,y:0},currentTranslate:{x:0,y:0},scale:1,startTime:0,moved:!1},this.cleanups=[],this.pointerId=null,this.instance=t}attach(t){this.detach(),this.cleanups.push(c(t,"pointerdown",e=>this.onPointerDown(e),{passive:!1}),c(window,"pointermove",e=>this.onPointerMove(e),{passive:!1}),c(window,"pointerup",e=>this.onPointerUp(e)),c(window,"pointercancel",e=>this.onPointerUp(e)),c(t,"touchstart",e=>this.onTouchStart(e),{passive:!1}),c(t,"touchmove",e=>this.onTouchMove(e),{passive:!1}),c(t,"touchend",e=>this.onTouchEnd(e)),c(t,"touchcancel",e=>this.onTouchEnd(e)))}detach(){this.cleanups.forEach(t=>t()),this.cleanups=[]}touchEnabled(){return this.instance.opts.touch!==!1}onPointerDown(t){if(!this.touchEnabled()||t.pointerType==="touch"||t.button!==0||t.target.closest("a, button, input, textarea, select, .glare-thumbs"))return;this.pointerId=t.pointerId;const s=[{x:t.clientX,y:t.clientY}];this.begin(s)}onPointerMove(t){this.pointerId===t.pointerId&&this.move([{x:t.clientX,y:t.clientY}],t)}onPointerUp(t){this.pointerId===t.pointerId&&(this.pointerId=null,this.end([{x:t.clientX,y:t.clientY}]))}onTouchStart(t){!this.touchEnabled()||t.target.closest("a, button, input, textarea, select, .glare-thumbs")||this.begin(P(t))}onTouchMove(t){this.move(P(t),t)}onTouchEnd(t){this.end(P(t))}begin(t){const e=this.instance.getZoomState();this.state={isPanning:!1,isSwiping:!1,isZooming:t.length>=2,startPoints:t,lastPoints:t,startDistance:t.length>=2?N(t[0],t[1]):0,startScale:e.scale,startTranslate:{x:e.x,y:e.y},currentTranslate:{x:e.x,y:e.y},scale:e.scale,startTime:performance.now(),moved:!1}}move(t,e){if(!this.state.startPoints.length)return;const s=this.instance.current;if(!s)return;if(t.length>=2&&this.state.startPoints.length>=2){e.preventDefault(),this.state.isZooming=!0,this.state.moved=!0;const h=N(t[0],t[1]),b=x(h/(this.state.startDistance||h)*this.state.startScale,1,5),y=Q(t[0],t[1]);this.state.scale=b,this.instance.applyZoom(b,y.x,y.y,!1),this.state.lastPoints=t;return}if(!t.length||!this.state.startPoints.length)return;const i=t[0].x-this.state.startPoints[0].x,n=t[0].y-this.state.startPoints[0].y,o=Math.abs(i),a=Math.abs(n);if(!this.state.moved&&o<6&&a<6)return;this.state.moved=!0;const l=this.instance.getZoomState();if(l.scale>1.01&&s.type==="image"||this.state.isPanning){e.preventDefault(),this.state.isPanning=!0;const h=this.state.startTranslate.x+i,b=this.state.startTranslate.y+n;this.state.currentTranslate={x:h,y:b},this.instance.applyZoom(l.scale,h,b,!1)}else{const h=this.instance.opts.touch;if(!(h&&typeof h=="object"?h.vertical!==!1:!0)&&a>o)return;e.preventDefault(),this.state.isSwiping=!0,this.instance.onSwipe(i,n,!1)}this.state.lastPoints=t}end(t){if(!this.state.startPoints.length)return;const e=Math.max(performance.now()-this.state.startTime,1),s=t[0]||this.state.lastPoints[0]||this.state.startPoints[0],i=this.state.startPoints[0],n=s.x-i.x,o=s.y-i.y,a={x:n/e,y:o/e};if(this.state.isSwiping)this.instance.onSwipe(n,o,!0,a);else if(this.state.isPanning){const l=this.instance.opts.touch;if(l&&typeof l=="object"?l.momentum!==!1:!0){const h=this.instance.getZoomState();this.instance.applyZoom(h.scale,this.state.currentTranslate.x+a.x*120,this.state.currentTranslate.y+a.y*120,!0)}}this.state.startPoints=[],this.state.isPanning=!1,this.state.isSwiping=!1,this.state.isZooming=!1}wasMoved(){return this.state.moved}resetMoved(){this.state.moved=!1}}class tt{constructor(t){this.cleanups=[],this.instance=t}init(){this.cleanups.push(c(document,"fullscreenchange",()=>this.sync()),c(document,"webkitfullscreenchange",()=>this.sync()))}isFullscreen(){const t=document;return!!(document.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement)}request(){const t=this.instance.$refs.container||document.documentElement;(t.requestFullscreen||t.webkitRequestFullscreen||t.mozRequestFullScreen||t.msRequestFullscreen)?.call(t)}exit(){const t=document,e=document.exitFullscreen||t.webkitExitFullscreen||t.mozCancelFullScreen||t.msExitFullscreen;this.isFullscreen()&&e?.call(document)}toggle(){this.isFullscreen()?this.exit():this.request()}sync(){const t=this.isFullscreen();this.instance.$refs.container?.classList.toggle("glare-is-fullscreen",t);const e=this.instance.$refs.container?.querySelector("[data-glare-fullscreen]");e&&(e.innerHTML=t?u.fullscreenExit:u.fullscreen,e.classList.toggle("is-active",t))}destroy(){this.isFullscreen()&&this.exit(),this.cleanups.forEach(t=>t()),this.cleanups=[]}}function O(){const r=window.location.hash.replace(/^#/,"");if(!r)return null;const t=r.match(/^(?:glare-)?(.+?)(?:-|\/)(\d+)$/);return t?{gallery:t[1],index:Math.max(0,parseInt(t[2],10)-1)}:null}function et(r,t){return`${r}-${t+1}`}const D=class D{constructor(t,e){this.cleanups=[],this.skipping=!1,this.instance=t,this.gallery=e||"gallery"}init(){this.cleanups.push(c(window,"hashchange",()=>{if(this.skipping)return;const t=O();if(!t||t.gallery!==this.gallery){this.instance.isActive&&this.instance.close();return}t.index!==this.instance.currIndex&&this.instance.jumpTo(t.index)})),this.update()}update(t=this.instance.currIndex){if(!this.gallery)return;const e=et(this.gallery,t);if(window.location.hash.replace(/^#/,"")===e)return;this.skipping=!0;const s=`${window.location.pathname}${window.location.search}#${e}`;window.history.replaceState(null,"",s),queueMicrotask(()=>{this.skipping=!1})}clear(){const t=O();if(t&&t.gallery===this.gallery){this.skipping=!0;const e=`${window.location.pathname}${window.location.search}`;window.history.replaceState(null,"",e),queueMicrotask(()=>{this.skipping=!1})}}destroy(){this.clear(),this.cleanups.forEach(t=>t()),this.cleanups=[]}};D.parse=O;let z=D;const _=/\.(avif|bmp|gif|jpe?g|png|svg|webp|ico)(\?.*)?$/i,U=/\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i,st=/\.pdf(\?.*)?$/i;function W(r,t){return t||(r?r.startsWith("#")||r.startsWith(".")?"inline":_.test(r)?"image":U.test(r)?"video":st.test(r)||/^https?:\/\//i.test(r)||r.startsWith("//")||r.startsWith("/")?"iframe":"html":"html")}function it(r,t){if(!t)return null;for(const e of Object.values(t)){const s=r.match(e.matcher);if(!s)continue;let i=r;if(typeof e.url=="function"?i=e.url(s,r):typeof e.url=="string"&&(i=e.url.replace(/\$(\d+)/g,(o,a)=>s[Number(a)]||"")),e.params){const o=i.includes("?")?"&":"?";i+=o+K(e.params)}let n;return typeof e.thumb=="function"?n=e.thumb(s,r):typeof e.thumb=="string"&&(n=e.thumb.replace(/\$(\d+)/g,(o,a)=>s[Number(a)]||"")),{src:i,type:e.type||"iframe",thumb:n}}return null}function F(r,t,e){const s=typeof r=="string"?{src:r}:{...r};let i=s.src||"",n=s.type,o=s.thumb;s.html&&!i&&(n="html",i="");const a=i?it(i,e.media):null;a&&(i=a.src||i,n=a.type||n,o=o||a.thumb),n||(s.content||s.html?n="html":n=W(i,e.defaultType)),n==="iframe"&&_.test(i)&&(n="image"),n==="iframe"&&U.test(i)&&(n="video");const l={...s,index:t,src:i,type:n,thumb:o,caption:s.caption??s.title??"",isLoaded:!1,isComplete:!1,hasError:!1,canZoomIn:!1,canZoomOut:!1};return s.opts&&(l.opts=C({},e,s.opts)),l}function X(r,t){return r.map((e,s)=>{const i=e.getAttribute("data-src")||e.getAttribute("data-glare-src")||e.getAttribute("href")||"",n=e.getAttribute("data-type")||e.getAttribute("data-glare-type")||void 0,o=e.getAttribute("data-caption")||e.getAttribute("data-glare-caption")||e.getAttribute("title")||"",a=e.getAttribute("data-thumb")||e.getAttribute("data-glare-thumb")||e.querySelector("img")?.getAttribute("src")||void 0,l=e.getAttribute("data-width")||void 0,d=e.getAttribute("data-height")||void 0,h=e.getAttribute("data-poster")||void 0,b=e.getAttribute("data-download-src")||e.getAttribute("data-glare-download")||void 0;let y;const R=e.getAttribute("data-html")||e.getAttribute("data-glare-html");return R&&(y=R),F({src:i,type:n,caption:o,thumb:a,width:l,height:d,poster:h,downloadSrc:b,html:y,alt:e.querySelector("img")?.getAttribute("alt")||o||"",$trigger:e},s,t)})}const nt=`
|
|
16
|
-
<div class="glare-
|
|
17
|
-
|
|
13
|
+
<div class="glare-stage"></div>
|
|
14
|
+
<div class="glare-caption"></div>
|
|
15
|
+
</div>
|
|
16
|
+
</div>`,ft={zoom:b("zoom","ZOOM",u.zoomIn),slideshow:b("slideshow","PLAY_START",u.play),thumbs:b("thumbs","THUMBS",u.thumbs,' aria-expanded="false"'),share:b("share","SHARE",u.share),fullscreen:b("fullscreen","FULL_SCREEN",u.fullscreen),close:b("close","CLOSE",u.close),download:`<a class="glare-button glare-button--download" data-glare-download download target="_blank" rel="noopener" title="{{DOWNLOAD}}" aria-label="{{DOWNLOAD}}">${u.download}</a>`,smallBtn:`<button type="button" class="glare-button glare-close-small" data-glare-close title="{{CLOSE}}" aria-label="{{CLOSE}}">${u.close}</button>`},pt='<div class="glare-spinner" role="status" aria-label="{{LOADING}}"></div>',mt='<div class="glare-error"><p>{{ERROR}}</p></div>',gt='<video class="glare-video" controls playsinline controlsList="nodownload" poster="{{poster}}"><source src="{{src}}" type="{{format}}"/>{{VIDEO_UNSUPPORTED}}</video>',yt='<iframe class="glare-iframe"></iframe>',bt=`
|
|
17
|
+
<div class="glare-share" role="dialog" aria-label="{{SHARE}}">
|
|
18
|
+
<div class="glare-share-head">
|
|
19
|
+
<h4 class="glare-share-title">{{SHARE}}</h4>
|
|
20
|
+
<button type="button" class="glare-button glare-share-close" data-glare-share-close title="{{CLOSE}}" aria-label="{{CLOSE}}">${u.close}</button>
|
|
21
|
+
</div>
|
|
18
22
|
<p><a class="glare-share-link" href="{{url_facebook}}" target="_blank" rel="noopener">Facebook</a></p>
|
|
19
23
|
<p><a class="glare-share-link" href="{{url_twitter}}" target="_blank" rel="noopener">X / Twitter</a></p>
|
|
20
24
|
<p><a class="glare-share-link" href="{{url_pinterest}}" target="_blank" rel="noopener">Pinterest</a></p>
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
`;class rt{constructor(t,e){this.$overlay=null,this.cleanups=[],this.instance=t,this.opts=e===!0?{}:e}open(){const t=this.instance.current;if(!t||!this.instance.$refs.container)return;this.close();const e=this.resolveUrl(t),s=encodeURIComponent(e),i=encodeURIComponent(t.thumb||t.src||e),n=encodeURIComponent(t.caption||""),o=this.instance.opts.lang||"en",a={...this.instance.opts.i18n?.en||{},...this.instance.opts.i18n?.[o]||{},url_direct:e,url_facebook:`https://www.facebook.com/sharer/sharer.php?u=${s}`,url_twitter:`https://twitter.com/intent/tweet?url=${s}&text=${n}`,url_pinterest:`https://pinterest.com/pin/create/button/?url=${s}&media=${i}&description=${n}`},l=S(this.opts.tpl||nt,a);this.$overlay=w("div","glare-share-overlay",l),this.instance.$refs.container.appendChild(this.$overlay),this.$overlay.querySelector(".glare-share-input")?.select(),this.cleanups.push(c(this.$overlay,"click",h=>{h.target===this.$overlay&&this.close()}))}close(){this.cleanups.forEach(t=>t()),this.cleanups=[],this.$overlay?.remove(),this.$overlay=null}resolveUrl(t){return typeof this.opts.url=="function"?this.opts.url(t):typeof this.opts.url=="string"?this.opts.url:t.src&&/^https?:\/\//i.test(t.src)?t.src:window.location.href}destroy(){this.close()}}class ot{constructor(t,e){this.timer=null,this.active=!1,this.instance=t,this.opts=e}init(){this.opts.autoStart&&this.start()}isActive(){return this.active}start(){this.instance.group.length<2||(this.active=!0,this.instance.$refs.container?.classList.add("glare-is-slideshow"),this.updateButton(),this.queue())}stop(){this.active=!1,this.clear(),this.instance.$refs.container?.classList.remove("glare-is-slideshow"),this.updateButton()}toggle(){this.active?this.stop():this.start()}queue(){this.clear(),this.active&&(this.timer=setTimeout(()=>{this.active&&(this.instance.next(),this.queue())},this.opts.speed||3e3))}clear(){this.timer&&(clearTimeout(this.timer),this.timer=null)}updateButton(){const t=this.instance.$refs.container?.querySelector("[data-glare-slideshow]");if(!t)return;const e=this.active?this.getLabel("PLAY_STOP"):this.getLabel("PLAY_START");t.setAttribute("title",e),t.setAttribute("aria-label",e),t.innerHTML=this.active?u.pause:u.play,t.classList.toggle("is-active",this.active)}getLabel(t){const e=this.instance.opts.lang||"en";return{...this.instance.opts.i18n?.en||{},...this.instance.opts.i18n?.[e]||{}}[t]||t}destroy(){this.stop()}}class at{constructor(t,e){this.isActive=!1,this.$container=null,this.$list=null,this.cleanups=[],this.instance=t,this.opts=e}init(){if(this.instance.group.length<2)return;const t=typeof this.opts.parentEl=="string"?g(this.opts.parentEl)||this.instance.$refs.container:this.opts.parentEl||this.instance.$refs.container;if(t){this.$container=w("div",`glare-thumbs glare-thumbs--${this.opts.axis||"y"}`),this.$list=w("div","glare-thumbs-list"),this.$container.appendChild(this.$list);for(const e of this.instance.group){const s=w("button","glare-thumbs-item");if(s.type="button",s.setAttribute("aria-label",`Go to slide ${e.index+1}`),s.dataset.index=String(e.index),e.thumb||e.type==="image"&&e.src){const i=w("img");i.src=e.thumb||e.src,i.alt=e.alt||e.caption||"",i.loading="lazy",s.appendChild(i)}else s.textContent=String(e.index+1);this.$list.appendChild(s),this.cleanups.push(c(s,"click",()=>{this.instance.jumpTo(e.index)}))}t.appendChild(this.$container),this.opts.autoStart&&this.show(),this.focus(this.instance.currIndex)}}show(){this.$container&&(this.isActive=!0,this.$container.classList.add("glare-thumbs--active"),this.instance.$refs.container?.classList.add("glare-show-thumbs"))}hide(){this.$container&&(this.isActive=!1,this.$container.classList.remove("glare-thumbs--active"),this.instance.$refs.container?.classList.remove("glare-show-thumbs"))}toggle(){this.isActive?this.hide():this.show()}focus(t=this.instance.currIndex){if(!this.$list)return;$(".glare-thumbs-item",this.$list).forEach(s=>{s.classList.toggle("is-active",Number(s.dataset.index)===t)}),this.$list.querySelector(".is-active")?.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})}destroy(){this.opts.hideOnClose!==!1&&this.hide(),this.cleanups.forEach(t=>t()),this.cleanups=[],this.$container?.remove(),this.$container=null,this.$list=null}}class lt{constructor(t,e){this.cleanups=[],this.locked=!1,this.instance=t,this.mode=e}init(t){this.mode!==!1&&this.cleanups.push(c(t,"wheel",e=>{const s=e;if(this.locked)return;const i=this.instance.current;i&&(this.mode==="auto"&&i.type!=="image"||i.type==="image"&&this.instance.$refs.container?.classList.contains("glare-can-zoom-out")||(s.preventDefault(),this.locked=!0,s.deltaY>0?this.instance.next():this.instance.prev(),setTimeout(()=>{this.locked=!1},350)))},{passive:!1}))}destroy(){this.cleanups.forEach(t=>t()),this.cleanups=[]}}let ct=0;const f=[];function ht(r){return r?typeof r=="string"?g(r)||document.body:r:document.body}const v=class v{constructor(t,e={},s=0,i=""){this.group=[],this.current=null,this.currIndex=0,this.prevIndex=0,this.isActive=!1,this.isClosing=!1,this.isAnimating=!1,this.isIdle=!1,this.$refs={container:null,stage:null,bg:null,inner:null,caption:null,toolbar:null,infobar:null,navigation:null},this.galleryName="",this.cleanups=[],this.idleTimer=null,this.gestures=null,this.hash=null,this.wheel=null,this.share=null,this.zoom={scale:1,x:0,y:0,min:1,max:5},this.previouslyFocused=null,this.openedFrom=null,this.id=++ct,this.galleryName=i;const n=C({},T,e);V()&&n.mobile?this.opts=C({},n,n.mobile):this.opts=n,t.length&&t[0]instanceof HTMLElement?this.group=X(t,this.opts):this.group=t.map((o,a)=>F(o,a,this.opts)),this.currIndex=x(s,0,Math.max(0,this.group.length-1))}open(t=this.currIndex){if(this.isActive){this.jumpTo(t);return}this.opts.closeExisting&&v.close(!0),this.currIndex=x(t,0,Math.max(0,this.group.length-1)),this.current=this.group[this.currIndex]||null,this.openedFrom=this.current?.$trigger||null,this.previouslyFocused=document.activeElement,this.trigger("onInit"),this.build(),this.isActive=!0,f.push(this),this.opts.hideScrollbar&&Z(!0),this.trigger("onActivate"),this.trigger("beforeShow",this.current||void 0),M(()=>{this.$refs.container?.classList.add("glare-is-open","glare-is-animated"),this.loadSlide(this.currIndex,!0),this.bindEvents(),this.initModules(),this.opts.autoFocus&&this.focus(),this.resetIdle()})}close(t,e){if(!this.isActive||this.isClosing||this.trigger("beforeClose",this.current||void 0)===!1)return;this.isClosing=!0,this.SlideShow?.stop(),this.clearIdle();const s=this.$refs.container,i=e??(I()?0:this.opts.animationDuration||0);s?.classList.add("glare-is-closing"),s?.classList.remove("glare-is-open");const n=()=>{this.teardown()};if(i>0&&s){const o=a=>{a.target===s&&(s.removeEventListener("transitionend",o),n())};s.addEventListener("transitionend",o),setTimeout(n,i+50)}else n()}next(t){this.jumpTo(this.currIndex+1,t)}previous(t){this.jumpTo(this.currIndex-1,t)}prev(t){this.previous(t)}jumpTo(t,e){if(!this.isActive||this.isClosing)return;const s=this.group.length;if(!s)return;let i=t;if(this.opts.loop)i=(t%s+s)%s;else if(i=x(t,0,s-1),i===this.currIndex&&t!==this.currIndex)return;i!==this.currIndex&&(this.prevIndex=this.currIndex,this.currIndex=i,this.current=this.group[i],this.resetZoom(),this.loadSlide(i,!1,e),this.updateChrome(),this.Thumbs?.focus(i),this.hash?.update(i),this.trigger("onUpdate",this.current))}scaleToFit(t=300){this.animateZoom(1,0,0,t),this.$refs.container?.classList.remove("glare-can-zoom-out"),this.$refs.container?.classList.add("glare-can-zoom-in"),this.updateZoomButton()}scaleToActual(t,e,s=300){const i=this.getImageWrap();if(!i)return;const n=A(i),o=t??n.left+n.width/2,a=e??n.top+n.height/2,l=Math.min(this.zoom.max,2.5),d=(n.left+n.width/2-o)*(l-1),h=(n.top+n.height/2-a)*(l-1);this.animateZoom(l,d,h,s),this.$refs.container?.classList.add("glare-can-zoom-out"),this.$refs.container?.classList.remove("glare-can-zoom-in"),this.updateZoomButton()}update(){this.updateChrome(),this.positionContent()}focus(){this.$refs.container?.focus({preventScroll:!0})}toggleControls(t){const e=this.$refs.container;if(!e)return;const s=t===void 0?!e.classList.contains("glare-is-idle"):t;e.classList.toggle("glare-is-idle",s),this.isIdle=s}getContentEl(){return this.current?.$content||null}getImageWrap(){return this.current?.$slide?.querySelector(".glare-content")}getZoomState(){return{...this.zoom}}applyZoom(t,e,s,i=!1){this.animateZoom(t,e,s,i?250:0);const n=t>1.01;this.$refs.container?.classList.toggle("glare-can-zoom-out",n),this.$refs.container?.classList.toggle("glare-can-zoom-in",!n),this.updateZoomButton()}onSwipe(t,e,s,i){const n=this.$refs.stage;if(!n)return;if(!s){if(m(n,{transform:`translate3d(${t}px, ${e}px, 0)`,transitionDuration:"0ms"}),this.$refs.bg){const h=x(1-Math.abs(e)/400,.35,1);m(this.$refs.bg,{opacity:String(h)})}return}const o=Math.abs(t),a=Math.abs(e),l=i?.x||0,d=i?.y||0;if(m(n,{transitionDuration:""}),this.$refs.bg&&m(this.$refs.bg,{opacity:""}),(a>100||Math.abs(d)>.5)&&a>o){this.close();return}(o>80||Math.abs(l)>.4)&&(t<0?this.next():this.prev()),m(n,{transform:""})}build(){const t=this.dict(),e=S(this.opts.baseTpl||"",t),i=w("div","",e).firstElementChild;i.dataset.glareId=String(this.id),this.opts.baseClass&&i.classList.add(this.opts.baseClass),this.opts.modal&&i.classList.add("glare-is-modal"),this.$refs.container=i,this.$refs.bg=g(".glare-bg",i),this.$refs.inner=g(".glare-inner",i),this.$refs.stage=g(".glare-stage",i),this.$refs.caption=g(".glare-caption",i),this.$refs.toolbar=g(".glare-toolbar",i),this.$refs.infobar=g(".glare-infobar",i),this.$refs.navigation=g(".glare-navigation",i),this.buildToolbar(),this.updateChrome(),(!this.opts.arrows||this.group.length<2)&&this.$refs.navigation?.classList.add("glare-hidden"),(!this.opts.infobar||this.group.length<2)&&this.$refs.infobar?.classList.add("glare-hidden"),ht(this.opts.parentEl).appendChild(i)}buildToolbar(){const t=this.$refs.toolbar;if(!t)return;if(!(this.opts.toolbar===!0||this.opts.toolbar==="auto")){t.classList.add("glare-hidden");return}const s=this.dict(),i=this.opts.buttons||[];t.innerHTML="";for(const n of i){if(n==="thumbs"&&this.group.length<2||n==="slideshow"&&this.group.length<2)continue;const o=this.opts.btnTpl?.[n];o&&t.insertAdjacentHTML("beforeend",S(o,s))}}initModules(){const t=this.opts.thumbs;if(t){const s=t===!0?{...T.thumbs}:t;this.Thumbs=new at(this,s),this.Thumbs.init()}const e=this.opts.slideShow;if(e){const s=e===!0?{...T.slideShow}:e;this.SlideShow=new ot(this,s),this.SlideShow.init()}if(this.opts.fullScreen!==!1){this.FullScreen=new tt(this),this.FullScreen.init();const s=this.opts.fullScreen;s&&typeof s=="object"&&s.autoStart&&this.FullScreen.request()}this.opts.share&&(this.share=new rt(this,this.opts.share)),this.opts.hash&&this.galleryName&&(this.hash=new z(this,this.galleryName),this.hash.init()),this.opts.wheel!==!1&&this.$refs.stage&&(this.wheel=new lt(this,this.opts.wheel||"auto"),this.wheel.init(this.$refs.stage)),this.opts.touch!==!1&&this.$refs.stage&&(this.gestures=new J(this),this.gestures.attach(this.$refs.stage))}bindEvents(){const t=this.$refs.container;t&&(this.cleanups.push(c(t,"click",e=>this.onClick(e)),c(t,"dblclick",e=>this.onDblClick(e)),c(document,"keydown",e=>this.onKeydown(e)),c(window,"resize",()=>this.positionContent()),c(window,"orientationchange",()=>this.positionContent()),c(document,"mousemove",()=>this.resetIdle()),c(document,"touchstart",()=>this.resetIdle(),{passive:!0})),this.opts.trapFocus&&this.cleanups.push(c(t,"keydown",e=>{const s=e;if(s.key!=="Tab")return;const i=$('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',t).filter(a=>!a.hasAttribute("disabled")&&a.offsetParent!==null);if(!i.length)return;const n=i[0],o=i[i.length-1];s.shiftKey&&document.activeElement===n?(s.preventDefault(),o.focus()):!s.shiftKey&&document.activeElement===o&&(s.preventDefault(),n.focus())})),this.opts.protect&&this.cleanups.push(c(t,"contextmenu",e=>{e.preventDefault()}),c(t,"dragstart",e=>{e.target.tagName==="IMG"&&e.preventDefault()})))}onClick(t){if(this.gestures?.wasMoved()){this.gestures.resetMoved();return}const e=t.target;if(e.closest("[data-glare-close]")){this.close(t);return}if(e.closest("[data-glare-next]")){this.next();return}if(e.closest("[data-glare-prev]")){this.prev();return}if(e.closest("[data-glare-zoom]")){this.toggleZoom(t);return}if(e.closest("[data-glare-slideshow]")){this.SlideShow?.toggle();return}if(e.closest("[data-glare-thumbs]")){this.Thumbs?.toggle();return}if(e.closest("[data-glare-fullscreen]")){this.FullScreen?.toggle();return}if(e.closest("[data-glare-share]")){this.share?.open();return}if(!e.closest("[data-glare-download]")){if(e.closest(".glare-content")||e.closest(".glare-space")){this.handleClickAction(this.opts.clickContent,t);return}if(e.closest(".glare-slide")){this.handleClickAction(this.opts.clickSlide,t);return}(e.classList.contains("glare-bg")||e.classList.contains("glare-stage"))&&this.handleClickAction(this.opts.clickOutside,t)}}onDblClick(t){const e=t.target;e.closest(".glare-content")||e.closest(".glare-space")?this.handleClickAction(this.opts.dblclickContent,t):e.closest(".glare-slide")?this.handleClickAction(this.opts.dblclickSlide,t):this.handleClickAction(this.opts.dblclickOutside,t)}handleClickAction(t,e){if(!t||!this.current)return;let s=t;switch(typeof t=="function"&&(s=t(this.current,e)),s){case"close":this.close(e);break;case"next":this.next();break;case"nextOrClose":this.currIndex===this.group.length-1&&!this.opts.loop?this.close(e):this.next();break;case"toggleControls":this.toggleControls();break;case"zoom":this.toggleZoom(e);break}}onKeydown(t){if(!this.isActive||!this.opts.keyboard||this.opts.modal||f[f.length-1]!==this)return;const e=t.target?.tagName;if(!(e==="INPUT"||e==="TEXTAREA"||e==="SELECT"))switch(t.key){case"Escape":t.preventDefault(),this.close(t);break;case"ArrowRight":case"ArrowDown":t.preventDefault(),this.next();break;case"ArrowLeft":case"ArrowUp":t.preventDefault(),this.prev();break;case" ":case"Spacebar":t.preventDefault(),this.SlideShow?.toggle();break;case"f":case"F":this.FullScreen?.toggle();break}}loadSlide(t,e,s){const i=this.$refs.stage;if(!i)return;const n=this.group[t];if(!n)return;$(".glare-slide",i).forEach(a=>{Number(a.dataset.index)!==t&&(a.classList.add("glare-slide--out"),setTimeout(()=>a.remove(),this.opts.transitionDuration||366))});let o=i.querySelector(`.glare-slide[data-index="${t}"]`);if(o||(o=w("div",`glare-slide${this.opts.slideClass?` ${this.opts.slideClass}`:""}`),o.dataset.index=String(t),o.innerHTML=`
|
|
24
|
-
|
|
25
|
-
<div class="glare-content"></div>
|
|
26
|
-
</div>
|
|
27
|
-
`,i.appendChild(o)),n.$slide=o,n.$content=g(".glare-content",o),n.pos=t,o.classList.add("glare-slide--current"),o.classList.remove("glare-slide--out"),this.shouldSmallBtn(n)){const a=this.dict();o.querySelector(".glare-close-small")||o.insertAdjacentHTML("beforeend",S(this.opts.btnTpl?.smallBtn||"",a))}this.showSpinner(o),this.trigger("beforeLoad",n),this.resolveContent(n).then(()=>{!this.isActive||this.currIndex!==t||(this.hideSpinner(o),this.trigger("afterLoad",n),this.positionContent(),this.updateChrome(),this.updateDownload(n),e?this.playOpenAnimation(n):this.playTransition(),this.trigger("afterShow",n),this.trigger("onReveal",n))}).catch(()=>{!this.isActive||this.currIndex!==t||(this.hideSpinner(o),this.showError(n))}),this.opts.image?.preload&&[t-1,t+1].forEach(a=>{const l=this.group[a];if(l?.type==="image"&&l.src){const d=new Image;d.src=l.src}})}shouldSmallBtn(t){return this.opts.smallBtn===!0?!0:this.opts.smallBtn===!1?!1:t.type!=="image"}async resolveContent(t){const e=t.$content;if(!e)throw new Error("Missing content node");switch(e.innerHTML="",e.className=`glare-content glare-content--${t.type}`,t.type){case"image":await this.loadImage(t,e);break;case"video":this.loadVideo(t,e);break;case"iframe":await this.loadIframe(t,e);break;case"inline":this.loadInline(t,e);break;case"ajax":await this.loadAjax(t,e);break;default:this.loadHtml(t,e);break}t.isLoaded=!0,t.isComplete=!0}loadImage(t,e){return new Promise((s,i)=>{const n=w("img","glare-image");n.alt=t.alt||t.caption||"",n.decoding="async",n.draggable=!1,this.opts.protect&&(n.style.pointerEvents="none"),n.onload=()=>{t.$image=n,t.contentWidth=n.naturalWidth,t.contentHeight=n.naturalHeight,t.canZoomIn=!0,e.appendChild(n),this.$refs.container?.classList.add("glare-can-zoom-in"),s()},n.onerror=()=>{t.hasError=!0,i(new Error("image error"))},n.src=t.src})}loadVideo(t,e){const s=t.format||this.opts.video?.format||(t.src.match(/\.(\w+)(?:\?|$)/)?.[1]?`video/${t.src.match(/\.(\w+)(?:\?|$)/)?.[1]?.replace("ogv","ogg")}`:"video/mp4"),i=S(this.opts.video?.tpl||"",{src:t.src,format:s,poster:t.poster||""});e.innerHTML=i;const n=e.querySelector("video");t.$content=e,n&&(t.autoStart??this.opts.video?.autoStart)&&n.play().catch(()=>{})}loadIframe(t,e){return new Promise(s=>{const i=w("div","glare-iframe-wrap");i.innerHTML=this.opts.iframe?.tpl||'<iframe class="glare-iframe"></iframe>';const n=i.querySelector("iframe"),o=this.opts.iframe?.attr||{};for(const[a,l]of Object.entries(o))n.setAttribute(a,l);if(this.opts.iframe?.css&&m(n,this.opts.iframe.css),t.width&&m(i,{width:typeof t.width=="number"?`${t.width}px`:String(t.width)}),t.height&&m(i,{height:typeof t.height=="number"?`${t.height}px`:String(t.height)}),e.appendChild(i),this.opts.iframe?.preload===!1){n.src=t.src,s();return}n.onload=()=>s(),n.src=t.src,setTimeout(()=>s(),1200)})}loadInline(t,e){const s=t.src?g(t.src):null;if(!s)throw t.hasError=!0,new Error("inline target missing");const i=s.cloneNode(!0);i.id="",i.classList.remove("glare-hidden"),i.hidden=!1,i.style.display="",e.appendChild(i)}async loadAjax(t,e){const s=this.opts.ajax?.settings||{},i=await fetch(t.src,s);if(!i.ok)throw new Error("ajax failed");const n=await i.text();e.innerHTML=n}loadHtml(t,e){t.content instanceof HTMLElement?e.appendChild(t.content):e.innerHTML=t.html||t.content||t.src||""}showSpinner(t){t.querySelector(".glare-spinner")||t.insertAdjacentHTML("beforeend",this.opts.spinnerTpl||"")}hideSpinner(t){t.querySelector(".glare-spinner")?.remove()}showError(t){t.hasError=!0;const e=t.$content;e&&(e.className="glare-content glare-content--error",e.innerHTML=S(this.opts.errorTpl||"",this.dict()))}playOpenAnimation(t){const e=this.$refs.container;if(!e)return;const s=I()?!1:this.opts.animationEffect;if(e.dataset.animation=s?String(s):"none",e.style.setProperty("--glare-duration",`${this.opts.animationDuration||0}ms`),s==="zoom"&&t.$trigger&&t.type==="image"&&t.$image){const i=A(t.$trigger),n=A(t.$image),o=i.width/Math.max(n.width,1),a=i.height/Math.max(n.height,1),l=i.left+i.width/2-(n.left+n.width/2),d=i.top+i.height/2-(n.top+n.height/2);m(t.$image,{transform:`translate3d(${l}px, ${d}px, 0) scale(${Math.max(o,a)})`,opacity:this.opts.zoomOpacity===!1?"1":"0.2",transitionDuration:"0ms"}),M(()=>{t.$image&&m(t.$image,{transform:"",opacity:"",transitionDuration:`${this.opts.animationDuration||366}ms`})})}M(()=>e.classList.add("glare-is-ready"))}playTransition(){const t=this.$refs.container;if(!t)return;const e=I()?!1:this.opts.transitionEffect;t.dataset.transition=e?String(e):"none",t.style.setProperty("--glare-transition-duration",`${this.opts.transitionDuration||0}ms`)}positionContent(){const t=this.current;if(!t?.$image||!t.contentWidth||!t.contentHeight)return;const e=t.$slide;if(!e)return;const s=g(".glare-space",e);if(!s)return;const i=A(s),n=Math.min(i.width/t.contentWidth,i.height/t.contentHeight,1);t.canZoomIn=n<.98||t.contentWidth>i.width||t.contentHeight>i.height,this.$refs.container?.classList.toggle("glare-can-zoom-in",!!t.canZoomIn&&this.zoom.scale<=1.01)}updateChrome(){const t=this.current;if(!t)return;if(this.$refs.infobar){const i=g(".glare-infobar-index",this.$refs.infobar);i&&(i.textContent=`${this.currIndex+1} / ${this.group.length}`)}if(this.$refs.caption){let i=t.caption||"";typeof this.opts.caption=="function"?i=this.opts.caption(this,t):typeof this.opts.caption=="string"&&(i=this.opts.caption),this.$refs.caption.innerHTML=i,this.$refs.caption.classList.toggle("glare-hidden",!i),this.$refs.container?.classList.toggle("glare-show-caption",!!i)}const e=this.currIndex===0&&!this.opts.loop,s=this.currIndex===this.group.length-1&&!this.opts.loop;this.$refs.container?.querySelector("[data-glare-prev]")?.classList.toggle("glare-disabled",e),this.$refs.container?.querySelector("[data-glare-next]")?.classList.toggle("glare-disabled",s),this.$refs.container?.setAttribute("aria-label",dt(t,this.currIndex,this.group.length))}updateDownload(t){const e=this.$refs.container?.querySelector("[data-glare-download]");if(!e)return;const s=t.downloadSrc||(t.type==="image"?t.src:"");s?(e.href=s,e.classList.remove("glare-hidden")):e.classList.add("glare-hidden")}toggleZoom(t){if(!(!this.current||this.current.type!=="image"))if(this.zoom.scale>1.01)this.scaleToFit();else{const e=t?{x:t.clientX,y:t.clientY}:void 0;this.scaleToActual(e?.x,e?.y)}}animateZoom(t,e,s,i=0){const n=this.getImageWrap(),o=this.current?.$image;!n||!o||(this.zoom.scale=x(t,this.zoom.min,this.zoom.max),this.zoom.x=e,this.zoom.y=s,m(o,{transform:`translate3d(${e}px, ${s}px, 0) scale(${this.zoom.scale})`,transitionDuration:`${i}ms`}))}resetZoom(){this.zoom={scale:1,x:0,y:0,min:1,max:5},this.$refs.container?.classList.remove("glare-can-zoom-out")}updateZoomButton(){const t=this.$refs.container?.querySelector("[data-glare-zoom]");t&&(t.innerHTML=this.zoom.scale>1.01?u.zoomOut:u.zoomIn,t.classList.toggle("is-active",this.zoom.scale>1.01))}resetIdle(){this.clearIdle(),this.isIdle&&this.toggleControls(!1);const t=this.opts.idleTime;!t||this.opts.modal||(this.idleTimer=setTimeout(()=>{this.toggleControls(!0)},t*1e3))}clearIdle(){this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null)}dict(){const t=this.opts.lang||"en";return{...ut,...this.opts.i18n?.en||{},...this.opts.i18n?.[t]||{}}}trigger(t,e,...s){const i=this.opts[t];if(typeof i=="function")return i(this,e,...s)}teardown(){this.gestures?.detach(),this.wheel?.destroy(),this.hash?.destroy(),this.share?.destroy(),this.Thumbs?.destroy(),this.SlideShow?.destroy(),this.FullScreen?.destroy(),this.cleanups.forEach(e=>e()),this.cleanups=[],this.$refs.container?.remove(),this.$refs={container:null,stage:null,bg:null,inner:null,caption:null,toolbar:null,infobar:null,navigation:null};const t=f.indexOf(this);t>=0&&f.splice(t,1),this.opts.hideScrollbar&&Z(!1),this.opts.backFocus&&(this.openedFrom||this.previouslyFocused)?.focus?.({preventScroll:!0}),this.isActive=!1,this.isClosing=!1,this.trigger("afterClose",this.current||void 0),this.trigger("onDeactivate"),this.trigger("onDestroy")}static getInstance(t){return t!=null?f.find(e=>e.id===t)||null:f[f.length-1]||null}static getInstances(){return[...f]}static open(t,e={},s=0){const i=new v(t,e,s);return i.open(s),i}static close(t=!1){if(t){[...f].reverse().forEach(e=>e.close());return}f[f.length-1]?.close()}static destroy(){v.close(!0),L.forEach(t=>t.destroy()),L.length=0}static bind(t,e={}){const s=typeof t=="string"?$(t):t instanceof HTMLElement?[t]:Array.from(t),i=a=>{const l=a.target;if(!l)return;const d=s.find(k=>k===l||k.contains(l));if(!d)return;a.preventDefault();const h=d.getAttribute("data-glare")||d.getAttribute("data-glare")||"",b=h?s.filter(k=>(k.getAttribute("data-glare")||k.getAttribute("data-glare")||"")===h):[d],y=Math.max(0,b.indexOf(d));new v(b,e,y,h||"gallery").open(y)},n=s.map(a=>c(a,"click",i)),o={selector:typeof t=="string"?t:"",options:e,elements:s,destroy:()=>{n.forEach(l=>l());const a=L.indexOf(o);a>=0&&L.splice(a,1)}};return L.push(o),o}static fromSelector(t,e={}){const s=$(t);if(!s.length)return null;const i=new v(s,e,0,"gallery");return i.open(0),i}};v.defaults=T;let E=v;const L=[],ut={CLOSE:"Close",NEXT:"Next",PREV:"Previous",ERROR:"The requested content cannot be loaded.<br/>Please try again later.",PLAY_START:"Start slideshow",PLAY_STOP:"Pause slideshow",FULL_SCREEN:"Full screen",THUMBS:"Thumbnails",DOWNLOAD:"Download",SHARE:"Share",ZOOM:"Zoom"};function dt(r,t,e){const s=r.caption||r.alt||"Media lightbox";return e>1?`${s} (${t+1} of ${e})`:s}function pt(){if(typeof document>"u")return;const r=()=>{$("[data-glare], [data-glare]").length&&E.bind("[data-glare], [data-glare]")};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",r,{once:!0}):r()}p.Glare=E,p.autoBind=pt,p.default=E,p.defaultMedia=q,p.defaults=T,p.detectType=W,p.i18nEn=j,p.itemsFromElements=X,p.normalizeItem=F,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
|
25
|
+
<div class="glare-share-row">
|
|
26
|
+
<input class="glare-share-input" type="text" value="{{url_direct}}" readonly />
|
|
27
|
+
<button type="button" class="glare-share-copy" data-glare-share-copy>{{COPY}}</button>
|
|
28
|
+
</div>
|
|
29
|
+
</div>`,j={autoStart:!1,axis:"x"},D={autoStart:!1,speed:3e3},q={autoStart:!1},B={closeExisting:!1,loop:!1,keyboard:!0,protect:!1,modal:!1,idleTime:3,hideScrollbar:!0,autoFocus:!0,backFocus:!0,trapFocus:!0,defaultType:"image",parentEl:"body",baseClass:"",slideClass:"",arrows:!0,infobar:!0,toolbar:"auto",smallBtn:"auto",buttons:["zoom","slideshow","thumbs","share","download","fullscreen","close"],animationEffect:"zoom",animationDuration:366,zoomOpacity:!0,transitionEffect:"fade",transitionDuration:366,clickContent:e=>e.type==="image"?"zoom":!1,clickSlide:"close",dblclickContent:!1,dblclickSlide:!1,wheel:"auto",touch:{vertical:!0,momentum:!0},mobile:{idleTime:!1,clickContent:e=>e.type==="image"?"toggleControls":!1,clickSlide:e=>e.type==="image"?"toggleControls":"close",dblclickContent:e=>e.type==="image"?"zoom":!1,dblclickSlide:e=>e.type==="image"?"zoom":!1},image:{preload:!1},video:{tpl:gt,format:"",autoStart:!0},iframe:{preload:!0,css:{},attr:{allowfullscreen:"true",allow:"autoplay; fullscreen; picture-in-picture"},tpl:yt},ajax:{settings:{headers:{"X-Requested-With":"XMLHttpRequest"}}},media:ht,hash:!0,slideshow:D,thumbs:j,fullscreen:q,share:!0,lang:"en",i18n:{en:T},baseTpl:dt,btnTpl:ft,spinnerTpl:pt,errorTpl:mt},vt=/\.(avif|bmp|gif|jpe?g|png|svg|webp|ico)(\?.*)?$/i,wt=/\.(mp4|webm|ogg|ogv|mov|m4v)(\?.*)?$/i,xt=/\.pdf(\?.*)?$/i,Et=/^(#[\w-]+|\.[\w-]+)$/;function St(e,t="image"){return e?Et.test(e)?"inline":vt.test(e)?"image":wt.test(e)?"video":xt.test(e)?"iframe":t:"html"}function Tt(e){const t=e.match(/\.(\w+)(?:\?|$)/)?.[1]?.toLowerCase();return t?`video/${t==="ogv"?"ogg":t}`:"video/mp4"}function W(e,t,s){const i=typeof e=="string"?{src:e}:{...e};let o=i.src??"",n=i.type,r=i.thumb;const a=o?ut(o,s.media):null;return a&&(o=a.src??o,n??=a.type,r??=a.thumb),n||(n=i.html||i.content?"html":St(o,s.defaultType)),{...i,index:t,src:o,type:n,thumb:r,caption:i.caption??i.title??"",isLoaded:!1,hasError:!1}}const p=(e,t)=>e.getAttribute(t)||void 0;function Lt(e,t){return e.map((s,i)=>{const o=s.querySelector("img"),n=p(s,"data-caption")??p(s,"title")??"";return W({src:p(s,"data-src")??p(s,"href")??"",type:p(s,"data-type"),caption:n,alt:o?.getAttribute("alt")||n,thumb:p(s,"data-thumb")??o?.getAttribute("src")??void 0,width:p(s,"data-width"),height:p(s,"data-height"),poster:p(s,"data-poster"),downloadSrc:p(s,"data-download-src"),html:p(s,"data-html"),$trigger:s},i,t)})}function Ct(e,t){return e.length&&e[0]instanceof HTMLElement?Lt(e,t):e.map((s,i)=>W(s,i,t))}function c(e,t=document){return t.querySelector(e)}function $(e,t=document){return Array.from(t.querySelectorAll(e))}function m(e,t="",s=""){const i=document.createElement(e);return t&&(i.className=t),s&&(i.innerHTML=s),i}function $t(e){return m("div","",e.trim()).firstElementChild}function M(e){return/[<&]/.test(e)?new DOMParser().parseFromString(e,"text/html").body.textContent?.trim()??"":e.trim()}function Mt(e,t=document){return e?typeof e!="string"?e:c(e,t)??c(e):null}function X(e){return typeof e=="number"?`${e}px`:e}function h(e,t,s,i){return e.addEventListener(t,s,i),()=>e.removeEventListener(t,s,i)}function Y(e){requestAnimationFrame(()=>requestAnimationFrame(e))}function Ot(e,t,s){let i=!1;const o=()=>{i||(i=!0,clearTimeout(r),e.removeEventListener("transitionend",n),s())},n=a=>{a.target===e&&o()};e.addEventListener("transitionend",n);const r=setTimeout(o,t+50)}function It(){return navigator.maxTouchPoints>0&&window.matchMedia("(pointer: coarse)").matches}function O(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}function G(){const e=document;return!!(e.fullscreenEnabled??e.webkitFullscreenEnabled)}const V="glare-lock";function K(e){const t=document.documentElement;if(e){const s=window.innerWidth-t.clientWidth;t.classList.add(V),s>0&&(t.style.marginRight=`${s}px`)}else t.classList.remove(V),t.style.marginRight=""}const E="glare-hidden";function At(e,t,s,i){const o=$t(y(e.baseTpl,t));o.dataset.glareId=String(s),e.baseClass&&o.classList.add(e.baseClass),e.modal&&o.classList.add("glare-is-modal");const n=c(".glare-stage",o);if(!n)throw new Error("baseTpl must contain a .glare-stage element");const r={container:o,bg:c(".glare-bg",o),inner:c(".glare-inner",o),stage:n,caption:c(".glare-caption",o),toolbar:c(".glare-toolbar",o),infobar:c(".glare-infobar",o),navigation:c(".glare-navigation",o)},a=i<2;return r.navigation?.classList.toggle(E,!e.arrows||a),r.infobar?.classList.toggle(E,!e.infobar||a),r.toolbar&&Dt(r.toolbar,e,t,a),r}function Dt(e,t,s,i){if(t.toolbar===!1){e.classList.add(E);return}for(const o of t.buttons){if(i&&(o==="thumbs"||o==="slideshow")||o==="fullscreen"&&!G())continue;const n=t.btnTpl[o];n&&e.insertAdjacentHTML("beforeend",y(n,s))}}function kt(e,t,s){const i=m("div",`glare-slide glare-slide--${t.type}`);s.slideClass&&i.classList.add(s.slideClass);const o=m("div","glare-content");return i.appendChild(o),e.appendChild(i),t.$slide=i,t.$content=o,i}function _t(e,t){t&&(e.style.transition="none"),e.offsetWidth,e.classList.add("glare-slide--current"),t&&(e.offsetWidth,e.style.transition="")}function Ht(e,t,s){for(const i of $(".glare-slide",e))i!==t&&(i.classList.remove("glare-slide--current"),i.classList.add("glare-slide--out"),setTimeout(()=>i.remove(),s))}function Rt(e,t,s){e.insertAdjacentHTML("beforeend",y(t.btnTpl.smallBtn??"",s))}function Ft(e,t,s){e.querySelector(":scope > .glare-spinner")||e.insertAdjacentHTML("beforeend",y(t.spinnerTpl,s))}function Pt(e){e.querySelector(":scope > .glare-spinner")?.remove()}function zt(e,t,s,i){e.hasError=!0,e.error=t,e.$content&&(e.$content.className="glare-content glare-content--error",e.$content.innerHTML=y(s.errorTpl,i))}function Q(e,t){return typeof e.toolbar=="boolean"?e.toolbar:t.type==="image"}function Nt(e,t){return typeof e.smallBtn=="boolean"?e.smallBtn:!Q(e,t)}function Zt(e,t,s,i,o,n){const{container:r,toolbar:a,infobar:l}=e;Yt(r,i.type),a&&Ut(a,t,i),jt(r,i),l&&qt(l,i.index,o),e.caption&&Bt(e.caption,n),Wt(r,t,i.index,o),Xt(r,s,i,o)}function Ut(e,t,s){if(t.toolbar===!1)return;const i=Q(t,s);if(e.classList.toggle(E,!i),!i)return;const o=s.type==="image";c("[data-glare-zoom]",e)?.classList.toggle(E,!o)}function jt(e,t){const s=e.querySelector("[data-glare-download]");if(!s)return;const i=t.downloadSrc||(t.type==="image"?t.src:"");s.classList.toggle(E,!i),i&&(s.href=i)}function qt(e,t,s){const i=c(".glare-infobar-index",e);i&&(i.textContent=`${t+1} / ${s}`)}function Bt(e,t){e.innerHTML=t,e.classList.toggle(E,!t)}function Wt(e,t,s,i){const o=!t.loop&&s===0,n=!t.loop&&s===i-1;J(c("[data-glare-prev]",e),o),J(c("[data-glare-next]",e),n)}function J(e,t){e&&(e.classList.toggle("glare-is-disabled",t),e.setAttribute("aria-disabled",String(t)))}function Xt(e,t,s,i){const o=M(s.caption)||s.alt||t.LIGHTBOX,n=i>1?`${o} (${s.index+1} of ${i})`:o;e.setAttribute("aria-label",n);const r=c(".glare-live",e);r&&(r.textContent=n)}function Yt(e,t){const s=e.dataset.type;s&&e.classList.remove(`glare-type-${s}`),e.dataset.type=t,e.classList.add(`glare-type-${t}`)}function Gt(e,t,s,i){e.classList.toggle("glare-can-zoom-out",s),e.classList.toggle("glare-can-zoom-in",!s&&i);const o=c("[data-glare-zoom]",e),n=s?"out":"in";!o||o.dataset.state===n||(o.dataset.state=n,k(o,s,s?t.ZOOM_OUT:t.ZOOM,s?u.zoomOut:u.zoomIn))}function k(e,t,s,i){e.setAttribute("title",s),e.setAttribute("aria-label",s),e.innerHTML=i,e.classList.toggle("glare-is-active",t)}class Vt{constructor(t,s,i){this.glare=t,this.container=s,this.offs=[h(document,"fullscreenchange",()=>this.sync()),h(document,"webkitfullscreenchange",()=>this.sync())],i.autoStart&&this.request()}isFullscreen(){const t=document;return!!(t.fullscreenElement??t.webkitFullscreenElement)}request(){const t=this.container;(t.requestFullscreen??t.webkitRequestFullscreen)?.call(t)}exit(){if(!this.isFullscreen())return;const t=document;(t.exitFullscreen??t.webkitExitFullscreen)?.call(document)}toggle(){this.isFullscreen()?this.exit():this.request()}destroy(){this.exit(),this.offs.forEach(t=>t())}sync(){const t=this.isFullscreen();this.container.classList.toggle("glare-is-fullscreen",t);const s=c("[data-glare-fullscreen]",this.container);if(!s)return;const{dict:i}=this.glare;k(s,t,t?i.FULL_SCREEN_EXIT:i.FULL_SCREEN,t?u.fullscreenExit:u.fullscreen)}}function tt(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function _(...e){const t={};for(const s of e)if(s)for(const[i,o]of Object.entries(s)){if(o===void 0)continue;const n=t[i];t[i]=tt(o)?_(tt(n)?n:{},o):o}return t}function v(e,t,s){return Math.min(s,Math.max(t,e))}const L=1,H=5,Kt=1.01;class Qt{constructor(t){this.target=t,this.scale=L,this.x=0,this.y=0}get isZoomed(){return this.scale>Kt}get state(){return{scale:this.scale,x:this.x,y:this.y}}center(){const t=this.target.image();if(!t)return null;const s=t.getBoundingClientRect();return{x:s.left+s.width/2-this.x,y:s.top+s.height/2-this.y}}apply(t,s,i,o=0){const n=this.target.image();if(!n)return;this.scale=v(t,L,H);const r=this.isZoomed?this.bounded(s,i):{x:0,y:0};this.x=r.x,this.y=r.y,n.style.transitionDuration=`${o}ms`,n.style.transform=`translate3d(${this.x}px, ${this.y}px, 0) scale(${this.scale})`,this.target.onChange(this.isZoomed)}toFit(t=300){this.apply(L,0,0,t)}toActual(t,s=300){const i=this.target.image(),o=this.center();if(!i||!o)return;const n=i.naturalWidth/Math.max(i.offsetWidth,1),r=v(Math.max(n,1.5),L,H),a=t?.x??o.x,l=t?.y??o.y;this.apply(r,(o.x-a)*(r-1),(o.y-l)*(r-1),s)}reset(){const t=this.target.image();t&&(t.style.transform="",t.style.transitionDuration=""),this.scale=L,this.x=0,this.y=0,this.target.onChange(!1)}bounded(t,s){const i=this.target.image(),o=this.target.stage();if(!i||!o)return{x:t,y:s};const n=Math.max(0,(i.offsetWidth*this.scale-o.clientWidth)/2),r=Math.max(0,(i.offsetHeight*this.scale-o.clientHeight)/2);return{x:v(t,-n,n),y:v(s,-r,r)}}}const Jt=6,et=120,te=100,ee=.5,se=80,ie=.4,oe="a, button, input, textarea, select, video, .glare-thumbs",st=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),it=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),R=e=>({x:e.clientX,y:e.clientY});class ne{constructor(t,s){this.stage=t,this.host=s,this.pointers=new Map,this.mode="idle",this.moved=!1,this.start=[],this.startTime=0,this.startZoom={scale:1,x:0,y:0},this.startMid={x:0,y:0},this.startDistance=0,this.offs=[h(t,"pointerdown",i=>this.onDown(i)),h(window,"pointermove",i=>this.onMove(i),{passive:!1}),h(window,"pointerup",i=>this.onUp(i)),h(window,"pointercancel",i=>this.onUp(i))]}destroy(){this.offs.forEach(t=>t()),this.pointers.clear()}consumeMoved(){const t=this.moved;return this.moved=!1,t}onDown(t){t.pointerType==="mouse"&&t.button!==0||t.target.closest(oe)||(this.pointers.set(t.pointerId,R(t)),this.pointers.size<=2&&this.begin())}onMove(t){this.pointers.has(t.pointerId)&&(this.pointers.set(t.pointerId,R(t)),this.move(t))}onUp(t){this.pointers.has(t.pointerId)&&(this.pointers.delete(t.pointerId),this.pointers.size===0?this.end(R(t)):this.begin())}begin(){this.mode==="swipe"&&this.releaseStage();const t=[...this.pointers.values()];this.start=t,this.startTime=performance.now(),this.startZoom=this.host.zoom.state,this.mode=t.length>=2?"pinch":"idle",t.length>=2&&(this.startDistance=st(t[0],t[1]),this.startMid=it(t[0],t[1]))}move(t){const s=[...this.pointers.values()];if(!this.start.length||!s.length)return;if(this.mode==="pinch"&&s.length>=2){t.preventDefault(),this.moved=!0,this.pinch(s[0],s[1]);return}const i=s[0].x-this.start[0].x,o=s[0].y-this.start[0].y;if(!(!this.moved&&Math.hypot(i,o)<Jt)){if(this.moved=!0,this.mode==="idle"&&(this.mode=this.host.zoom.isZoomed&&this.host.canPan()?"pan":"swipe"),this.mode==="pan")t.preventDefault(),this.host.zoom.apply(this.startZoom.scale,this.startZoom.x+i,this.startZoom.y+o);else if(this.mode==="swipe"){const n=this.host.touch.vertical!==!1;if(!n&&Math.abs(o)>Math.abs(i))return;t.preventDefault(),this.dragStage(i,n?o:0)}}}pinch(t,s){const{zoom:i}=this.host,o=it(t,s),n=i.center()??o,r=v(this.startZoom.scale*st(t,s)/(this.startDistance||1),L,H),a=(this.startMid.x-n.x-this.startZoom.x)/this.startZoom.scale,l=(this.startMid.y-n.y-this.startZoom.y)/this.startZoom.scale;i.apply(r,o.x-n.x-r*a,o.y-n.y-r*l)}end(t){if(!this.start.length)return;const s=Math.max(performance.now()-this.startTime,1),i=t.x-this.start[0].x,o=t.y-this.start[0].y,n={x:i/s,y:o/s};if(this.mode==="swipe")this.releaseStage(),this.finishSwipe(i,o,n);else if(this.mode==="pan"&&this.host.touch.momentum!==!1){const{zoom:r}=this.host;r.apply(r.scale,r.x+n.x*et,r.y+n.y*et,250)}this.mode="idle",this.start=[],this.moved&&setTimeout(()=>this.moved=!1,0)}dragStage(t,s){this.stage.style.transitionDuration="0ms",this.stage.style.transform=`translate3d(${t}px, ${s}px, 0)`;const{bg:i}=this.host;i&&(i.style.transitionDuration="0ms",i.style.opacity=String(v(1-Math.abs(s)/400,.35,1)))}releaseStage(){this.stage.style.transitionDuration="",this.stage.style.transform="";const{bg:t}=this.host;t&&(t.style.transitionDuration="",t.style.opacity="")}finishSwipe(t,s,i){if(Math.abs(s)>Math.abs(t)){(Math.abs(s)>te||Math.abs(i.y)>ee)&&this.host.close();return}(Math.abs(t)>se||Math.abs(i.x)>ie)&&(t<0?this.host.next():this.host.prev())}}const re=/^(.+)-(\d+)$/;function F(e=window.location.hash){const t=e.replace(/^#/,"").match(re);return t?{gallery:t[1],index:Math.max(0,parseInt(t[2],10)-1)}:null}function ot(e,t){return`${e}-${t+1}`}class ae{constructor(t,s){this.glare=t,this.gallery=s,this.pushed=!1,this.off=h(window,"hashchange",()=>this.onHashChange());const i=ot(s,t.currIndex);nt()!==i&&(window.history.pushState(null,"",`#${i}`),this.pushed=!0)}update(t=this.glare.currIndex){const s=ot(this.gallery,t);nt()!==s&&this.replace(`#${s}`)}destroy(){this.off(),F()?.gallery===this.gallery&&(this.pushed?window.history.back():this.replace(""))}onHashChange(){const t=F();!t||t.gallery!==this.gallery?(this.pushed=!1,this.glare.close()):t.index!==this.glare.currIndex&&this.glare.jumpTo(t.index)}replace(t){const{pathname:s,search:i}=window.location;window.history.replaceState(null,"",`${s}${i}${t}`)}}const nt=()=>window.location.hash.replace(/^#/,"");class le{constructor(t,s,i){this.glare=t,this.container=s,this.opts=i,this.overlay=null,this.off=null}get isOpen(){return this.overlay!==null}open(){const{current:t,dict:s}=this.glare;if(!t)return;this.close();const i=this.resolveUrl(t),o=encodeURIComponent(i),n=encodeURIComponent(t.thumb||t.src||i),r=encodeURIComponent(M(t.caption)),a=y(this.opts.tpl??bt,{...s,url_direct:i,url_facebook:`https://www.facebook.com/sharer/sharer.php?u=${o}`,url_twitter:`https://twitter.com/intent/tweet?url=${o}&text=${r}`,url_pinterest:`https://pinterest.com/pin/create/button/?url=${o}&media=${n}&description=${r}`});this.overlay=m("div","glare-share-overlay",a),this.container.appendChild(this.overlay);const l=c(".glare-share-input",this.overlay);l?.select(),this.off=h(this.overlay,"click",f=>{const S=f.target;S===this.overlay||S.closest("[data-glare-share-close]")?this.close():S.closest("[data-glare-share-copy]")&&this.copy(i,l)})}close(){if(!this.overlay)return;const t=this.overlay.contains(document.activeElement);if(this.off?.(),this.off=null,this.overlay.remove(),this.overlay=null,!t)return;const s=c("[data-glare-share]",this.container);s?s.focus():this.glare.focus()}destroy(){this.close()}async copy(t,s){try{await navigator.clipboard.writeText(t)}catch{s?.select(),document.execCommand("copy")}s?.select()}resolveUrl(t){const{url:s}=this.opts;return typeof s=="function"?s(t):s||(/^https?:\/\//i.test(t.src)?t.src:window.location.href)}}class ce{constructor(t,s,i){this.glare=t,this.container=s,this.opts=i,this.timer=null,this.active=!1,this.bar=c(".glare-progress",s),this.button=c("[data-glare-slideshow]",s),i.autoStart&&this.start()}isActive(){return this.active}start(){this.glare.group.length<2||(this.active=!0,this.container.classList.add("glare-is-slideshow"),this.syncButton(),this.schedule())}stop(){this.active=!1,this.clearTimer(),this.setProgress(0,!0),this.container.classList.remove("glare-is-slideshow"),this.syncButton()}toggle(){this.active?this.stop():this.start()}onIndexChange(){this.active&&this.schedule()}destroy(){this.stop()}get speed(){return this.opts.speed??D.speed}get atEnd(){return!this.glare.opts.loop&&this.glare.currIndex===this.glare.group.length-1}schedule(){this.clearTimer(),this.setProgress(0),O()||(this.bar?.offsetWidth,this.setProgress(1)),this.timer=setTimeout(()=>this.atEnd?this.stop():this.glare.next(),this.speed)}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}setProgress(t,s=!1){this.bar&&(this.bar.hidden=s,this.bar.style.transitionDuration=t?`${this.speed}ms`:"0ms",this.bar.style.transform=`scaleX(${t})`)}syncButton(){if(!this.button)return;const{dict:t}=this.glare;k(this.button,this.active,this.active?t.PLAY_STOP:t.PLAY_START,this.active?u.pause:u.play)}}class he{constructor(t,s,i){this.glare=t,this.container=s,this.opts=i,this.isActive=!1,this.offs=[],this.axis=i.axis==="y"?"y":"x",this.list=m("div","glare-thumbs-list"),this.strip=m("div",`glare-thumbs glare-thumbs--${this.axis}`),this.strip.appendChild(this.list),this.build()}show(){this.setActive(!0)}hide(){this.setActive(!1)}toggle(){this.setActive(!this.isActive)}focus(t=this.glare.currIndex){for(const s of $(".glare-thumbs-item",this.list))s.classList.toggle("glare-is-active",Number(s.dataset.index)===t);this.list.querySelector(".glare-is-active")?.scrollIntoView({block:"nearest",inline:"nearest",behavior:"smooth"})}destroy(){this.offs.forEach(t=>t()),this.offs=[],this.container.classList.remove(`glare-thumbs-axis-${this.axis}`),this.strip.remove()}setActive(t){this.isActive=t,this.strip.classList.toggle("glare-thumbs--active",t),this.container.classList.toggle("glare-show-thumbs",t);const s=c("[data-glare-thumbs]",this.container);s?.classList.toggle("glare-is-active",t),s?.setAttribute("aria-expanded",String(t))}build(){const{group:t,dict:s}=this.glare;if(t.length<2)return;this.container.classList.add(`glare-thumbs-axis-${this.axis}`);for(const o of t){const n=m("button","glare-thumbs-item");n.type="button",n.dataset.index=String(o.index),n.setAttribute("aria-label",y(s.GO_TO_SLIDE,{index:String(o.index+1)}));const r=o.thumb||(o.type==="image"?o.src:"");if(r){const a=m("img");a.src=r,a.alt=o.alt||M(o.caption),a.loading="lazy",n.appendChild(a)}else n.textContent=String(o.index+1);this.list.appendChild(n),this.offs.push(h(n,"click",()=>this.glare.jumpTo(o.index)))}(Mt(this.opts.parentEl,this.container)??this.container).appendChild(this.strip),this.opts.autoStart&&this.show(),this.focus()}}const ue=40,de=150,fe=16;class pe{constructor(t,s){this.distance=0,this.fired=!1,this.settle=null,this.off=h(t,"wheel",i=>{const o=s.current();!o||i.deltaY===0||s.mode==="auto"&&o.type!=="image"||o.type==="image"&&s.isZoomed()||(i.preventDefault(),this.restartSettle(),!this.fired&&(this.distance+=me(i,t),!(Math.abs(this.distance)<ue)&&(this.fired=!0,this.distance>0?s.next():s.prev())))},{passive:!1})}destroy(){this.settle&&clearTimeout(this.settle),this.off()}restartSettle(){this.settle&&clearTimeout(this.settle),this.settle=setTimeout(()=>{this.distance=0,this.fired=!1},de)}}function me(e,t){return e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*fe:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t.clientHeight:e.deltaY}function ge(e,t){const s=O(),i=s?!1:t.animationEffect,o=s?!1:t.transitionEffect;e.dataset.animation=i||"none",e.style.setProperty("--glare-duration",`${i?t.animationDuration:0}ms`),e.style.setProperty("--glare-transition-duration",`${o?t.transitionDuration:0}ms`)}function ye(e,t){const s=O()?!1:t.transitionEffect;e.dataset.transition=s||"none"}function be(e,t,s){const i=t.$image,o=t.$trigger;if(e.dataset.animation!=="zoom"||!i||!o)return;const n=o.getBoundingClientRect(),r=i.getBoundingClientRect(),a=Math.max(n.width/Math.max(r.width,1),n.height/Math.max(r.height,1)),l=n.left+n.width/2-(r.left+r.width/2),f=n.top+n.height/2-(r.top+r.height/2);Object.assign(i.style,{transform:`translate3d(${l}px, ${f}px, 0) scale(${a})`,opacity:s.zoomOpacity?"0.2":"1",transitionDuration:"0ms"}),Y(()=>{Object.assign(i.style,{transform:"",opacity:"",transitionDuration:""})})}function rt(e){const t=_(B,e);return It()&&t.mobile?_(t,t.mobile):t}function I(e,t){return e?e===!0?{...t}:{...t,...e}:null}const A=[],P=e=>e.getAttribute("data-glare")??"";function ve(e){return typeof e=="string"?$(e):e instanceof HTMLElement?[e]:Array.from(e)}function we(e,t,s){const i=ve(e),o=a=>{const l=P(a),f=l?i.filter(S=>P(S)===l):[a];s(f,f.indexOf(a),l)},n=i.map(a=>h(a,"click",l=>{l.preventDefault(),o(a)})),r={elements:i,destroy(){n.forEach(l=>l());const a=A.indexOf(r);a>=0&&A.splice(a,1)}};return A.push(r),rt(t).hash&&Ee(i,o),r}function xe(){for(const e of[...A])e.destroy()}function Ee(e,t){const s=F();if(!s)return;const o=e.filter(n=>P(n)===s.gallery)[s.index];o&&t(o)}class Se{constructor(t,s){this.seconds=t,this.onIdle=s,this.timer=null}reset(){this.stop(),this.seconds&&(this.timer=setTimeout(this.onIdle,this.seconds*1e3))}stop(){this.timer&&clearTimeout(this.timer),this.timer=null}}const w=[],g={add(e){w.push(e)},remove(e){const t=w.indexOf(e);t>=0&&w.splice(t,1)},top(){return w[w.length-1]??null},get(e){return w.find(t=>t.id===e)??null},all(){return[...w]},get size(){return w.length}},Te=[["[data-glare-close]",e=>e.close()],["[data-glare-next]",e=>e.next()],["[data-glare-prev]",e=>e.prev()],["[data-glare-zoom]",e=>e.toggleZoom()],["[data-glare-slideshow]",e=>e.slideshow?.toggle()],["[data-glare-thumbs]",e=>e.thumbs?.toggle()],["[data-glare-fullscreen]",e=>e.fullscreen?.toggle()],["[data-glare-share]",e=>e.share?.open()]],Le=".glare-content",Ce=".glare-slide, .glare-stage",$e='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',Me=new Set(["INPUT","TEXTAREA","SELECT"]),Oe=300;function Ie(e,t,s){let i=null;const o=()=>{i&&clearTimeout(i),i=null},n=[h(t,"click",r=>{if(e.consumeGesture())return;const a=r.target,l=Te.find(([S])=>a.closest(S));if(l)return l[1](e);if(a.closest(".glare-button"))return;const f=z(e,a,"click");if(f){if(!at(e,z(e,a,"dblclick"),r))return N(e,f,r);o(),i=setTimeout(()=>N(e,f,r),Oe)}}),h(t,"dblclick",r=>{o();const a=r.target;a.closest(".glare-button")||N(e,z(e,a,"dblclick"),r)}),h(document,"keydown",r=>Ae(e,r)),h(document,"keydown",s),h(document,"mousemove",s),h(document,"touchstart",s,{passive:!0})];return e.opts.trapFocus&&n.push(h(t,"keydown",r=>De(t,r))),e.opts.protect&&n.push(h(t,"contextmenu",r=>r.preventDefault()),h(t,"dragstart",r=>{r.target.tagName==="IMG"&&r.preventDefault()})),()=>{o(),n.forEach(r=>r())}}function z(e,t,s){const{opts:i}=e;if(t.closest(Le))return s==="click"?i.clickContent:i.dblclickContent;if(!(i.modal||!t.closest(Ce)))return s==="click"?i.clickSlide:i.dblclickSlide}function at(e,t,s){return!t||!e.current?!1:typeof t=="function"?t(e.current,s):t}function N(e,t,s){switch(at(e,t,s)){case"close":return e.close();case"next":return e.next();case"nextOrClose":return e.currIndex===e.group.length-1&&!e.opts.loop?e.close():e.next();case"toggleControls":return e.toggleControls();case"zoom":{const i=s instanceof MouseEvent?{x:s.clientX,y:s.clientY}:void 0;return e.toggleZoom(i)}}}function Ae(e,t){if(g.top()!==e)return;if(t.key==="Escape"&&e.share?.isOpen)return t.preventDefault(),e.share.close();if(!e.opts.keyboard||e.opts.modal)return;const s=t.target;if(!Me.has(s.tagName)&&!(t.key===" "&&s.closest("button")))switch(t.key){case"Escape":return t.preventDefault(),e.close();case"ArrowRight":case"ArrowDown":return t.preventDefault(),e.next();case"ArrowLeft":case"ArrowUp":return t.preventDefault(),e.prev();case" ":return t.preventDefault(),e.slideshow?.toggle();case"f":case"F":return e.fullscreen?.toggle()}}function De(e,t){if(t.key!=="Tab")return;const s=$($e,e).filter(n=>!n.hasAttribute("disabled")&&n.offsetParent!==null&&getComputedStyle(n).visibility!=="hidden");if(!s.length)return;const i=s[0],o=s[s.length-1];t.shiftKey&&document.activeElement===i?(t.preventDefault(),o.focus()):!t.shiftKey&&document.activeElement===o&&(t.preventDefault(),i.focus())}const ke=1200,_e={image:(e,t,s)=>new Promise((i,o)=>{const n=m("img","glare-image");n.alt=e.alt||M(e.caption),n.decoding="async",n.draggable=!1,s.protect&&(n.style.pointerEvents="none"),n.onload=()=>{e.$image=n,e.contentWidth=n.naturalWidth,e.contentHeight=n.naturalHeight,t.appendChild(n),i()},n.onerror=()=>o(new Error(`Failed to load image: ${e.src}`)),n.src=e.src}),video:(e,t,s,i)=>{const o=e.format||s.video.format||Tt(e.src);t.innerHTML=y(s.video.tpl,{...i,src:e.src,format:o,poster:e.poster??""});const n=t.querySelector("video");n&&(e.autoStart??s.video.autoStart)&&n.play().catch(()=>{})},iframe:(e,t,s)=>new Promise(i=>{const o=s.iframe,n=m("div","glare-iframe-wrap",o.tpl),r=n.querySelector("iframe");if(!r)throw new Error("Iframe template must contain an <iframe>");for(const[a,l]of Object.entries(o.attr))r.setAttribute(a,l);if(Object.assign(r.style,o.css),e.width&&(n.style.width=X(e.width)),e.height&&(n.style.height=X(e.height)),t.appendChild(n),!o.preload){r.src=e.src,i();return}r.onload=()=>i(),r.src=e.src,setTimeout(i,ke)}),inline:(e,t)=>{const s=e.src?c(e.src):null;if(!s)throw new Error(`Inline target not found: ${e.src}`);const i=s.cloneNode(!0);i.removeAttribute("id"),i.hidden=!1,i.style.display="",t.appendChild(i)},ajax:async(e,t,s)=>{const i=await fetch(e.src,s.ajax.settings);if(!i.ok)throw new Error(`Request failed: ${i.status} ${e.src}`);t.innerHTML=await i.text()},html:(e,t)=>{e.content instanceof HTMLElement?t.appendChild(e.content):t.innerHTML=e.html??e.content??e.src}};async function He(e,t,s,i){t.innerHTML="",t.className=`glare-content glare-content--${e.type}`,await _e[e.type](e,t,s,i),e.isLoaded=!0}function Re(e,t){for(const s of[e[t-1],e[t+1]])s?.type==="image"&&s.src&&(new Image().src=s.src)}let Fe=0;const x=class x{constructor(t,s={},i=0,o=""){this.id=++Fe,this.current=null,this.currIndex=0,this.prevIndex=0,this.isActive=!1,this.isClosing=!1,this.isIdle=!1,this.$refs=null,this.hash=null,this.gestures=null,this.wheel=null,this.cleanups=[],this.previouslyFocused=null,this.opts=rt(s),this.dict=C(this.opts),this.group=Ct(t,this.opts),this.galleryName=o,this.currIndex=this.clampIndex(i),this.zoom=new Qt({image:()=>this.current?.$image??null,stage:()=>this.$refs?.stage??null,onChange:n=>this.syncZoomState(n)}),this.idle=new Se(this.opts.modal?!1:this.opts.idleTime,()=>this.toggleControls(!0))}open(t=this.currIndex){if(this.isActive)return this.jumpTo(t);if(!this.group.length)return;this.opts.closeExisting&&x.close(!0),this.currIndex=this.clampIndex(t),this.current=this.group[this.currIndex],this.previouslyFocused=document.activeElement instanceof HTMLElement?document.activeElement:null,this.emit("onInit");const s=At(this.opts,this.dict,this.id,this.group.length),{container:i}=s;this.$refs=s,ge(i,this.opts),this.syncChrome(),this.resolveParent().appendChild(i),this.isActive=!0,g.add(this),this.opts.hideScrollbar&&K(!0),this.emit("onActivate"),this.emitSlide("beforeShow",this.current),Y(()=>{this.isActive&&(i.classList.add("glare-is-open"),this.showSlide(this.currIndex,!0),this.cleanups.push(Ie(this,i,()=>this.onActivity())),this.startModules(s),this.opts.autoFocus&&this.focus(),this.idle.reset())})}close(){if(!this.isActive||this.isClosing||!this.current||!this.$refs||this.emitSlide("beforeClose",this.current)===!1)return;this.isClosing=!0,this.slideshow?.stop(),this.idle.stop();const{container:t,bg:s}=this.$refs,i=O()?0:this.opts.animationDuration;if(i===0)return this.teardown();t.classList.remove("glare-is-open"),t.classList.add("glare-is-closing"),Ot(s??t,i,()=>this.teardown())}next(){this.jumpTo(this.currIndex+1)}prev(){this.jumpTo(this.currIndex-1)}jumpTo(t){if(!this.isActive||this.isClosing)return;const s=this.group.length,i=this.opts.loop?(t%s+s)%s:v(t,0,s-1);i!==this.currIndex&&(this.prevIndex=this.currIndex,this.currIndex=i,this.zoom.reset(),this.current=this.group[i],this.syncChrome(),this.showSlide(i,!1),this.thumbs?.focus(i),this.hash?.update(i),this.slideshow?.onIndexChange(),this.emitSlide("onUpdate",this.current))}toggleZoom(t){this.current?.type==="image"&&(this.zoom.isZoomed?this.zoom.toFit():this.zoom.toActual(t))}update(){this.syncChrome()}focus(){this.$refs?.container.focus({preventScroll:!0})}toggleControls(t){this.$refs&&(this.isIdle=t??!this.isIdle,this.$refs.container.classList.toggle("glare-is-idle",this.isIdle))}consumeGesture(){return this.gestures?.consumeMoved()??!1}async showSlide(t,s){const i=this.group[t];if(!this.$refs||!i)return;const{container:o,stage:n}=this.$refs,r=kt(n,i,this.opts);Nt(this.opts,i)&&Rt(r,this.opts,this.dict),Ft(n,this.opts,this.dict),this.emitSlide("beforeLoad",i),this.opts.image.preload&&Re(this.group,t);let a=!1;try{await He(i,i.$content,this.opts,this.dict)}catch(l){a=!0,zt(i,l,this.opts,this.dict),this.emitSlide("onError",i),this.opts.onError||console.warn("[glare]",l)}if(!this.isActive||this.currIndex!==t)return r.remove();a||this.emitSlide("afterLoad",i),Pt(n),s||ye(o,this.opts),_t(r,s),Ht(n,r,this.opts.transitionDuration),this.syncZoomState(this.zoom.isZoomed),!a&&(s&&be(o,i,this.opts),this.emitSlide("afterShow",i))}syncChrome(){!this.$refs||!this.current||(Zt(this.$refs,this.opts,this.dict,this.current,this.group.length,this.captionFor(this.current)),this.syncZoomState(this.zoom.isZoomed))}captionFor(t){const{caption:s}=this.opts;return typeof s=="function"?s(this,t):s??t.caption}syncZoomState(t){this.$refs&&Gt(this.$refs.container,this.dict,t,!!this.current?.$image)}resolveParent(){const{parentEl:t}=this.opts;return(typeof t=="string"?document.querySelector(t):t)??document.body}startModules({container:t,stage:s,bg:i}){const o=this.opts,n=I(o.thumbs,j);n&&(this.thumbs=new he(this,t,n));const r=I(o.slideshow,D);r&&(this.slideshow=new ce(this,t,r));const a=I(o.fullscreen,q);a&&G()&&(this.fullscreen=new Vt(this,t,a));const l=I(o.share,{});l&&(this.share=new le(this,t,l)),o.hash&&this.galleryName&&(this.hash=new ae(this,this.galleryName)),o.wheel&&(this.wheel=new pe(s,{mode:o.wheel,current:()=>this.current,isZoomed:()=>this.zoom.isZoomed,next:()=>this.next(),prev:()=>this.prev()})),o.touch&&(this.gestures=new ne(s,{zoom:this.zoom,touch:o.touch,bg:i,canPan:()=>this.current?.type==="image",close:()=>this.close(),next:()=>this.next(),prev:()=>this.prev()}))}onActivity(){this.isIdle&&this.toggleControls(!1),this.idle.reset()}teardown(){for(const t of[this.gestures,this.wheel,this.hash,this.share,this.thumbs,this.slideshow,this.fullscreen])t?.destroy();this.gestures=this.wheel=this.hash=null,this.share=this.thumbs=this.slideshow=this.fullscreen=void 0,this.cleanups.forEach(t=>t()),this.cleanups=[],this.$refs?.container.remove(),this.$refs=null,g.remove(this),this.opts.hideScrollbar&&g.size===0&&K(!1),this.opts.backFocus&&(this.current?.$trigger??this.previouslyFocused)?.focus({preventScroll:!0}),this.isActive=!1,this.isClosing=!1,this.current&&this.emitSlide("afterClose",this.current)}emit(t){return this.opts[t]?.(this)}emitSlide(t,s){return this.opts[t]?.(this,s)}clampIndex(t){return v(t,0,Math.max(0,this.group.length-1))}static open(t,s={},i=0){const o=new x(t,s,i);return o.open(),o}static bind(t,s={}){return we(t,s,(i,o,n)=>{new x(i,s,o,n).open()})}static close(t=!1){t?g.all().reverse().forEach(s=>s.close()):g.top()?.close()}static getInstance(t){return t==null?g.top():g.get(t)}static getInstances(){return g.all()}static destroy(){x.close(!0),xe()}static autoBind(t={}){const s=()=>x.bind("[data-glare]",t);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",s,{once:!0}):s()}};x.defaults=B;let Z=x;return Z}));
|
|
28
30
|
//# sourceMappingURL=glare.js.map
|