zoomora 1.2.1 → 1.4.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.
@@ -1,10 +1,536 @@
1
- var t,e,s=Object.defineProperty,o=Object.defineProperties,i=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertyNames,a=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable,h=(t,e,o)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,c=(t,e)=>{for(var s in e||(e={}))r.call(e,s)&&h(t,s,e[s]);if(a)for(var s of a(e))l.call(e,s)&&h(t,s,e[s]);return t},d=(t={"zoomora.es.min.js"(t,e){
1
+ function t(e) {
2
+ return t = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
3
+ return typeof t;
4
+ } : function(t) {
5
+ return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
6
+ }, t(e);
7
+ }
8
+ function e(e) {
9
+ var s = function(e, s) {
10
+ if ("object" != t(e) || !e) return e;
11
+ var o = e[Symbol.toPrimitive];
12
+ if (void 0 !== o) {
13
+ var i = o.call(e, s || "default");
14
+ if ("object" != t(i)) return i;
15
+ throw new TypeError("@@toPrimitive must return a primitive value.");
16
+ }
17
+ return ("string" === s ? String : Number)(e);
18
+ }(e, "string");
19
+ return "symbol" == t(s) ? s : s + "";
20
+ }
21
+ function s(t, s, o) {
22
+ return (s = e(s)) in t ? Object.defineProperty(t, s, {
23
+ value: o,
24
+ enumerable: !0,
25
+ configurable: !0,
26
+ writable: !0
27
+ }) : t[s] = o, t;
28
+ }
29
+ function o(t, e) {
30
+ var s = Object.keys(t);
31
+ if (Object.getOwnPropertySymbols) {
32
+ var o = Object.getOwnPropertySymbols(t);
33
+ e && (o = o.filter(function(e) {
34
+ return Object.getOwnPropertyDescriptor(t, e).enumerable;
35
+ })), s.push.apply(s, o);
36
+ }
37
+ return s;
38
+ }
39
+ function i(t) {
40
+ for (var e = 1; e < arguments.length; e++) {
41
+ var i = null != arguments[e] ? arguments[e] : {};
42
+ e % 2 ? o(Object(i), !0).forEach(function(e) {
43
+ s(t, e, i[e]);
44
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i)) : o(Object(i)).forEach(function(e) {
45
+ Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(i, e));
46
+ });
47
+ }
48
+ return t;
49
+ }
2
50
  /*!
3
- * Zoomora Lightbox Plugin v1.2.1
4
- * A modern, responsive lightbox plugin with zoom, fullscreen, and gallery features
5
- *
6
- * Copyright (c) 2026 Faruk Ahmed (FrontTheme)
7
- * Licensed under MIT License
8
- */
9
- var s,n;s="undefined"!=typeof window?window:void 0,n=function(){class t{static get defaults(){return{selector:"[data-zoomora]",showCounter:!0,showThumbnails:!0,showFullscreen:!0,showZoom:!0,transition:"fade",useHref:!1,maxZoomScale:3,zoomStep:.1,animationDuration:300,closeOnBackgroundClick:!0,onOpen:null,onClose:null,onNext:null,onPrev:null,showAutoHideToggle:!0,autoHideDelay:3e3,autoHideEnabled:!1}}constructor(e={}){this.options=c(c({},t.defaults),e),this.currentIndex=0,this.items=[],this.isZoomed=!1,this.isFullscreen=!1,this.isDragging=!1,this.thumbnailsVisible=!0,this.startX=0,this.startY=0,this.currentX=0,this.currentY=0,this.currentScale=1,this.isInitialized=!1,this.eventListeners=new Map,this.autoHideEnabled=!1,this.autoHideTimeout=null,this.autoHideDelay=3e3,this.isControlsVisible=!0,this.idleTimer=null,this.lastDragTime=0,this.boundMethods={handleDocumentClick:this.handleDocumentClick.bind(this),handleKeydown:this.handleKeydown.bind(this),handleFullscreenChange:this.handleFullscreenChange.bind(this),handleZoomoraClick:this.handleZoomoraClick.bind(this),handleContentClick:this.handleContentClick.bind(this),handleMouseDown:this.handleMouseDown.bind(this),handleMouseMove:this.handleMouseMove.bind(this),handleMouseUp:this.handleMouseUp.bind(this),handleTouchStart:this.handleTouchStart.bind(this),handleTouchMove:this.handleTouchMove.bind(this),handleTouchEnd:this.handleTouchEnd.bind(this)},this.init()}init(){if(!this.isInitialized)try{this.createLightbox(),this.bindEvents(),this.isInitialized=!0}catch(t){}}static bind(e,s={}){const n=(a=c({},s),o(a,i({selector:e,useHref:!0})));var a;return new t(n)}createLightbox(){if(document.getElementById("zoomoraLightbox"))return;const t=this.options.showAutoHideToggle?'\n <button class="zoomora-btn" id="zoomoraAutoHideBtn" title="Toggle Auto-Hide Controls">\n <i class="zoomorai-controls-off"></i>\n </button>\n ':"",e=`\n <div class="zoomora" id="zoomoraLightbox">\n <div class="zoomora-container">\n <div class="zoomora-header" id="zoomoraHeader">\n <div class="zoomora-counter" id="zoomoraCounter" ${this.options.showCounter?"":'style="opacity:0;visibility:hidden;"'}>1 / 1</div>\n <div class="zoomora-controls">\n ${this.options.showThumbnails?'\n <button class="zoomora-btn" id="zoomoraThumbnailBtn" title="Toggle Thumbnails">\n <i class="zoomorai-thumbnails"></i>\n </button>\n ':""}\n ${t}\n ${this.options.showZoom?'\n <button class="zoomora-btn" id="zoomoraZoomBtn" title="Zoom">\n <i class="zoomorai-zoom"></i>\n </button>\n ':""}\n ${this.options.showFullscreen?'\n <button class="zoomora-btn" id="zoomoraFullscreenBtn" title="Fullscreen">\n <i class="zoomorai-expand"></i>\n </button>\n <button class="zoomora-btn" id="zoomoraCollapseBtn" title="Exit Fullscreen" style="display: none;">\n <i class="zoomorai-collapse"></i>\n </button>\n ':""}\n <button class="zoomora-btn" id="zoomoraCloseBtn" title="Close">\n <i class="zoomorai-close"></i>\n </button>\n </div>\n </div>\n \n <div class="zoomora-content" id="zoomoraContent">\n <div class="zoomora-loading" id="zoomoraLoading"></div>\n <div class="zoomora-slides-container" id="zoomoraSlidesContainer"></div>\n </div>\n \n <button class="zoomora-nav prev" id="zoomoraPrevBtn">\n <i class="zoomorai-arrow-left"></i>\n </button>\n <button class="zoomora-nav next" id="zoomoraNextBtn">\n <i class="zoomorai-arrow-right"></i>\n </button>\n \n <div class="zoomora-caption" id="zoomoraCaption" ${this.options.showThumbnails?"":'style="bottom:20px;"'}></div>\n <div class="zoomora-thumbnails" id="zoomoraThumbs" ${this.options.showThumbnails?"":'style="display:none;"'}></div>\n </div>\n </div>\n `;if(document.body.insertAdjacentHTML("beforeend",e),this.zoomora=document.getElementById("zoomoraLightbox"),this.header=document.getElementById("zoomoraHeader"),this.content=document.getElementById("zoomoraContent"),this.slidesContainer=document.getElementById("zoomoraSlidesContainer"),this.counter=document.getElementById("zoomoraCounter"),this.thumbs=document.getElementById("zoomoraThumbs"),this.loading=document.getElementById("zoomoraLoading"),this.caption=document.getElementById("zoomoraCaption"),this.prevBtn=document.getElementById("zoomoraPrevBtn"),this.nextBtn=document.getElementById("zoomoraNextBtn"),!(this.zoomora&&this.content&&this.counter&&this.thumbs&&this.loading&&this.caption))throw new Error("Failed to create required DOM elements")}bindEvents(){this.addEventListener(document,"click",this.boundMethods.handleDocumentClick),this.addEventListener(document.getElementById("zoomoraCloseBtn"),"click",()=>this.close()),this.addEventListener(document.getElementById("zoomoraPrevBtn"),"click",()=>this.prev()),this.addEventListener(document.getElementById("zoomoraNextBtn"),"click",()=>this.next()),this.options.showZoom&&this.addEventListener(document.getElementById("zoomoraZoomBtn"),"click",()=>this.toggleZoom()),this.options.showFullscreen&&(this.addEventListener(document.getElementById("zoomoraFullscreenBtn"),"click",()=>this.toggleFullscreen()),this.addEventListener(document.getElementById("zoomoraCollapseBtn"),"click",()=>this.exitFullscreen())),this.options.showThumbnails&&this.addEventListener(document.getElementById("zoomoraThumbnailBtn"),"click",()=>this.toggleThumbnails()),this.addEventListener(document,"fullscreenchange",this.boundMethods.handleFullscreenChange),this.addEventListener(document,"webkitfullscreenchange",this.boundMethods.handleFullscreenChange),this.addEventListener(document,"mozfullscreenchange",this.boundMethods.handleFullscreenChange),this.addEventListener(document,"MSFullscreenChange",this.boundMethods.handleFullscreenChange),this.addEventListener(document,"keydown",this.boundMethods.handleKeydown),this.addEventListener(this.zoomora,"click",this.boundMethods.handleZoomoraClick),this.addEventListener(this.content,"click",this.boundMethods.handleContentClick),this.addEventListener(this.content,"mousedown",this.boundMethods.handleMouseDown),this.addEventListener(this.content,"mousemove",this.boundMethods.handleMouseMove),this.addEventListener(this.content,"mouseup",this.boundMethods.handleMouseUp),this.addEventListener(this.content,"mouseleave",this.boundMethods.handleMouseUp),this.addEventListener(this.content,"touchstart",this.boundMethods.handleTouchStart,{passive:!1}),this.addEventListener(this.content,"touchmove",this.boundMethods.handleTouchMove,{passive:!1}),this.addEventListener(this.content,"touchend",this.boundMethods.handleTouchEnd),this.options.showAutoHideToggle&&(this.addEventListener(document.getElementById("zoomoraAutoHideBtn"),"click",()=>this.toggleAutoHide()),this.addEventListener(this.zoomora,"mousemove",()=>this.handleUserActivity()),this.addEventListener(this.zoomora,"touchstart",()=>this.handleUserActivity()),this.addEventListener(this.zoomora,"keydown",()=>this.handleUserActivity()))}addEventListener(t,e,s,o={}){if(!t)return;t.addEventListener(e,s,o);const i=`${t.constructor.name}_${e}`;this.eventListeners.has(i)||this.eventListeners.set(i,[]),this.eventListeners.get(i).push({element:t,event:e,handler:s,options:o})}handleDocumentClick(t){const e=t.target.closest(this.options.selector);e&&(t.preventDefault(),this.open(e))}handleKeydown(t){if(this.zoomora.classList.contains("active"))switch(t.key){case"Escape":this.isFullscreen?this.exitFullscreen():this.close();break;case"ArrowLeft":this.prev();break;case"ArrowRight":this.next();break;case"z":case"Z":this.toggleZoom();break;case"f":case"F":this.toggleFullscreen();break;case"t":case"T":this.toggleThumbnails()}}handleFullscreenChange(){const t=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);!t&&this.isFullscreen?(this.isFullscreen=!1,this.zoomora.classList.remove("fullscreen"),this.updateButtons()):t&&!this.isFullscreen&&(this.isFullscreen=!0,this.zoomora.classList.add("fullscreen"),this.updateButtons())}handleZoomoraClick(t){t.target===this.zoomora&&this.options.closeOnBackgroundClick&&this.close()}handleContentClick(t){if(Date.now()-this.lastDragTime<200)return;if(this.header&&this.header.contains(t.target))return;if(t.target.closest("button"))return;const e=t.target.closest(".zoomora-media, .zoomora-video, .zoomora-iframe");if(e)return void(e.classList.contains("zoomora-media")&&!e.classList.contains("no-zoom")&&this.toggleZoom());if(t.target.closest(".zoomora-video-container")){if(t.target.closest(".zoomora-play-button"))return;return void(this.options.closeOnBackgroundClick&&this.close())}const s=t.target;((s.classList.contains("zoomora-content")||s.classList.contains("zoomora-slide-container")||s.classList.contains("zoomora-slide")||s.classList.contains("zoomora-slides-container")||"zoomoraContent"===s.id||"zoomoraSlidesContainer"===s.id)&&this.options.closeOnBackgroundClick||this.options.closeOnBackgroundClick)&&this.close()}handleMouseDown(t){this.startDrag(t)}handleMouseMove(t){this.drag(t)}handleMouseUp(){this.endDrag()}handleTouchStart(t){this.startDrag(t)}handleTouchMove(t){this.drag(t)}handleTouchEnd(){this.endDrag()}getImageSource(t){const e=t.dataset.src||t.src||t.getAttribute("src");return"video"===(t.dataset.type||"image")&&e?this.convertToEmbedUrl(e):e}convertToEmbedUrl(t){if(t.includes("youtube.com/embed/"))return t;let e=null,s=null;if(t.includes("youtube.com/watch")){const o=new URLSearchParams(t.split("?")[1]);e=o.get("v");const i=o.get("t");i&&(s=i.replace("s",""))}else if(t.includes("youtu.be/")){const o=t.split("/"),i=o[o.length-1];if(i.includes("?")){e=i.split("?")[0];const t=new URLSearchParams(i.split("?")[1]).get("t");t&&(s=t.replace("s",""))}else e=i}if(e){let t=`https://www.youtube.com/embed/${e}`;const o=new URLSearchParams;return s&&o.append("start",s),o.append("rel","0"),o.append("modestbranding","1"),o.toString()&&(t+="?"+o.toString()),t}return t}getThumbnailSource(t){return"video"===(t.dataset.type||"image")?t.src||t.getAttribute("src"):t.dataset.src||t.src||t.getAttribute("src")}getGroup(t){return this.options.useHref?t.dataset.lightbox||t.dataset.gallery||"default":t.dataset.zoomora||"default"}open(t){if(!t)return;const e=this.getGroup(t);let s;s=this.options.useHref?t.dataset.lightbox?`[data-lightbox="${e}"]`:t.dataset.gallery?`[data-gallery="${e}"]`:this.options.selector:`[data-zoomora="${e}"]`,this.items=Array.from(document.querySelectorAll(s)),this.currentIndex=Math.max(0,this.items.indexOf(t)),this.isZoomed=!1,this.isFullscreen=!1,this.thumbnailsVisible=!0,this.currentX=0,this.currentY=0,this.currentScale=1,this.zoomora.classList.add("active"),document.body.style.overflow="hidden",this.loadContent(),this.updateThumbnails(),this.updateCounter(),this.updateNavigation(),this.updateCaption(),this.updateButtons(),this.autoHideEnabled?this.startAutoHideTimer():this.showControls(),"function"==typeof this.options.onOpen&&this.options.onOpen(t,this.currentIndex)}close(){this.isFullscreen&&this.exitFullscreen(),this.zoomora.classList.remove("active"),document.body.style.overflow="",this.isZoomed=!1,this.isFullscreen=!1,this.currentX=0,this.currentY=0,this.currentScale=1;const t=this.content.querySelector(".zoomora-media");t&&(t.classList.remove("zoomed"),t.style.transform="",t.style.cursor=""),this.zoomora.classList.remove("fullscreen"),this.updateButtons(),this.stopAutoHideTimer(),this.showControls(),"function"==typeof this.options.onClose&&this.options.onClose(this.currentIndex)}prev(){this.currentIndex>0&&(this.currentIndex--,this.loadContent(),this.updateCounter(),this.updateThumbnails(),this.updateNavigation(),this.updateCaption(),"function"==typeof this.options.onPrev&&this.options.onPrev(this.currentIndex))}next(){this.currentIndex<this.items.length-1&&(this.currentIndex++,this.loadContent(),this.updateCounter(),this.updateThumbnails(),this.updateNavigation(),this.updateCaption(),"function"==typeof this.options.onNext&&this.options.onNext(this.currentIndex))}loadContent(){if(!this.items[this.currentIndex])return;const t=this.items[this.currentIndex],e=this.getImageSource(t),s=t.dataset.type||"image";e&&(this.isZoomed=!1,this.currentX=0,this.currentY=0,this.currentScale=1,this.loading.style.display="block",this.slidesContainer&&(this.slidesContainer.innerHTML=""),setTimeout(()=>{this.renderContent(e,s,t)},100))}renderContent(t,e,s){const o=document.createElement("div");o.className="zoomora-slide-container";const i=document.createElement("div");let n;i.className="zoomora-slide "+("slide"===this.options.transition?"slide-effect":"fade-effect"),i.style.opacity="0",i.style.transform="slide"===this.options.transition?"translateX(100%)":"scale(0.8)";try{switch(e){case"video":if(t.endsWith(".mp4")||t.endsWith(".webm")||t.endsWith(".ogg")){const e=document.createElement("div");e.className="zoomora-video-container",n=document.createElement("video"),n.src=t,n.className="zoomora-video",n.setAttribute("preload","metadata");const i=s.src||s.getAttribute("src");i&&n.setAttribute("poster",i);const a=document.createElement("div");a.className="zoomora-play-button",a.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>',a.addEventListener("click",()=>{n.play(),a.style.display="none",n.setAttribute("controls","")}),n.addEventListener("ended",()=>{a.style.display="flex"}),e.appendChild(n),e.appendChild(a),o.appendChild(e)}else n=document.createElement("iframe"),n.src=t,n.className="zoomora-video",n.setAttribute("allowfullscreen",""),n.setAttribute("frameborder","0"),o.appendChild(n);break;case"iframe":n=document.createElement("iframe"),n.src=t,n.className="zoomora-iframe",n.setAttribute("frameborder","0"),o.appendChild(n);break;default:n=document.createElement("img"),n.src=t,n.className="zoomora-media",n.alt=s.alt||s.title||"",n.onload=()=>{this.loading.style.display="none",this.checkZoomability(n),this.animateSlideIn(i)},n.onerror=()=>{this.loading.style.display="none",this.animateSlideIn(i)},o.appendChild(n)}i.appendChild(o),this.slidesContainer.innerHTML="",this.slidesContainer.appendChild(i),"image"!==e&&(this.loading.style.display="none",this.animateSlideIn(i))}catch(t){this.loading.style.display="none"}}animateSlideIn(t){t.offsetHeight,t.classList.add("active"),"slide"===this.options.transition?(t.style.transition=`transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`,t.style.transform="translateX(0)",t.style.opacity="1"):(t.style.transition=`transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`,t.style.transform="scale(1)",t.style.opacity="1")}toggleAutoHide(){this.autoHideEnabled=!this.autoHideEnabled;const t=document.getElementById("zoomoraAutoHideBtn");this.autoHideEnabled?(t.classList.add("active"),t.title="Disable Auto-Hide Controls",this.startAutoHideTimer()):(t.classList.remove("active"),t.title="Enable Auto-Hide Controls",this.stopAutoHideTimer(),this.showControls())}handleUserActivity(){this.autoHideEnabled&&(this.showControls(),this.startAutoHideTimer())}startAutoHideTimer(){this.stopAutoHideTimer(),this.autoHideTimeout=setTimeout(()=>{this.hideControls()},this.options.autoHideDelay)}stopAutoHideTimer(){this.autoHideTimeout&&(clearTimeout(this.autoHideTimeout),this.autoHideTimeout=null)}showControls(){this.isControlsVisible||(this.isControlsVisible=!0,this.zoomora.classList.remove("controls-hidden"),this.header&&(this.header.style.transform="translateY(0)",this.header.style.opacity="1"),this.caption&&(this.caption.style.transform="translateX(-50%) translateY(0)",this.caption.style.opacity="1"),this.thumbs&&(this.thumbs.style.transform="translateX(-50%) translateY(0)",this.thumbs.style.opacity="1"),this.prevBtn&&(this.prevBtn.style.transform="translateX(0)",this.prevBtn.style.opacity="1"),this.nextBtn&&(this.nextBtn.style.transform="translateX(0)",this.nextBtn.style.opacity="1"))}hideControls(){this.isControlsVisible&&(this.isControlsVisible=!1,this.zoomora.classList.add("controls-hidden"),this.header&&(this.header.style.transform="translateY(-100%)",this.header.style.opacity="0"),this.caption&&(this.caption.style.transform="translateX(-50%) translateY(100%)",this.caption.style.opacity="0"),this.thumbs&&(this.thumbs.style.transform="translateX(-50%) translateY(100%)",this.thumbs.style.opacity="0"),this.prevBtn&&(this.prevBtn.style.transform="translateX(-100%)",this.prevBtn.style.opacity="0"),this.nextBtn&&(this.nextBtn.style.transform="translateX(100%)",this.nextBtn.style.opacity="0"))}checkZoomability(t){if(!t||!t.naturalWidth||!t.naturalHeight)return;const e=t.getBoundingClientRect(),s=e.width,o=e.height,i=t.naturalWidth,n=t.naturalHeight,a=i>s||n>o,r=i/s,l=n/o,h=Math.max(r,l);t.dataset.zoomRatio=h,t.dataset.naturalWidth=i,t.dataset.naturalHeight=n,t.dataset.renderedWidth=s,t.dataset.renderedHeight=o,a&&h>1.1?t.classList.remove("no-zoom"):t.classList.add("no-zoom")}calculateZoomLevels(t){if(!t||!t.naturalWidth||!t.naturalHeight)return{canZoom:!1,levels:[],currentLevel:0};const e=this.content.getBoundingClientRect(),s=e.width,o=e.height,i=t.naturalWidth,n=t.naturalHeight,a=s/i,r=o/n,l=Math.min(a,r);if(l>=.95)return{canZoom:!1,levels:[],currentLevel:0};const h=[1];1.5*l<=1&&h.push(1.5),2*l<=1&&h.push(2),3*l<=1&&h.push(3);const c=1/l;return c>h[h.length-1]&&h.push(c),{canZoom:h.length>1,levels:h,currentLevel:0,baseScale:l,naturalWidth:i,naturalHeight:n}}updateCounter(){this.options.showCounter&&this.counter&&(this.counter.textContent=`${this.currentIndex+1} / ${this.items.length}`)}updateCaption(){if(!this.caption||!this.items[this.currentIndex])return;const t=this.items[this.currentIndex],e=t.dataset.caption||t.title||"";e?(this.caption.textContent=e,this.caption.style.transform="translateX(-50%) translateY(0)",this.caption.style.opacity="1",this.caption.style.pointerEvents="auto",this.caption.style.transition="opacity 0.3s ease, transform 0.3s ease"):(this.caption.style.transform="translateX(-50%) translateY(100%)",this.caption.style.opacity="0",this.caption.style.pointerEvents="none",this.caption.style.transition="opacity 0.3s ease, transform 0.3s ease")}updateThumbnails(){if(this.options.showThumbnails&&this.thumbs){if(1===this.items.length)return this.caption.classList.add("single-item-thumbnail"),void(this.thumbs.style.display="none");this.caption.classList.remove("single-item-thumbnail"),this.thumbs.style.display="flex",this.thumbs.innerHTML="",this.items.forEach((t,e)=>{const s=document.createElement("div");s.className="zoomora-thumb",e===this.currentIndex&&s.classList.add("active");const o=document.createElement("img"),i=this.getThumbnailSource(t);i&&(o.src=i,o.alt=t.alt||t.title||"",o.onerror=()=>{s.style.display="none"}),s.appendChild(o),s.addEventListener("click",()=>{this.currentIndex=e,this.loadContent(),this.updateCounter(),this.updateThumbnails(),this.updateNavigation(),this.updateCaption()}),this.thumbs.appendChild(s)})}}updateNavigation(){const t=document.getElementById("zoomoraPrevBtn"),e=document.getElementById("zoomoraNextBtn");t&&(t.style.display=this.currentIndex>0?"flex":"none"),e&&(e.style.display=this.currentIndex<this.items.length-1?"flex":"none")}updateButtons(){const t=document.getElementById("zoomoraFullscreenBtn"),e=document.getElementById("zoomoraCollapseBtn");t&&e&&(this.isFullscreen?(t.style.display="none",e.style.display="flex"):(t.style.display="flex",e.style.display="none"))}toggleZoom(){const t=this.content.querySelector(".zoomora-media");if(!t||"IMG"!==t.tagName)return;const e=this.calculateZoomLevels(t);if(!e.canZoom)return;t.dataset.zoomLevel||(t.dataset.zoomLevel="0");let s=parseInt(t.dataset.zoomLevel)||0;s++,s>=e.levels.length&&(s=0);const o=e.levels[s];t.dataset.zoomLevel=s.toString(),0===s?(this.isZoomed=!1,this.isDragging=!1,t.classList.remove("dragging"),t.style.transform="",t.style.cursor="pointer",t.classList.remove("zoomed"),this.currentX=0,this.currentY=0,this.currentScale=1):(this.isZoomed=!0,this.currentScale=o,this.currentX=0,this.currentY=0,t.style.transform=`translate(0px, 0px) scale(${o})`,t.style.cursor="grab",t.classList.add("zoomed"))}updateImageTransform(t){if(t)if(1===this.currentScale)t.style.transform="";else{const e=this.currentX/this.currentScale,s=this.currentY/this.currentScale;t.style.transform=`scale(${this.currentScale}) translate(${e}px, ${s}px)`}}toggleFullscreen(){this.isFullscreen?this.exitFullscreen():this.enterFullscreen()}enterFullscreen(){const t=this.zoomora;try{t.requestFullscreen?t.requestFullscreen().then(()=>{this.isFullscreen=!0,this.zoomora.classList.add("fullscreen"),this.updateButtons()}).catch(t=>{this.fallbackFullscreen()}):t.webkitRequestFullscreen?(t.webkitRequestFullscreen(),this.isFullscreen=!0,this.zoomora.classList.add("fullscreen"),this.updateButtons()):t.mozRequestFullScreen?(t.mozRequestFullScreen(),this.isFullscreen=!0,this.zoomora.classList.add("fullscreen"),this.updateButtons()):t.msRequestFullscreen?(t.msRequestFullscreen(),this.isFullscreen=!0,this.zoomora.classList.add("fullscreen"),this.updateButtons()):this.fallbackFullscreen()}catch(t){this.fallbackFullscreen()}}exitFullscreen(){if(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)try{document.exitFullscreen?document.exitFullscreen().then(()=>{this.isFullscreen=!1,this.zoomora.classList.remove("fullscreen"),this.updateButtons()}).catch(t=>{this.fallbackExitFullscreen()}):document.webkitExitFullscreen?(document.webkitExitFullscreen(),this.isFullscreen=!1,this.zoomora.classList.remove("fullscreen"),this.updateButtons()):document.mozCancelFullScreen?(document.mozCancelFullScreen(),this.isFullscreen=!1,this.zoomora.classList.remove("fullscreen"),this.updateButtons()):document.msExitFullscreen?(document.msExitFullscreen(),this.isFullscreen=!1,this.zoomora.classList.remove("fullscreen"),this.updateButtons()):this.fallbackExitFullscreen()}catch(t){this.fallbackExitFullscreen()}else this.fallbackExitFullscreen()}fallbackFullscreen(){this.isFullscreen=!0,this.zoomora.classList.add("fullscreen"),this.updateButtons()}fallbackExitFullscreen(){this.isFullscreen=!1,this.zoomora.classList.remove("fullscreen"),this.updateButtons()}toggleThumbnails(){if(1!==this.items.length&&(this.thumbnailsVisible=!this.thumbnailsVisible,this.thumbs)){if(this.thumbs.classList.toggle("thumbs-hidden",!this.thumbnailsVisible),!this.caption||!this.items[this.currentIndex])return;const t=this.items[this.currentIndex];(t.dataset.caption||t.title)&&this.thumbs.classList.contains("thumbs-hidden")?(this.caption.style.bottom="20px",this.caption.style.transition="bottom 0.3s ease, transform 0.3s ease"):this.caption.style.bottom="120px"}}startDrag(t){const e=this.content.querySelector(".zoomora-media");if(!e||!this.isZoomed)return;this.isDragging=!0,e.classList.add("dragging"),e.style.cursor="grabbing",this.startX=t.clientX||t.touches&&t.touches[0].clientX||0,this.startY=t.clientY||t.touches&&t.touches[0].clientY||0;const s=window.getComputedStyle(e).transform;if(s&&"none"!==s){const t=new DOMMatrix(s);this.currentX=t.m41,this.currentY=t.m42}else this.currentX=0,this.currentY=0;t.preventDefault()}drag(t){if(!this.isDragging)return;t.preventDefault();const e=this.content.querySelector(".zoomora-media");if(!e)return;const s=t.clientX||t.touches&&t.touches[0].clientX||0,o=t.clientY||t.touches&&t.touches[0].clientY||0,i=s-this.startX,n=o-this.startY;let a=this.currentX+i,r=this.currentY+n;const l=this.content.getBoundingClientRect(),h=e.getBoundingClientRect(),c=Math.max(0,(h.width-l.width)/2),d=Math.max(0,(h.height-l.height)/2);a=c>0?Math.max(-c,Math.min(c,a)):0,r=d>0?Math.max(-d,Math.min(d,r)):0,e.style.transform=`translate(${a}px, ${r}px) scale(${this.currentScale})`,this.startX=s,this.startY=o,this.currentX=a,this.currentY=r}endDrag(){if(!this.isDragging)return;this.isDragging=!1,this.lastDragTime=Date.now();const t=this.content.querySelector(".zoomora-media");t&&(t.classList.remove("dragging"),this.isZoomed&&(t.style.cursor="grab"))}goTo(t){t<0||t>=this.items.length||(this.currentIndex=t,this.loadContent(),this.updateCounter(),this.updateThumbnails(),this.updateNavigation(),this.updateCaption())}getCurrentIndex(){return this.currentIndex}getTotalItems(){return this.items.length}isOpen(){return this.zoomora&&this.zoomora.classList.contains("active")}updateOptions(t){this.options=c(c({},this.options),t)}refresh(){if(this.isOpen()){const t=this.items[this.currentIndex];t&&this.open(t)}}destroy(){this.isInitialized&&(this.isOpen()&&this.close(),this.stopAutoHideTimer(),this.eventListeners.forEach((t,e)=>{t.forEach(({element:t,event:e,handler:s,options:o})=>{t&&t.removeEventListener&&t.removeEventListener(e,s,o)})}),this.eventListeners.clear(),this.zoomora&&this.zoomora.parentNode&&this.zoomora.parentNode.removeChild(this.zoomora),this.isInitialized=!1,this.items=[],this.currentIndex=0,this.zoomora=null,this.content=null,this.counter=null,this.thumbs=null,this.loading=null,this.caption=null)}}return t},"object"==typeof e&&"object"==typeof e.exports?e.exports=n():"function"==typeof define&&define.amd?define(n):s.Zoomora=n()}},function(){return e||(0,t[n(t)[0]])((e={exports:{}}).exports,e),e.exports});export default d();
10
- //# sourceMappingURL=zoomora.es.min.js.map
51
+ * Zoomora Lightbox Plugin v1.4.0
52
+ * A modern, responsive lightbox plugin with zoom, fullscreen, and gallery features
53
+ *
54
+ * Copyright (c) 2026 Faruk Ahmed (FrontTheme)
55
+ * Licensed under MIT License
56
+ */ var n = class t {
57
+ static get defaults() {
58
+ return {
59
+ selector: "[data-zoomora]",
60
+ showCounter: !0,
61
+ showThumbnails: !0,
62
+ showFullscreen: !0,
63
+ showZoom: !0,
64
+ transition: "fade",
65
+ useHref: !1,
66
+ maxZoomScale: 3,
67
+ zoomStep: .1,
68
+ animationDuration: 300,
69
+ closeOnBackgroundClick: !0,
70
+ autoplayVideos: !1,
71
+ onOpen: null,
72
+ onClose: null,
73
+ onNext: null,
74
+ onPrev: null,
75
+ showAutoHideToggle: !0,
76
+ autoHideDelay: 3e3,
77
+ autoHideEnabled: !1
78
+ };
79
+ }
80
+ constructor(e = {}) {
81
+ this.options = i(i({}, t.defaults), e), this.currentIndex = 0, this.items = [], this.isZoomed = !1, this.isFullscreen = !1, this.isDragging = !1, this.thumbnailsVisible = !0, this.startX = 0, this.startY = 0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.isInitialized = !1, this.eventListeners = /* @__PURE__ */ new Map(), this.autoHideEnabled = !1, this.autoHideTimeout = null, this.autoHideDelay = 3e3, this.isControlsVisible = !0, this.lastDragTime = 0, this.boundMethods = {
82
+ handleDocumentClick: this.handleDocumentClick.bind(this),
83
+ handleKeydown: this.handleKeydown.bind(this),
84
+ handleFullscreenChange: this.handleFullscreenChange.bind(this),
85
+ handleZoomoraClick: this.handleZoomoraClick.bind(this),
86
+ handleContentClick: this.handleContentClick.bind(this),
87
+ handleMouseDown: this.handleMouseDown.bind(this),
88
+ handleMouseMove: this.handleMouseMove.bind(this),
89
+ handleMouseUp: this.handleMouseUp.bind(this),
90
+ handleTouchStart: this.handleTouchStart.bind(this),
91
+ handleTouchMove: this.handleTouchMove.bind(this),
92
+ handleTouchEnd: this.handleTouchEnd.bind(this),
93
+ handleWheel: this.handleWheel.bind(this)
94
+ }, this.init();
95
+ }
96
+ init() {
97
+ if (!this.isInitialized) try {
98
+ this.createLightbox(), this.bindEvents(), this.isInitialized = !0;
99
+ } catch (t) {}
100
+ }
101
+ static bind(e, s = {}) {
102
+ return new t(i(i({}, s), {}, {
103
+ selector: e,
104
+ useHref: !0
105
+ }));
106
+ }
107
+ createLightbox() {
108
+ if (document.getElementById("zoomoraLightbox")) return;
109
+ const t = this.options.showAutoHideToggle ? "\n <button class=\"zoomora-btn\" id=\"zoomoraAutoHideBtn\" title=\"Toggle Auto-Hide Controls\">\n <i class=\"zoomorai-controls-off\"></i>\n </button>\n " : "", e = `\n <div class="zoomora" id="zoomoraLightbox">\n <div class="zoomora-container">\n <div class="zoomora-header" id="zoomoraHeader">\n <div class="zoomora-counter" id="zoomoraCounter" ${this.options.showCounter ? "" : "style=\"opacity:0;visibility:hidden;\""}>1 / 1</div>\n <div class="zoomora-controls">\n ${this.options.showThumbnails ? "\n <button class=\"zoomora-btn\" id=\"zoomoraThumbnailBtn\" title=\"Toggle Thumbnails\">\n <i class=\"zoomorai-thumbnails\"></i>\n </button>\n " : ""}\n ${t}\n ${this.options.showZoom ? "\n <button class=\"zoomora-btn\" id=\"zoomoraZoomBtn\" title=\"Zoom\">\n <i class=\"zoomorai-zoom\"></i>\n </button>\n " : ""}\n ${this.options.showFullscreen ? "\n <button class=\"zoomora-btn\" id=\"zoomoraFullscreenBtn\" title=\"Fullscreen\">\n <i class=\"zoomorai-expand\"></i>\n </button>\n <button class=\"zoomora-btn\" id=\"zoomoraCollapseBtn\" title=\"Exit Fullscreen\" style=\"display: none;\">\n <i class=\"zoomorai-collapse\"></i>\n </button>\n " : ""}\n <button class="zoomora-btn" id="zoomoraCloseBtn" title="Close">\n <i class="zoomorai-close"></i>\n </button>\n </div>\n </div>\n \n <div class="zoomora-content" id="zoomoraContent">\n <div class="zoomora-loading" id="zoomoraLoading"></div>\n <div class="zoomora-slides-container" id="zoomoraSlidesContainer"></div>\n </div>\n \n <button class="zoomora-nav prev" id="zoomoraPrevBtn">\n <i class="zoomorai-arrow-left"></i>\n </button>\n <button class="zoomora-nav next" id="zoomoraNextBtn">\n <i class="zoomorai-arrow-right"></i>\n </button>\n \n <div class="zoomora-caption" id="zoomoraCaption" ${this.options.showThumbnails ? "" : "style=\"bottom:20px;\""}></div>\n <div class="zoomora-thumbnails" id="zoomoraThumbs" ${this.options.showThumbnails ? "" : "style=\"display:none;\""}></div>\n </div>\n </div>\n `;
110
+ if (document.body.insertAdjacentHTML("beforeend", e), this.zoomora = document.getElementById("zoomoraLightbox"), this.header = document.getElementById("zoomoraHeader"), this.content = document.getElementById("zoomoraContent"), this.slidesContainer = document.getElementById("zoomoraSlidesContainer"), this.counter = document.getElementById("zoomoraCounter"), this.thumbs = document.getElementById("zoomoraThumbs"), this.loading = document.getElementById("zoomoraLoading"), this.caption = document.getElementById("zoomoraCaption"), this.prevBtn = document.getElementById("zoomoraPrevBtn"), this.nextBtn = document.getElementById("zoomoraNextBtn"), !(this.zoomora && this.content && this.counter && this.thumbs && this.loading && this.caption)) throw new Error("Failed to create required DOM elements");
111
+ }
112
+ bindEvents() {
113
+ this.addEventListener(document, "click", this.boundMethods.handleDocumentClick), this.addEventListener(document.getElementById("zoomoraCloseBtn"), "click", () => this.close()), this.addEventListener(document.getElementById("zoomoraPrevBtn"), "click", () => this.prev()), this.addEventListener(document.getElementById("zoomoraNextBtn"), "click", () => this.next()), this.options.showZoom && this.addEventListener(document.getElementById("zoomoraZoomBtn"), "click", () => this.toggleZoom()), this.options.showFullscreen && (this.addEventListener(document.getElementById("zoomoraFullscreenBtn"), "click", () => this.toggleFullscreen()), this.addEventListener(document.getElementById("zoomoraCollapseBtn"), "click", () => this.exitFullscreen())), this.options.showThumbnails && this.addEventListener(document.getElementById("zoomoraThumbnailBtn"), "click", () => this.toggleThumbnails()), this.addEventListener(document, "fullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "webkitfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "mozfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "MSFullscreenChange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "keydown", this.boundMethods.handleKeydown), this.addEventListener(this.zoomora, "click", this.boundMethods.handleZoomoraClick), this.addEventListener(this.content, "click", this.boundMethods.handleContentClick), this.addEventListener(this.content, "mousedown", this.boundMethods.handleMouseDown), this.addEventListener(this.content, "mousemove", this.boundMethods.handleMouseMove), this.addEventListener(this.content, "mouseup", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "mouseleave", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "touchstart", this.boundMethods.handleTouchStart, { passive: !1 }), this.addEventListener(this.content, "touchmove", this.boundMethods.handleTouchMove, { passive: !1 }), this.addEventListener(this.content, "touchend", this.boundMethods.handleTouchEnd), this.options.showZoom && this.addEventListener(this.content, "wheel", this.boundMethods.handleWheel, { passive: !1 }), this.options.showAutoHideToggle && (this.addEventListener(document.getElementById("zoomoraAutoHideBtn"), "click", () => this.toggleAutoHide()), this.addEventListener(this.zoomora, "mousemove", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "touchstart", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "keydown", () => this.handleUserActivity()));
114
+ }
115
+ addEventListener(t, e, s, o = {}) {
116
+ if (!t) return;
117
+ t.addEventListener(e, s, o);
118
+ const i = `${t.constructor.name}_${e}`;
119
+ this.eventListeners.has(i) || this.eventListeners.set(i, []), this.eventListeners.get(i).push({
120
+ element: t,
121
+ event: e,
122
+ handler: s,
123
+ options: o
124
+ });
125
+ }
126
+ handleDocumentClick(t) {
127
+ const e = t.target.closest(this.options.selector);
128
+ e && (t.preventDefault(), this.open(e));
129
+ }
130
+ handleKeydown(t) {
131
+ if (this.zoomora.classList.contains("active")) switch (t.key) {
132
+ case "Escape":
133
+ this.isFullscreen ? this.exitFullscreen() : this.close();
134
+ break;
135
+ case "ArrowLeft":
136
+ this.prev();
137
+ break;
138
+ case "ArrowRight":
139
+ this.next();
140
+ break;
141
+ case "z":
142
+ case "Z":
143
+ this.toggleZoom();
144
+ break;
145
+ case "f":
146
+ case "F":
147
+ this.toggleFullscreen();
148
+ break;
149
+ case "t":
150
+ case "T": this.toggleThumbnails();
151
+ }
152
+ else this.handleTriggerKeydown(t);
153
+ }
154
+ handleTriggerKeydown(t) {
155
+ if ("Enter" !== t.key && " " !== t.key) return;
156
+ const e = t.target.closest(this.options.selector);
157
+ e && (t.preventDefault(), this.open(e));
158
+ }
159
+ handleFullscreenChange() {
160
+ const t = !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
161
+ !t && this.isFullscreen ? (this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : t && !this.isFullscreen && (this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons());
162
+ }
163
+ handleZoomoraClick(t) {
164
+ t.target === this.zoomora && this.options.closeOnBackgroundClick && this.close();
165
+ }
166
+ handleContentClick(t) {
167
+ if (Date.now() - this.lastDragTime < 200) return;
168
+ if (this.header && this.header.contains(t.target)) return;
169
+ if (t.target.closest("button")) return;
170
+ const e = t.target.closest(".zoomora-media, .zoomora-video, .zoomora-iframe");
171
+ if (e) return void (e.classList.contains("zoomora-media") && !e.classList.contains("no-zoom") && this.toggleZoom());
172
+ if (t.target.closest(".zoomora-video-container")) {
173
+ if (t.target.closest(".zoomora-play-button")) return;
174
+ this.options.closeOnBackgroundClick && this.close();
175
+ return;
176
+ }
177
+ const s = t.target;
178
+ ((s.classList.contains("zoomora-content") || s.classList.contains("zoomora-slide-container") || s.classList.contains("zoomora-slide") || s.classList.contains("zoomora-slides-container") || "zoomoraContent" === s.id || "zoomoraSlidesContainer" === s.id) && this.options.closeOnBackgroundClick || this.options.closeOnBackgroundClick) && this.close();
179
+ }
180
+ handleMouseDown(t) {
181
+ this.startDrag(t);
182
+ }
183
+ handleMouseMove(t) {
184
+ this.drag(t);
185
+ }
186
+ handleMouseUp() {
187
+ this.endDrag();
188
+ }
189
+ handleTouchStart(t) {
190
+ this.startDrag(t);
191
+ }
192
+ handleTouchMove(t) {
193
+ this.drag(t);
194
+ }
195
+ handleTouchEnd() {
196
+ this.endDrag();
197
+ }
198
+ handleWheel(t) {
199
+ const e = this.content.querySelector(".zoomora-media");
200
+ if (!e || "IMG" !== e.tagName) return;
201
+ const s = this.calculateZoomLevels(e);
202
+ if (!s.canZoom) return;
203
+ t.preventDefault();
204
+ const o = s.levels[s.levels.length - 1], i = this.options.zoomStep || .1, n = t.deltaY < 0 ? 1 : -1;
205
+ let a = (this.currentScale || 1) + n * i * o;
206
+ if (a = Math.max(1, Math.min(o, a)), a === this.currentScale) return;
207
+ this.currentScale = a, this.isZoomed = a > 1, this.currentX = 0, this.currentY = 0, this.isZoomed ? (e.style.transform = `scale(${a})`, e.style.cursor = "grab", e.classList.add("zoomed")) : (e.style.transform = "", e.style.cursor = "pointer", e.classList.remove("zoomed"));
208
+ let r = 0;
209
+ s.levels.forEach((t, e) => {
210
+ Math.abs(t - a) < Math.abs(s.levels[r] - a) && (r = e);
211
+ }), e.dataset.zoomLevel = r.toString();
212
+ }
213
+ getImageSource(t) {
214
+ const e = t.dataset.src || t.getAttribute("href") || t.src || t.getAttribute("src");
215
+ return "video" === (t.dataset.type || "image") && e ? this.convertToEmbedUrl(e) : e;
216
+ }
217
+ convertToEmbedUrl(t) {
218
+ if (t.includes("youtube.com/embed/")) return t;
219
+ let e = null, s = null;
220
+ if (t.includes("youtube.com/watch")) {
221
+ const o = new URLSearchParams(t.split("?")[1]);
222
+ e = o.get("v");
223
+ const i = o.get("t");
224
+ i && (s = i.replace("s", ""));
225
+ } else if (t.includes("youtu.be/")) {
226
+ const o = t.split("/"), i = o[o.length - 1];
227
+ if (i.includes("?")) {
228
+ e = i.split("?")[0];
229
+ const t = new URLSearchParams(i.split("?")[1]).get("t");
230
+ t && (s = t.replace("s", ""));
231
+ } else e = i;
232
+ }
233
+ if (e) {
234
+ let t = `https://www.youtube.com/embed/${e}`;
235
+ const o = new URLSearchParams();
236
+ return s && o.append("start", s), o.append("rel", "0"), o.append("modestbranding", "1"), this.options.autoplayVideos && o.append("autoplay", "1"), o.toString() && (t += "?" + o.toString()), t;
237
+ }
238
+ return t;
239
+ }
240
+ getThumbnailSource(t) {
241
+ var e;
242
+ if (t.dataset.thumbnail) return t.dataset.thumbnail;
243
+ const s = null === (e = t.querySelector) || void 0 === e ? void 0 : e.call(t, "img"), o = t.getAttribute("src") || (null == s ? void 0 : s.getAttribute("src"));
244
+ return "video" === (t.dataset.type || "image") ? o : o || t.dataset.src || t.getAttribute("href");
245
+ }
246
+ getGroup(t) {
247
+ return this.options.useHref ? t.dataset.lightbox || t.dataset.gallery || "default" : t.dataset.zoomora || "default";
248
+ }
249
+ open(t) {
250
+ if (!t) return;
251
+ const e = this.getGroup(t);
252
+ let s;
253
+ s = this.options.useHref ? t.dataset.lightbox ? `[data-lightbox="${e}"]` : t.dataset.gallery ? `[data-gallery="${e}"]` : this.options.selector : `[data-zoomora="${e}"]`, this.items = Array.from(document.querySelectorAll(s)), this.currentIndex = Math.max(0, this.items.indexOf(t)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(t, this.currentIndex);
254
+ }
255
+ openImage(t, e = {}) {
256
+ const s = Array.isArray(t) ? t : [t];
257
+ this.items = s.map((t) => this.createVirtualItem("string" == typeof t ? { src: t } : t)), this.currentIndex = Math.max(0, Math.min(e.startIndex || 0, this.items.length - 1)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(this.items[this.currentIndex], this.currentIndex);
258
+ }
259
+ createVirtualItem({ src: t, thumb: e, type: s = "image", caption: o = "", alt: i = "" }) {
260
+ const n = e || t;
261
+ return {
262
+ dataset: {
263
+ src: t,
264
+ type: s,
265
+ caption: o
266
+ },
267
+ src: n,
268
+ alt: i,
269
+ title: o,
270
+ getAttribute: (t) => "src" === t ? n : null
271
+ };
272
+ }
273
+ _activateLightbox() {
274
+ this.isZoomed = !1, this.isFullscreen = !1, this.thumbnailsVisible = !0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.zoomora.classList.add("active"), document.body.style.overflow = "hidden", this.loadContent(), this.updateThumbnails(), this.updateCounter(), this.updateNavigation(), this.updateCaption(), this.updateButtons(), this.autoHideEnabled ? this.startAutoHideTimer() : this.showControls();
275
+ }
276
+ close() {
277
+ this.isFullscreen && this.exitFullscreen(), this.zoomora.classList.remove("active"), document.body.style.overflow = "";
278
+ const t = this.content.querySelector("video");
279
+ t && t.pause();
280
+ const e = this.content.querySelector("iframe");
281
+ e && (e.src = "about:blank"), this.isZoomed = !1, this.isFullscreen = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1;
282
+ const s = this.content.querySelector(".zoomora-media");
283
+ s && (s.classList.remove("zoomed"), s.style.transform = "", s.style.cursor = ""), this.zoomora.classList.remove("fullscreen"), this.updateButtons(), this.stopAutoHideTimer(), this.showControls(), "function" == typeof this.options.onClose && this.options.onClose(this.currentIndex);
284
+ }
285
+ prev() {
286
+ this.currentIndex > 0 && (this.currentIndex--, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onPrev && this.options.onPrev(this.currentIndex));
287
+ }
288
+ next() {
289
+ this.currentIndex < this.items.length - 1 && (this.currentIndex++, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onNext && this.options.onNext(this.currentIndex));
290
+ }
291
+ loadContent() {
292
+ if (!this.items[this.currentIndex]) return;
293
+ const t = this.items[this.currentIndex], e = this.getImageSource(t), s = t.dataset.type || "image";
294
+ e && (this.isZoomed = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.loading.style.display = "block", this.slidesContainer && (this.slidesContainer.innerHTML = ""), setTimeout(() => {
295
+ this.renderContent(e, s, t);
296
+ }, 100));
297
+ }
298
+ renderContent(t, e, s) {
299
+ const o = document.createElement("div");
300
+ o.className = "zoomora-slide-container";
301
+ const i = document.createElement("div");
302
+ let n;
303
+ i.className = "zoomora-slide " + ("slide" === this.options.transition ? "slide-effect" : "fade-effect"), i.style.opacity = "0", i.style.transform = "slide" === this.options.transition ? "translateX(100%)" : "scale(0.8)";
304
+ try {
305
+ switch (e) {
306
+ case "video":
307
+ if (t.endsWith(".mp4") || t.endsWith(".webm") || t.endsWith(".ogg")) {
308
+ const e = document.createElement("div");
309
+ e.className = "zoomora-video-container", n = document.createElement("video"), n.src = t, n.className = "zoomora-video", n.setAttribute("preload", "metadata");
310
+ const i = s.src || s.getAttribute("src");
311
+ i && n.setAttribute("poster", i);
312
+ const a = document.createElement("div");
313
+ a.className = "zoomora-play-button", a.innerHTML = "<svg viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M8 5v14l11-7z\"/></svg>", a.addEventListener("click", () => {
314
+ n.play(), a.style.display = "none", n.setAttribute("controls", "");
315
+ }), n.addEventListener("ended", () => {
316
+ a.style.display = "flex";
317
+ }), e.appendChild(n), e.appendChild(a), this.options.autoplayVideos && n.play().then(() => {
318
+ a.style.display = "none", n.setAttribute("controls", "");
319
+ }).catch(() => {}), o.appendChild(e);
320
+ } else n = document.createElement("iframe"), n.src = t, n.className = "zoomora-video", n.setAttribute("allowfullscreen", ""), n.setAttribute("allow", "autoplay; fullscreen; picture-in-picture"), n.setAttribute("frameborder", "0"), o.appendChild(n);
321
+ break;
322
+ case "iframe":
323
+ n = document.createElement("iframe"), n.src = t, n.className = "zoomora-iframe", n.setAttribute("frameborder", "0"), o.appendChild(n);
324
+ break;
325
+ default: n = document.createElement("img"), n.src = t, n.className = "zoomora-media", n.alt = s.alt || s.title || "", n.onload = () => {
326
+ this.loading.style.display = "none", this.checkZoomability(n), this.animateSlideIn(i);
327
+ }, n.onerror = () => {
328
+ this.loading.style.display = "none", this.animateSlideIn(i);
329
+ }, o.appendChild(n);
330
+ }
331
+ i.appendChild(o), this.slidesContainer.innerHTML = "", this.slidesContainer.appendChild(i), "image" !== e && (this.loading.style.display = "none", this.animateSlideIn(i));
332
+ } catch (t) {
333
+ this.loading.style.display = "none";
334
+ }
335
+ }
336
+ animateSlideIn(t) {
337
+ t.offsetHeight, t.classList.add("active"), "slide" === this.options.transition ? (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "translateX(0)", t.style.opacity = "1") : (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "scale(1)", t.style.opacity = "1");
338
+ }
339
+ toggleAutoHide() {
340
+ this.autoHideEnabled = !this.autoHideEnabled;
341
+ const t = document.getElementById("zoomoraAutoHideBtn");
342
+ this.autoHideEnabled ? (t.classList.add("active"), t.title = "Disable Auto-Hide Controls", this.startAutoHideTimer()) : (t.classList.remove("active"), t.title = "Enable Auto-Hide Controls", this.stopAutoHideTimer(), this.showControls());
343
+ }
344
+ handleUserActivity() {
345
+ this.autoHideEnabled && (this.showControls(), this.startAutoHideTimer());
346
+ }
347
+ startAutoHideTimer() {
348
+ this.stopAutoHideTimer(), this.autoHideTimeout = setTimeout(() => {
349
+ this.hideControls();
350
+ }, this.options.autoHideDelay);
351
+ }
352
+ stopAutoHideTimer() {
353
+ this.autoHideTimeout && (clearTimeout(this.autoHideTimeout), this.autoHideTimeout = null);
354
+ }
355
+ showControls() {
356
+ this.isControlsVisible || (this.isControlsVisible = !0, this.zoomora.classList.remove("controls-hidden"), this.header && (this.header.style.transform = "translateY(0)", this.header.style.opacity = "1"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(0)", this.thumbs.style.opacity = "1"), this.prevBtn && (this.prevBtn.style.transform = "translateX(0)", this.prevBtn.style.opacity = "1"), this.nextBtn && (this.nextBtn.style.transform = "translateX(0)", this.nextBtn.style.opacity = "1"));
357
+ }
358
+ hideControls() {
359
+ this.isControlsVisible && (this.isControlsVisible = !1, this.zoomora.classList.add("controls-hidden"), this.header && (this.header.style.transform = "translateY(-100%)", this.header.style.opacity = "0"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(100%)", this.thumbs.style.opacity = "0"), this.prevBtn && (this.prevBtn.style.transform = "translateX(-100%)", this.prevBtn.style.opacity = "0"), this.nextBtn && (this.nextBtn.style.transform = "translateX(100%)", this.nextBtn.style.opacity = "0"));
360
+ }
361
+ checkZoomability(t) {
362
+ if (!t || !t.naturalWidth || !t.naturalHeight) return;
363
+ const e = t.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = i > s || n > o, r = i / s, l = n / o, h = Math.max(r, l);
364
+ t.dataset.zoomRatio = h.toString(), t.dataset.naturalWidth = i.toString(), t.dataset.naturalHeight = n.toString(), t.dataset.renderedWidth = s.toString(), t.dataset.renderedHeight = o.toString(), a && h > 1.1 ? t.classList.remove("no-zoom") : t.classList.add("no-zoom");
365
+ }
366
+ calculateZoomLevels(t) {
367
+ if (!t || !t.naturalWidth || !t.naturalHeight) return {
368
+ canZoom: !1,
369
+ levels: [],
370
+ currentLevel: 0
371
+ };
372
+ const e = this.content.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = s / i, r = o / n, l = Math.min(a, r);
373
+ if (l >= .95) return {
374
+ canZoom: !1,
375
+ levels: [],
376
+ currentLevel: 0
377
+ };
378
+ const h = Number(this.options.maxZoomScale), c = Number.isFinite(h) && h > 0 ? Math.max(1, h) : 3, d = [1];
379
+ [
380
+ 1.5,
381
+ 2,
382
+ 3,
383
+ 4,
384
+ 5
385
+ ].forEach((t) => {
386
+ t <= c && l * t <= 1 && d.push(t);
387
+ });
388
+ const u = Math.min(1 / l, c);
389
+ return u > d[d.length - 1] && d.push(u), {
390
+ canZoom: d.length > 1,
391
+ levels: d,
392
+ currentLevel: 0,
393
+ baseScale: l,
394
+ naturalWidth: i,
395
+ naturalHeight: n
396
+ };
397
+ }
398
+ updateCounter() {
399
+ this.options.showCounter && this.counter && (this.counter.textContent = `${this.currentIndex + 1} / ${this.items.length}`);
400
+ }
401
+ updateCaption() {
402
+ if (!this.caption || !this.items[this.currentIndex]) return;
403
+ const t = this.items[this.currentIndex], e = t.dataset.caption || t.title || "";
404
+ e ? (this.caption.textContent = e, this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1", this.caption.style.pointerEvents = "auto", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease") : (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0", this.caption.style.pointerEvents = "none", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease");
405
+ }
406
+ updateThumbnails() {
407
+ if (this.options.showThumbnails && this.thumbs) {
408
+ if (1 === this.items.length) return this.caption.classList.add("single-item-thumbnail"), void (this.thumbs.style.display = "none");
409
+ this.caption.classList.remove("single-item-thumbnail"), this.thumbs.style.display = "flex", this.thumbs.innerHTML = "", this.items.forEach((t, e) => {
410
+ const s = document.createElement("div");
411
+ s.className = "zoomora-thumb", e === this.currentIndex && s.classList.add("active");
412
+ const o = document.createElement("img"), i = this.getThumbnailSource(t);
413
+ i && (o.src = i, o.alt = t.alt || t.title || "", o.onerror = () => {
414
+ s.style.display = "none";
415
+ }), s.appendChild(o), s.addEventListener("click", () => {
416
+ this.currentIndex = e, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption();
417
+ }), this.thumbs.appendChild(s);
418
+ });
419
+ }
420
+ }
421
+ updateNavigation() {
422
+ const t = document.getElementById("zoomoraPrevBtn"), e = document.getElementById("zoomoraNextBtn");
423
+ t && (t.style.display = this.currentIndex > 0 ? "flex" : "none"), e && (e.style.display = this.currentIndex < this.items.length - 1 ? "flex" : "none");
424
+ }
425
+ updateButtons() {
426
+ const t = document.getElementById("zoomoraFullscreenBtn"), e = document.getElementById("zoomoraCollapseBtn");
427
+ t && e && (this.isFullscreen ? (t.style.display = "none", e.style.display = "flex") : (t.style.display = "flex", e.style.display = "none"));
428
+ }
429
+ toggleZoom() {
430
+ const t = this.content.querySelector(".zoomora-media");
431
+ if (!t || "IMG" !== t.tagName) return;
432
+ const e = this.calculateZoomLevels(t);
433
+ if (!e.canZoom) return;
434
+ t.dataset.zoomLevel || (t.dataset.zoomLevel = "0");
435
+ let s = parseInt(t.dataset.zoomLevel) || 0;
436
+ s++, s >= e.levels.length && (s = 0);
437
+ const o = e.levels[s];
438
+ t.dataset.zoomLevel = s.toString(), 0 === s ? (this.isZoomed = !1, this.isDragging = !1, t.classList.remove("dragging"), t.style.transform = "", t.style.cursor = "pointer", t.classList.remove("zoomed"), this.currentX = 0, this.currentY = 0, this.currentScale = 1) : (this.isZoomed = !0, this.currentScale = o, this.currentX = 0, this.currentY = 0, t.style.transform = `translate(0px, 0px) scale(${o})`, t.style.cursor = "grab", t.classList.add("zoomed"));
439
+ }
440
+ toggleFullscreen() {
441
+ this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen();
442
+ }
443
+ enterFullscreen() {
444
+ const t = this.zoomora;
445
+ try {
446
+ t.requestFullscreen ? t.requestFullscreen().then(() => {
447
+ this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
448
+ }).catch((t) => {
449
+ this.fallbackFullscreen();
450
+ }) : t.webkitRequestFullscreen ? (t.webkitRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.mozRequestFullScreen ? (t.mozRequestFullScreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.msRequestFullscreen ? (t.msRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : this.fallbackFullscreen();
451
+ } catch (t) {
452
+ this.fallbackFullscreen();
453
+ }
454
+ }
455
+ exitFullscreen() {
456
+ if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) try {
457
+ document.exitFullscreen ? document.exitFullscreen().then(() => {
458
+ this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
459
+ }).catch((t) => {
460
+ this.fallbackExitFullscreen();
461
+ }) : document.webkitExitFullscreen ? (document.webkitExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.mozCancelFullScreen ? (document.mozCancelFullScreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.msExitFullscreen ? (document.msExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : this.fallbackExitFullscreen();
462
+ } catch (t) {
463
+ this.fallbackExitFullscreen();
464
+ }
465
+ else this.fallbackExitFullscreen();
466
+ }
467
+ fallbackFullscreen() {
468
+ this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
469
+ }
470
+ fallbackExitFullscreen() {
471
+ this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
472
+ }
473
+ toggleThumbnails() {
474
+ if (1 !== this.items.length && (this.thumbnailsVisible = !this.thumbnailsVisible, this.thumbs)) {
475
+ if (this.thumbs.classList.toggle("thumbs-hidden", !this.thumbnailsVisible), !this.caption || !this.items[this.currentIndex]) return;
476
+ const t = this.items[this.currentIndex];
477
+ (t.dataset.caption || t.title) && this.thumbs.classList.contains("thumbs-hidden") ? (this.caption.style.bottom = "20px", this.caption.style.transition = "bottom 0.3s ease, transform 0.3s ease") : this.caption.style.bottom = "120px";
478
+ }
479
+ }
480
+ startDrag(t) {
481
+ const e = this.content.querySelector(".zoomora-media");
482
+ if (!e || !this.isZoomed) return;
483
+ this.isDragging = !0, e.classList.add("dragging"), e.style.cursor = "grabbing", this.startX = t.clientX || t.touches && t.touches[0].clientX || 0, this.startY = t.clientY || t.touches && t.touches[0].clientY || 0;
484
+ const s = window.getComputedStyle(e).transform;
485
+ if (s && "none" !== s) {
486
+ const t = new DOMMatrix(s);
487
+ this.currentX = t.m41, this.currentY = t.m42;
488
+ } else this.currentX = 0, this.currentY = 0;
489
+ t.preventDefault();
490
+ }
491
+ drag(t) {
492
+ if (!this.isDragging) return;
493
+ t.preventDefault();
494
+ const e = this.content.querySelector(".zoomora-media");
495
+ if (!e) return;
496
+ const s = t.clientX || t.touches && t.touches[0].clientX || 0, o = t.clientY || t.touches && t.touches[0].clientY || 0, i = s - this.startX, n = o - this.startY;
497
+ let a = this.currentX + i, r = this.currentY + n;
498
+ const l = this.content.getBoundingClientRect(), h = e.getBoundingClientRect(), c = Math.max(0, (h.width - l.width) / 2), d = Math.max(0, (h.height - l.height) / 2);
499
+ a = c > 0 ? Math.max(-c, Math.min(c, a)) : 0, r = d > 0 ? Math.max(-d, Math.min(d, r)) : 0, e.style.transform = `translate(${a}px, ${r}px) scale(${this.currentScale})`, this.startX = s, this.startY = o, this.currentX = a, this.currentY = r;
500
+ }
501
+ endDrag() {
502
+ if (!this.isDragging) return;
503
+ this.isDragging = !1, this.lastDragTime = Date.now();
504
+ const t = this.content.querySelector(".zoomora-media");
505
+ t && (t.classList.remove("dragging"), this.isZoomed && (t.style.cursor = "grab"));
506
+ }
507
+ goTo(t) {
508
+ t < 0 || t >= this.items.length || (this.currentIndex = t, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption());
509
+ }
510
+ getCurrentIndex() {
511
+ return this.currentIndex;
512
+ }
513
+ getTotalItems() {
514
+ return this.items.length;
515
+ }
516
+ isOpen() {
517
+ return this.zoomora && this.zoomora.classList.contains("active");
518
+ }
519
+ updateOptions(t) {
520
+ this.options = i(i({}, this.options), t);
521
+ }
522
+ refresh() {
523
+ if (this.isOpen()) {
524
+ const t = this.items[this.currentIndex];
525
+ t && this.open(t);
526
+ }
527
+ }
528
+ destroy() {
529
+ this.isInitialized && (this.isOpen() && this.close(), this.stopAutoHideTimer(), this.eventListeners.forEach((t, e) => {
530
+ t.forEach(({ element: t, event: e, handler: s, options: o }) => {
531
+ t && t.removeEventListener && t.removeEventListener(e, s, o);
532
+ });
533
+ }), this.eventListeners.clear(), this.zoomora && this.zoomora.parentNode && this.zoomora.parentNode.removeChild(this.zoomora), this.isInitialized = !1, this.items = [], this.currentIndex = 0, this.zoomora = null, this.content = null, this.counter = null, this.thumbs = null, this.loading = null, this.caption = null);
534
+ }
535
+ };
536
+ export { n as default };