PageSourceSearch

https://rahua.com/cdn/shop/t/78/assets/ugc-desktop.js?v=62514470652339045871760645804

js rahua.com collected 2026-09-25 19:13:26 UTC 10,688 bytes, 2 lines download raw bytes

1document.addEventListener("alpine:init",()=>{Alpine.store("ugc",{modalOpen:!1,modalMobileOpen:!1,currentVideo:1,openModal(currentVideo){this.currentVideo=currentVideo,window.innerWidth<=768?(this.modalMobileOpen=!0,this.modalOpen=!1,window.dispatchEvent(new CustomEvent("ugc-modal-mobile-open",{detail:this.currentVideo,bubbles:!0}))):(this.modalMobileOpen=!1,this.modalOpen=!0,window.dispatchEvent(new CustomEvent("ugc-modal-open",{detail:this.currentVideo,bubbles:!0})))},closeModal(){this.modalOpen=!1,this.modalMobileOpen=!1,this.currentVideo=1,window.dispatchEvent(new CustomEvent("ugc-modal-close",{bubbles:!0})),window.dispatchEvent(new CustomEvent("ugc-modal-mobile-close",{bubbles:!0}))}}),Alpine.data("ugcModal",()=>({isPlaying:!1,init(){const placeholders=new Map,selectors=["[data-oke-star-rating]",".ugc-append","delm-widget"];window.addEventListener("ugc-modal-open",()=>{const target=document.querySelector(".product-info-slot");selectors.forEach(selector=>{document.querySelectorAll(selector).forEach(node=>{if(console.log("Processing node for selector:",selector,node),!placeholders.has(node)){const placeholder=document.createComment(`placeholder for ${selector}`);node.parentNode.insertBefore(placeholder,node),placeholders.set(node,placeholder)}target.appendChild(node)})})}),window.addEventListener("ugc-modal-close",()=>{placeholders.forEach((placeholder,node)=>{placeholder.parentNode&&(placeholder.parentNode.insertBefore(node,placeholder),placeholder.remove())}),placeholders.clear();const videoCount=document.querySelectorAll('[x-ref^="video"]').length;this.pauseAllVideos(videoCount)}),window.addEventListener("rh-variant-changed",event=>{if(this.$store.ugc.modalOpen)this.playCurrentVideo();else{const videoCount=document.querySelectorAll('[x-ref^="video"]').length;this.pauseAllVideos(videoCount)}})},pauseAllVideos(videoSize){for(let i=1;i<=videoSize;i++){const video=this.$refs["video"+i];if(video){console.log("Pausing video",i,video.paused?"(already paused)":"(was playing)"),video.pause(),video.currentTime=0;const playBtn=this.$refs["playBtn"+i],pauseBtn=this.$refs["pauseBtn"+i];playBtn&&(playBtn.style.display="block"),pauseBtn&&(pauseBtn.style.display="none")}else console.log("Video",i,"not found in refs")}},playCurrentVideo(){const currentVideoIndex=this.$store.ugc.currentVideo,video=this.$refs["video"+currentVideoIndex];if(video){this.lazyLoadVideo(video),video.play().catch(e=>console.error("Error playing video:",e));const playBtn=this.$refs["playBtn"+currentVideoIndex],pauseBtn=this.$refs["pauseBtn"+currentVideoIndex];playBtn&&(playBtn.style.display="none"),pauseBtn&&(pauseBtn.style.display="block")}},lazyLoadVideo(videoElement){if(videoElement.dataset.lazyLoaded==="true")return;videoElement.querySelectorAll(".video-source-template").forEach(template=>{const source=document.createElement("source");source.src=template.dataset.src,source.type=template.dataset.type,videoElement.appendChild(source)}),videoElement.dataset.lazyLoaded="true",videoElement.load(),console.log("Video sources loaded")},toggleMute(videoIndex){const video=this.$refs["video"+videoIndex];if(video){video.muted=!video.muted;const volumeOnBtn=this.$refs["volumeOnBtn"+videoIndex],volumeDownBtn=this.$refs["volumeDownBtn"+videoIndex];video.muted?(volumeOnBtn&&(volumeOnBtn.style.display="none"),volumeDownBtn&&(volumeDownBtn.style.display="block")):(volumeOnBtn&&(volumeOnBtn.style.display="block"),volumeDownBtn&&(volumeDownBtn.style.display="none"))}},toggleVideoPlayPause(videoIndex){const video=this.$refs["video"+videoIndex];video&&(video.paused?video.play():video.pause())},switchToVideo(videoIndex,videoSize){this.pauseAllVideos(videoSize),this.$store.ugc.currentVideo=videoIndex,console.log("Current video after switch:",this.$store.ugc.currentVideo),this.$nextTick(()=>{this.playCurrentVideo()})}})),Alpine.data("ugcModalMobile",()=>({splideInstance:null,currentMobileVideo:1,isMuted:!1,isPlaying:!1,init(){console.log("UGC Mobile Modal initialized");const placeholders=new Map,selectors=["[data-oke-star-rating]",".ugc-append","delm-widget"];window.addEventListener("ugc-modal-mobile-open",()=>{document.body.classList.add("ugc-modal-mobile-open"),document.documentElement.classList.add("ugc-modal-mobile-open"),this.isMuted=!1,this.updateVolumeButtonState(),console.log("Videos automatically unmuted on mobile modal open"),this.initializeMobileSlider(),this.currentMobileVideo=this.$store.ugc.currentVideo,this.$nextTick(()=>{console.log("Navigating to video and playing...",this.currentMobileVideo),this.splideInstance&&(this.splideInstance.go(this.currentMobileVideo-1),setTimeout(()=>{this.forcePlayMobileVideo(this.currentMobileVideo)},200)),setTimeout(()=>{this.updateVolumeButtonState()},100)})}),window.addEventListener("ugc-modal-mobile-close",()=>{document.body.classList.remove("ugc-modal-mobile-open"),document.documentElement.classList.remove("ugc-modal-mobile-open"),this.pauseAllMobileVideos(),this.splideInstance&&(this.splideInstance.destroy(),this.splideInstance=null),placeholders.forEac
1h((placeholder,node)=>{placeholder.parentNode&&(placeholder.parentNode.insertBefore(node,placeholder),placeholder.remove())}),placeholders.clear()}),window.addEventListener("rh-variant-changed",event=>{this.splideInstance&&this.$store.ugc.modalMobileOpen?this.playMobileVideo(this.currentMobileVideo):this.pauseAllMobileVideos()})},initializeMobileSlider(){console.log("Initializing mobile slider..."),this.splideInstance&&this.splideInstance.destroy(),this.$nextTick(()=>{if(console.log("Slider element:",this.$refs.mobileSlider),!this.$refs.mobileSlider){console.error("Mobile slider element not found!");return}if(typeof Splide>"u"){console.error("Splide library not loaded!");return}this.splideInstance=new Splide(this.$refs.mobileSlider,{direction:"ttb",height:"100vh",wheel:!0,wheelSleep:300,speed:600,pagination:!1,arrows:!1,drag:!0,snap:!0,autoWidth:!1,autoHeight:!1}),this.splideInstance.on("moved",newIndex=>{console.log("Slide moved to:",newIndex),this.pauseAllMobileVideos(),this.currentMobileVideo=newIndex+1,this.$store.ugc.currentVideo=this.currentMobileVideo,setTimeout(()=>{this.forcePlayMobileVideo(this.currentMobileVideo)},100)}),this.splideInstance.mount(),console.log("Splide mounted successfully")})},pauseAllMobileVideos(){const videoCount=document.querySelectorAll('[x-ref^="mobileVideo"]').length;for(let i=1;i<=videoCount;i++){const video=this.$refs["mobileVideo"+i];video&&(video.pause(),this.updateMobilePlayState(i,!1))}},playMobileVideo(videoIndex){const video=this.$refs["mobileVideo"+videoIndex];video&&(this.lazyLoadVideo(video),video.muted=this.isMuted,video.play().catch(e=>console.error("Error playing mobile video:",e)))},forcePlayMobileVideo(videoIndex){const video=this.$refs["mobileVideo"+videoIndex];video&&(console.log("Force playing mobile video:",videoIndex),this.lazyLoadVideo(video),video.muted=this.isMuted,video.play().then(()=>{console.log("Video",videoIndex,"started playing successfully"),this.updateMobilePlayState(videoIndex,!0)}).catch(e=>{console.error("Error force playing mobile video:",e),video.muted=!0,this.isMuted=!0,this.updateVolumeButtonState(),video.play().catch(err=>console.error("Fallback play failed:",err))}))},updateVolumeButtonState(){const volumeOnBtn=this.$refs.mobileVolumeOnBtn,volumeDownBtn=this.$refs.mobileVolumeDownBtn;this.isMuted?(volumeOnBtn&&(volumeOnBtn.style.display="none"),volumeDownBtn&&(volumeDownBtn.style.display="block")):(volumeOnBtn&&(volumeOnBtn.style.display="block"),volumeDownBtn&&(volumeDownBtn.style.display="none"))},toggleMobilePlay(videoIndex){const video=this.$refs["mobileVideo"+videoIndex];video&&(video.paused?(this.lazyLoadVideo(video),video.play()):video.pause())},updateMobilePlayState(videoIndex,isPlaying){const playBtn=this.$refs["mobilePlayBtn"+videoIndex],pauseBtn=this.$refs["mobilePauseBtn"+videoIndex];isPlaying?(playBtn&&(playBtn.style.display="none"),pauseBtn&&(pauseBtn.style.display="block")):(playBtn&&(playBtn.style.display="block"),pauseBtn&&(pauseBtn.style.display="none"))},toggleMobileVolume(){this.isMuted=!this.isMuted;const currentVideo=this.$refs["mobileVideo"+this.currentMobileVideo];currentVideo&&(currentVideo.muted=this.isMuted);const volumeOnBtn=this.$refs.mobileVolumeOnBtn,volumeDownBtn=this.$refs.mobileVolumeDownBtn;this.isMuted?(volumeOnBtn&&(volumeOnBtn.style.display="none"),volumeDownBtn&&(volumeDownBtn.style.display="block")):(volumeOnBtn&&(volumeOnBtn.style.display="block"),volumeDownBtn&&(volumeDownBtn.style.display="none"))},lazyLoadVideo(videoElement){if(videoElement.dataset.lazyLoaded==="true")return;console.log("Lazy loading mobile video sources..."),videoElement.querySelectorAll(".video-source-template").forEach(template=>{const source=document.createElement("source");source.src=template.dataset.src,source.type=template.dataset.type,videoElement.appendChild(source)}),videoElement.dataset.lazyLoaded="true",videoElement.load(),console.log("Mobile video sources loaded")},updateSelectedVariant(variantId){const option=document.querySelector(`option[value="${variantId}"]`);if(option){const price=option.dataset.price,comparePrice=option.dataset.comparePrice;
1console.log("Selected variant:",variantId,"Price:",price)}},addToCartFromModal(){const variantSelect=this.$refs.variantSelect;let variantId=null;if(variantSelect){if(variantId=variantSelect.value,!variantId){alert("Please select a size");return}}else{const productForm=document.querySelector("product-form");if(productForm){const hiddenVariantInput=productForm.querySelector('input[name="id"]');hiddenVariantInput&&(variantId=hiddenVariantInput.value)}}if(!variantId){console.error("No variant ID found");return}const formData=new FormData;formData.append("items[0][id]",variantId),formData.append("items[0][quantity]","1");const addToCartBtn=this.$refs.addToCartBtn,originalText=addToCartBtn.textContent;addToCartBtn.textContent="Adding...",addToCartBtn.disabled=!0,fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[{id:variantId,quantity:1}]})}).then(response=>response.json()).then(data=>{console.log("Added to cart:",data),addToCartBtn.textContent="Added!",document.dispatchEvent(new CustomEvent("cart:item-added",{detail:{variant_id:variantId,quantity:1}})),setTimeout(()=>{addToCartBtn.textContent=originalText,addToCartBtn.disabled=!1},2e3)}).catch(error=>{console.error("Error adding to cart:",error),addToCartBtn.textContent="Error - Try Again",setTimeout(()=>{addToCartBtn.textContent=originalText,addToCartBtn.disabled=!1},2e3)})}}))});
2//# sourceMappingURL=/cdn/shop/t/78/assets/ugc-desktop.js.map?v=62514470652339045871760645804

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.