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