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