PageSourceSearch

https://schoolmaker.com/assets/controllers/lightbox_controller-bd8…ba8b66451d9465f5f25c01868979b82eb2e4ac8c.js

js schoolmaker.com collected 2026-09-26 02:12:57 UTC 11,135 bytes, 1 lines download raw bytes

1import{Controller}from"@hotwired/stimulus";import PhotoSwipe from"photoswipe";export default class extends Controller{static targets=["trigger","gallery"];static values={options:Object,gallerySelector:String,showDownloadButton:{type:Boolean,default:!0},showZoomIndicator:{type:Boolean,default:!0},showDotsIndicator:{type:Boolean,default:!0}};connect(){this.photoSwipeHostDialog=null,this.boundHandleGalleryClick=this.handleGalleryClick.bind(this),this.boundHandleSingleClick=this.handleSingleClick.bind(this),this.loadCSS(),this.setupGallery()}loadCSS(){if(!document.querySelector('link[href*="photoswipe.css"]')){const t=document.createElement("link");t.rel="stylesheet",t.href="https://cdn.jsdelivr.net/npm/[email protected]/dist/photoswipe.css",document.head.appendChild(t)}}setupGallery(){this.hasGalleryTarget?this.galleryTarget.addEventListener("click",this.boundHandleGalleryClick):this.hasTriggerTarget&&this.triggerTargets.forEach(t=>{t.addEventListener("click",this.boundHandleSingleClick)})}handleGalleryClick(t){const e=t.target.closest("a[data-pswp-src]");if(!e)return;t.preventDefault();const o=this.galleryTarget.querySelectorAll("a[data-pswp-src]"),n=Array.from(o).map(t=>this.getItemData(t)),i=Array.from(o).indexOf(e);this.openPhotoSwipe(n,i)}handleSingleClick(t){t.preventDefault();const e=t.currentTarget,o=[this.getItemData(e)];this.openPhotoSwipe(o,0)}getItemData(t){const e={src:t.dataset.pswpSrc||t.href,width:parseInt(t.dataset.pswpWidth)||0,height:parseInt(t.dataset.pswpHeight)||0,alt:t.dataset.pswpAlt||""},o=t.dataset.pswpCaption;if(o&&(e.caption=o),!e.width||!e.height){const o=t.querySelector("img");if(o&&o.complete&&o.naturalWidth){const t=o.naturalWidth/o.naturalHeight;t>1.2?(e.width=2400,e.height=Math.round(2400/t)):t<.8?(e.height=2400,e.width=Math.round(2400*t)):(e.width=2e3,e.height=2e3)}else e.width=1920,e.height=1080;e.needsUpdate=!0}return e}openPhotoSwipe(t,e){this.photoSwipe?.destroy();const{appendTarget:o,hostDialog:n}=this.getAppendTarget(),i={index:e||0,appendToEl:o,...this.defaultOptions,...this.optionsValue},r=new PhotoSwipe({dataSource:t,...i});let a;this.photoSwipe=r,r.on("destroy",()=>{this.photoSwipe===r&&(this.photoSwipe=null)});const s=(()=>{let t=!1;return()=>{!t&&n&&(t=!0,a&&n.removeEventListener("cancel",a),this.teardownPhotoSwipeHost(n))}})();n&&(a=t=>{t.preventDefault(),r.close()},n.addEventListener("cancel",a),r.on("destroy",s));const l=()=>{if(!r.currSlide||!r.currSlide.container)return;const t=r.currSlide.currZoomLevel,e=r.currSlide.container,o=e.querySelector(".pswp__img");e.style.cursor="default",o&&(r.currSlide.isZoomable()?t<.95||t<1.5||t<2?(o.style.cursor="zoom-in",o.style.setProperty("cursor","zoom-in","important")):(o.style.cursor="zoom-out",o.style.setProperty("cursor","zoom-out","important")):(o.style.cursor="default",o.style.setProperty("cursor","default","important")))};let p;r.on("firstUpdate",()=>{const t="pswp-custom-cursor-override";if(!document.getElementById(t)){const e=document.createElement("style");e.id=t,e.textContent="\n          /* Override PhotoSwipe's default cursor styles */\n          .pswp__img {\n            /* Cursor will be set by JavaScript */\n          }\n          .pswp__img--placeholder {\n            cursor: default !important;\n          }\n          .pswp__container {\n            cursor: default !important;\n          }\n          .pswp__container.pswp__container--dragging {\n            cursor: grabbing !important;\n          }\n          .pswp__container.pswp__container--dragging .pswp__img {\n            cursor: grabbing !important;\n          }\n          /* Prevent PhotoSwipe from setting zoom-out cursor */\n          .pswp--zoom-allowed .pswp__img {\n            /* Cursor controlled by JavaScript */\n          }\n          .pswp__zoom-wrap {\n            cursor: inherit !important;\n          }\n        ",document.head.appendChild(e)}}),r.on("zoomPanUpdate",()=>{setTimeout(l,0)}),r.on("change",l),r.on("afterInit",l),r.on("slideDestroy",l),r.on("contentActivate",l),r.on("openingAnimationStart",()=>{p=setInterval(l,50)}),r.on("close",()=>{p&&clearInterval(p),s()}),r.on("imageClickAction",t=>{t.preventDefault();const e=r.currSlide.currZoomLevel;let o;o=e<.95?1:e<1.5?1.5:e<2?2:r.currSlide.zoomLevels.fit||r.currSlide.zoomLevels.min||r.currSlide.min||.5;const n={x:t.originalEvent.clientX,y:t.originalEvent.clientY};r.currSlide.zoomTo(o,n,333,!1)}),r.on("uiRegister",()=>{r.ui.registerElement({name:"caption",order:9,isButton:!1,appendTo:"root",html:"Caption text",onInit:(t,e)=>{t.style.cssText="\n            background: rgba(0, 0, 0, 0.75);\n            color: white;\n            font-size: 14px;\n            line-height: 1.5;\n            padding: 10px 15px;\n            position: absolute;\n            bottom: 0;\n            left: 0;\n            right: 0;\n            max-height: 30%;\n            overflow: auto;\n            text-align: center;\n          ",e.on("change",()=>{const o=e.currSlide.data;t.innerHTML=o.caption||"",t.style.display=o.caption?"block":"none"})}}),this.showDownloadButtonValue&&r.ui.registerElement({name:"download-button",order:8,isButton:!0,tagName:"a",title:"Download image",ariaLabel:"Download image",html:{isCustomSVG:!0,inner:'<path d="M20.5 14.3 17.1 18V10h-2.2v7.9l-3.4
1-3.6L10 16l6 6.1 6-6.1ZM23 23H9v2h14Z" id="pswp__icn-download"/>',outlineID:"pswp__icn-download"},onInit:(t,e)=>{t.setAttribute("download",""),t.setAttribute("target","_blank"),t.setAttribute("rel","noopener"),e.on("change",()=>{t.href=e.currSlide.data.src;const o=e.currSlide.data.src.split("/").pop().split("?")[0];t.setAttribute("download",o||"image.jpg")})}}),this.showZoomIndicatorValue&&r.ui.registerElement({name:"zoom-level-indicator",order:9,onInit:(t,e)=>{let o;t.style.cssText='\n              background: rgba(0, 0, 0, 0.75);\n              margin-top: auto;\n              margin-bottom: auto;\n              align-items: center;\n              justify-content: center;\n              color: white;\n              height: fit-content;\n              font-size: 14px;\n              line-height: 1;\n              padding: 8px 12px;\n              border-radius: 8px;\n              pointer-events: none;\n              font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n            ';let n=!1;const i=()=>{if(e.currSlide){const i=Math.round(100*e.currSlide.currZoomLevel);t.innerText=`${i}%`,t.style.display="block",t.style.opacity="1",o&&clearTimeout(o),100!==i||n||(o=setTimeout(()=>{n||(t.style.opacity="0",setTimeout(()=>{t.style.display="none"},200))},2e3))}};e.template.addEventListener("mouseenter",()=>{n=!0,o&&clearTimeout(o),e.currSlide&&(t.style.display="block",t.style.opacity="1")}),e.template.addEventListener("mouseleave",()=>{n=!1,i()}),t.style.transition="opacity 0.2s ease",e.on("zoomPanUpdate",i),e.on("change",i),i()}}),this.showDotsIndicatorValue&&r.getNumItems()>1&&r.ui.registerElement({name:"bulletsIndicator",className:"pswp__bullets-indicator",appendTo:"wrapper",onInit:(t,e)=>{const o=[];let n,i=-1;t.style.cssText="\n              display: flex;\n              flex-direction: row;\n              align-items: center;\n              justify-content: center;\n              position: absolute;\n              bottom: 50px;\n              left: 50%;\n              transform: translateX(-50%);\n              z-index: 10;\n              pointer-events: auto;\n            ";for(let i=0;i<e.getNumItems();i++)n=document.createElement("button"),n.className="pswp__bullet",n.setAttribute("aria-label",`Go to slide ${i+1}`),n.style.cssText="\n                width: 8px;\n                height: 8px;\n                border-radius: 50%;\n                background: rgba(255, 255, 255, 0.5);\n                margin: 0 4px;\n                padding: 0;\n                border: none;\n                cursor: pointer;\n                transition: all 0.2s ease;\n                box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.1);\n              ",n.onmouseover=t=>{t.target.classList.contains("pswp__bullet--active")||(t.target.style.background="rgba(255, 255, 255, 0.7)")},n.onmouseout=t=>{t.target.classList.contains("pswp__bullet--active")||(t.target.style.background="rgba(255, 255, 255, 0.5)")},n.onclick=(t=>()=>{e.goTo(t)})(i),t.appendChild(n),o.push(n);e.on("change",()=>{i>=0&&(o[i].classList.remove("pswp__bullet--active"),o[i].style.background="rgba(255, 255, 255, 0.5)",o[i].style.transform="scale(1)",o[i].style.boxShadow="0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.1)"),o[e.currIndex].classList.add("pswp__bullet--active"),o[e.currIndex].style.background="rgba(255, 255, 255, 1)",o[e.currIndex].style.transform="scale(1.2)",o[e.currIndex].style.boxShadow="0 2px 6px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.2)",i=e.currIndex})}})}),r.on("imageSrcChange",t=>{const{content:e,isLazy:o}=t;if(e.data.needsUpdate&&!o){const t=()=>{const t=e.pictureElement.querySelector("img");t&&t.naturalWidth&&t.naturalHeight&&(e.width=t.naturalWidth,e.height=t.naturalHeight,e.updateContentSize(!0))};e.pictureElement&&e.pictureElement.addEventListener("load",t,{once:!0})}}),r.init()}get defaultOptions(){return{showHideAnimationType:"zoom",pswpModule:()=>import("photoswipe"),preload:[1,2],wheelToZoom:!0,padding:{top:20,bottom:40,left:20,right:20},maxZoomLevel:4,getDoubleTapZoom:(t,e)=>{if(t){const t=e.instance.currSlide.currZoomLevel;if(t<.95)return 1;if(t<1.5)return 2;if(t<2.5)return 3;{const t=e.instance.currSlide;return t.zoomLevels.fit||t.zoomLevels.min||t.min||1}}return e.instance.currSlide.currZoomLevel<.95?1:2},closeOnVerticalDrag:!1,tapAction:!1,clickToCloseNonZoomable:!1,pinchToClose:!1}}
1getAppendTarget(){if(!this.element.closest("dialog[open]"))return{appendTarget:document.body,hostDialog:null};this.ensurePhotoSwipeHostStyles(),this.teardownPhotoSwipeHost();const t=document.createElement("dialog");return t.className="pswp-host-dialog",t.setAttribute("data-lightbox-pswp-host","true"),t.setAttribute("aria-label","Image viewer"),document.body.appendChild(t),t.showModal(),this.photoSwipeHostDialog=t,{appendTarget:t,hostDialog:t}}ensurePhotoSwipeHostStyles(){const t="pswp-host-dialog-styles";if(document.getElementById(t))return;const e=document.createElement("style");e.id=t,e.textContent="\n      dialog.pswp-host-dialog {\n        margin: 0;\n        padding: 0;\n        border: none;\n        width: 100vw;\n        max-width: none;\n        height: 100vh;\n        max-height: none;\n        background: transparent;\n        overflow: visible;\n      }\n\n      dialog.pswp-host-dialog::backdrop {\n        background: transparent;\n      }\n    ",document.head.appendChild(e)}teardownPhotoSwipeHost(t=this.photoSwipeHostDialog){t&&(t.open&&t.close(),t.remove(),this.photoSwipeHostDialog===t&&(this.photoSwipeHostDialog=null))}disconnect(){this.photoSwipe?.destroy(),this.photoSwipe=null,this.teardownPhotoSwipeHost(),this.hasGalleryTarget?this.galleryTarget.removeEventListener("click",this.boundHandleGalleryClick):this.hasTriggerTarget&&this.triggerTargets.forEach(t=>{t.removeEventListener("click",this.boundHandleSingleClick)})}}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.