PageSourceSearch

https://us.popunderwear.com/cdn/shop/t/234/assets/media-gallery.js?v=171575812713067022391789630092

js popunderwear.com collected 2026-10-09 23:04:28 UTC 10,570 bytes, 2 lines download raw bytes

1import{SlideSection}from"@NextSkyTheme/slide";import{LazyLoader}from"@NextSkyTheme/lazy-load";import{eventModal}from"@NextSkyTheme/modal";import PhotoSwipeLightbox from"@NextSkyTheme/photo-swipe-lightbox";import{CustomElement}from"@NextSkyTheme/safari-element-patch";import*as NextSkyTheme from"@NextSkyTheme/global";class MediaGallery extends SlideSection{constructor(){super(),this.init(),this.mobile=this.dataset.mobile}get dataImageZoom(){return this.hasAttribute("data-image-zoom")?this.getAttribute("data-image-zoom"):"none"}get mediaPosition(){return this.hasAttribute("data-media-position")?this.getAttribute("data-media-position"):"left"}get zoomPaneSide(){return document.documentElement.dir==="rtl"||this.mediaPosition==="right"?"left":"right"}getZoomImageSource(image){if(!image)return"";const srcset=image.currentSrc||image.dataset.srcset||image.srcset;if(srcset){const candidates=srcset.split(",").map(candidate=>candidate.trim().split(/\s+/)[0]).filter(Boolean);if(candidates.length)return candidates[candidates.length-1]}return image.currentSrc||image.src||""}init(){if(this.querySelector(".product__media-gallery").classList.contains("product-thumbnail")){let thumbnail=this.initSlideMediaGallery("thumbnail");this.initSlideMediaGallery("main",thumbnail)}let inlinePane=767;this.dataImageZoom=="zoom_inner"&&(inlinePane=4800),setTimeout(()=>{window.innerWidth>767&&this.querySelectorAll(".gallery_zoom_image").forEach((element,index)=>{const img=element.querySelector("img");let zoomImageSource=this.getZoomImageSource(img);try{const url=new URL(zoomImageSource);if(url.searchParams.delete("width"),zoomImageSource=url.toString(),!img||!zoomImageSource||(element.setAttribute("data-zoom",zoomImageSource),element.dataset.driftBound==="true"))return;element.dataset.driftBound="true",new Drift(element,{paneContainer:document.body,inlinePane,containInline:!0,zoomFactor:2.5,zoomMode:this.dataImageZoom,zoomPaneSide:this.zoomPaneSide,sourceAttribute:"data-zoom",triggerImage:img})}catch{return}})},500)}}customElements.get("media-gallery")||customElements.define("media-gallery",MediaGallery);class GridGalleryThumbnail extends HTMLElement{constructor(){super(),this.actionScroll=this.querySelectorAll(".action-grid-item"),this.MediaGalleryThumbnailHtml=this.innerHTML}connectedCallback(){this.actionScroll.forEach(action=>{action?.addEventListener("click",()=>{this.setActive(action),this.scrollGallery(action)}),action?.addEventListener("keypress",e=>{e.key==="Enter"&&(this.setActive(action),this.scrollGallery(action))})})}setActive(activeItem){this.querySelectorAll(".action-grid-item").forEach(item=>item.classList.remove("active")),activeItem.classList.add("active")}scrollGallery(action){if(window.innerWidth<=767)return;const index=action.dataset.position,gallery=this.closest("media-gallery");if(!gallery)return;gallery.querySelector(`grid-gallery .grid-item[data-position="${index}"]`)?.scrollIntoView({behavior:"smooth",block:"start"})}bindDesktopActions(){this.innerHTML=this.MediaGalleryThumbnailHtml,new LazyLoader(".image-lazy-load"),this.querySelectorAll(".action-grid-item").forEach(action=>{action?.addEventListener("click",()=>{this.setActive(action),this.scrollGallery(action)}),action?.addEventListener("keypress",e=>{e.key==="Enter"&&(this.setActive(action),this.scrollGallery(action))})})}}customElements.get("grid-gallery-thumbnail")||customElements.define("grid-gallery-thumbnail",GridGalleryThumbnail);class GridGallery extends MediaGallery{constructor(){super(),this.MediaGalleryHtml=this.innerHTML,this.init()}init(){if(this.classList.contains("two-columns-carousel"))this.MediaGalleryHtml&&this.initSlideColumnsGallery("gird");else if(this.MediaGalleryHtml){let width=window.innerWidth;window.addEventListener("resize",()=>{const newWidth=window.innerWidth;newWidth<=767&&width>767&&this.actionOnMobile(),newWidth>767&&width<=767&&this.actionOutMobile(),width=newWidth}),width<=767?this.actionOnMobile():this.actionOutMobile()}}initSlideColumnsGallery(){this.classList.add("swiper","swiper-wrapper-main");const actions=this.querySelector(".swiper-actions").outerHTML,pagination=this.querySelector(".swiper-pagination").outerHTML,html=this.MediaGalleryHtml.replaceAll("grid-item","swiper-slide").replaceAll(actions,"").replaceAll(pagination,""),wrapper=`${actions}<div class='swiper-wrapper'>${html}</div>${pagination}`;this.innerHTML=wrapper,this.initSlideMediaGallery("columns"),new LazyLoader(".image-lazy-load")}actionOnMobile(){this.classList.add("swiper","swiper-wrapper-main"),this.classList.remove("grid","grid-cols","stacked");const actions=this.querySelector(".swiper-actions").outerHTML,pagination=this.querySelector(".swiper-pagination").outerHTML,html=this.MediaGalleryHtml.replaceAll("grid-item","swiper-slide").replaceAll(actions,"").replaceAll(pagination,""),wrapper=`${actions}<div class='swiper-wrapper'>${html}</div>${pagination}`;if(this.innerHTML=wrapper,this.closest("media-gallery").querySelector("grid-gallery-thumbn
1ail")){let thumbnail=this.initSlideMediaGallery("thumbnail");this.initSlideMediaGallery("main",thumbnail)}else this.initSlideMediaGallery("gird");new LazyLoader(".image-lazy-load")}actionOutMobile(){this.classList.remove("swiper","swiper-wrapper-main"),this.classList.contains("grid-swiper-mobile")?this.classList.add("grid","grid-cols"):this.classList.add("stacked","grid"),this.innerHTML=this.MediaGalleryHtml;const galleryThumbnail=this.closest("media-gallery").querySelector("grid-gallery-thumbnail");galleryThumbnail&&galleryThumbnail?.bindDesktopActions(),new LazyLoader(".image-lazy-load")}}customElements.get("grid-gallery")||customElements.define("grid-gallery",GridGallery);class QuickViewGallery extends GridGallery{constructor(){super(),this.MediaGalleryHtml=this.innerHTML,this.quickView=document.querySelector("quickview-drawer"),this.slide=null,this.initQuickView()}initQuickView(){if(this.MediaGalleryHtml){let width=window.innerWidth;window.addEventListener("resize",()=>{const newWidth=window.innerWidth;newWidth<=767&&width>767&&eventModal(this.quickView,"close",!1),newWidth>767&&width<=767&&eventModal(this.quickView,"close",!1),width=newWidth}),width<=767?this.actionOnMobile():this.actionOutMobile()}}async actionOnMobile(){this.slide=this.initSlideMediaGallery("QuickView"),this.style.maxHeight="auto",this.style.minHeight="auto"}async actionOutMobile(){this.slide=this.initSlideMediaGallery("QuickView"),this.style.maxHeight=this.closest(".drawer__body").offsetHeight-40+"px",this.style.minHeight="calc(100vh - 40px)"}}customElements.get("quick-view-gallery")||customElements.define("quick-view-gallery",QuickViewGallery);class MediaZoomButton extends HTMLButtonElement{constructor(){super(),this.init()}init(){this.addEventListener("click",this.onButtonClick)}get gallery(){return this.closest("media-gallery")}onButtonClick(){if(this.closest(".pswp__item"))return;let width=window.innerWidth,returnFocus=!0;width<=767&&(returnFocus=!1);const lightbox=new PhotoSwipeLightbox({bgOpacity:1,pswpModule:()=>import(importJs.pswpModule),allowPanToNext:!1,allowMouseDrag:!0,wheelToZoom:!1,returnFocus,zoom:!1,arrowPrev:!1,arrowNext:!1,close:!1,loop:!1});lightbox.on("contentLoad",event=>{const{content}=event;(content.type==="video"||content.type==="external_video"||content.type==="model")&&(event.preventDefault(),content.element=document.createElement("div"),content.element.className="pswp__video-container",content.element.appendChild(content.data.domElement.cloneNode(!0)))}),lightbox.on("uiRegister",()=>{const{pswp}=lightbox;pswp?.ui.registerElement({name:"close-zoom",isButton:!0,order:2,tagName:"button",html:'<svg width="14" height="14" viewBox="0 0 14 14" fill="none" class="transition-short will-change heading-color"><use href="#icon-close"></use></svg>',onClick:()=>{pswp.close()}}),pswp?.ui.registerElement({name:"next",ariaLabel:"Next slide",order:3,isButton:!0,html:'<svg width="6" height="11" fill="none"><use href="#icon-next"></use></svg>',onClick:(event,el)=>{pswp&&pswp.getNumItems()>0&&pswp.currIndex<pswp.getNumItems()-1&&pswp.next()}}),pswp?.ui.registerElement({name:"prev",ariaLabel:"Previous slide",order:1,isButton:!0,html:'<svg width="6" height="11" fill="none"><use href="#icon-back"></use></svg>',onClick:(event,el)=>{pswp&&pswp.getNumItems()>0&&pswp.currIndex>0&&pswp.prev()}})}),lightbox.on("afterInit",()=>{const{pswp}=lightbox;if(!pswp)return;const updateButtons=()=>{const nextBtn=pswp.element.querySelector('[data-element="next"]'),prevBtn=pswp.element.querySelector('[data-element="prev"]');nextBtn&&prevBtn&&(nextBtn.disabled=pswp.currIndex>=pswp.getNumItems()-1,prevBtn.disabled=pswp.currIndex<=0)};pswp.on("change",updateButtons),updateButtons()}),lightbox.init();const index=(this.closest(".media-gallery__image")||this.closest(".media-gallery__local-video")||this.closest(".media-gallery__external-video")).getAttribute("data-position"),items=this.gallery.querySelectorAll("[media-gallery]");let dataSource=Array.from(items).filter(element=>element.clientWidth>0).map(media=>{const image=media.querySelector("img");if(media.getAttribute("media-gallery")==="image")return{thumbnailElement:image,src:image.currentSrc||image.src,srcset:image.dataset.srcset?image.dataset.srcset:image.srcset,width:parseInt(image.getAttribute("width")),height:parseInt(image.getAttribute("height")),alt:image.alt,mediaType:"image",thumbCropped:!0};if(media.getAttribute("media-gallery")==="video"||media.getAttribute("media-gallery")==="external_video"||media.getAttribute("media-gallery")==="model"){const video=media.querySelector("video-product-gallery")||media.querySelector("[media-model]")||media;return{thumbnailElement:image,domElement:video,type:media.getAttribute("media-gallery"),src:image?image.src:"",srcset:image?image.srcset:"",msrc:image?image.src:"",width:video?parseInt(video.getAttribute("width")):800,height:video?parseInt(video.getAttribute("height")):800,alt:image?image.alt:"",mediaType:"external",thumbCropped:!0}}});lightbox.loadAndOpen(index-1,dataSource),lightbox.on("pointerDown",e=>{lightbox.pswp.currSlide.data.type=="model"&&e.preventDefault()}),lightbox.on("change",()=>{NextSkyTheme.pauseAllMedia(lightbox.pswp.element)}),NextSkyTheme.pauseAllMedia(this.closest("media-gallery")),new LazyLoader(".image-lazy-load")}}customElements.define("media-zoom-button",MediaZoomButton,{extends:"button"}),CustomElement.observeAndPatchCustomElements({"media-zoom-button":{tagElement:"button",classElement:MediaZoomButton}});
2//# sourceMappingURL=/cdn/shop/t/234/assets/media-gallery.js.map?v=171575812713067022391789630092

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.