PageSourceSearch

https://store.ericchurch.com/cdn/shop/t/40/assets/product.js?v=160323014714586501751783617028

js ericchurch.com collected 2026-09-24 20:18:29 UTC 19,862 bytes, 2 lines download raw bytes

1if(!customElements.get("variant-selects")){class VariantSelects extends HTMLElement{constructor(){super(),this.sticky=this.dataset.sticky,this.featured=this.dataset.featured,this.isDisabledFeature=this.dataset.isDisabled,this.addEventListener("change",this.onVariantChange),this.other=Array.from(document.querySelectorAll("variant-selects")).filter(selector=>selector!=this)}connectedCallback(){this.updateOptions(),this.updateMasterId(),this.setDisabled()}onVariantChange(){this.updateOptions(),this.updateMasterId(),this.toggleAddButton(!0,"",!1),this.updatePickupAvailability(),this.removeErrorMessage(),this.updateVariantText(),this.setDisabled(),this.currentVariant?(this.updateMedia(),this.featured||this.updateURL(),this.updateVariantInput(),this.renderProductInfo()):(this.toggleAddButton(!0,"",!0),this.setUnavailable()),this.updateOther(),dispatchCustomEvent("product:variant-change",{variant:this.currentVariant,sectionId:this.dataset.section})}updateOptions(){this.fieldsets=Array.from(this.querySelectorAll("fieldset")),this.options=[],this.fieldsets.forEach((fieldset,i)=>{fieldset.querySelector("select")?this.options.push(fieldset.querySelector("select").value):fieldset.querySelectorAll("input").length&&this.options.push(fieldset.querySelector("input:checked").value)})}updateVariantText(){Array.from(this.querySelectorAll("fieldset")).forEach((item,i)=>{let label=item.querySelector(".form__label__value");label&&(label.innerHTML=this.options[i])})}updateMasterId(){this.currentVariant=this.getVariantData().find(variant=>!variant.options.map((option,index)=>this.options[index]===option).includes(!1))}updateOther(){if(this.dataset.updateUrl!=="false"&&this.other.length){let fieldsets=this.other[0].querySelectorAll("fieldset"),fieldsets_array=Array.from(fieldsets);this.options.forEach((option,i)=>{fieldsets_array[i].querySelector("select")?fieldsets_array[i].querySelector("select").value=option:fieldsets_array[i].querySelectorAll("input").length&&(fieldsets_array[i].querySelector(`input[value="${option}"]`).checked=!0)}),this.other[0].updateOptions(),this.other[0].updateMasterId(),this.other[0].updateVariantText(),this.other[0].setDisabled()}}updateMedia(){if(!this.currentVariant||!this.currentVariant.featured_media)return;const productSlider=document.getElementById(`MediaGallery-${this.dataset.section}`);if(!productSlider)return;let mediaId=`${this.dataset.section}-${this.currentVariant.featured_media.id}`,activeMedia=productSlider.querySelector(`[data-media-id="${mediaId}"]`);productSlider.querySelectorAll("[data-media-id]").forEach(element=>{element.classList.remove("is-active")}),activeMedia.classList.add("is-active"),!this.featured&&(activeMedia.parentElement.prepend(activeMedia),window.setTimeout(()=>{activeMedia.parentElement.scrollTo({left:0,top:0,behavior:"smooth"})}))}updateURL(){!this.currentVariant||this.dataset.updateUrl==="false"||window.history.replaceState({},"",`${this.dataset.url}?variant=${this.currentVariant.id}`)}updateShareUrl(){const shareButton=document.getElementById(`Share-${this.dataset.section}`);shareButton&&shareButton.updateUrl(`${window.shopUrl}${this.dataset.url}?variant=${this.currentVariant.id}`)}updateVariantInput(){document.querySelectorAll(`#product-form-${this.dataset.section}, #product-form-installment`).forEach(productForm=>{const input=productForm.querySelector('input[name="id"]');input.value=this.currentVariant.id,input.dispatchEvent(new Event("change",{bubbles:!0}))})}updatePickupAvailability(){const pickUpAvailability=document.querySelector(".pickup-availability-wrapper");pickUpAvailability&&(this.currentVariant&&this.currentVariant.available?pickUpAvailability.fetchAvailability(this.currentVariant.id):(pickUpAvailability.removeAttribute("available"),pickUpAvailability.innerHTML=""))}removeErrorMessage(){const section=this.closest("section");if(!section)return;const productForm=section.querySelector("product-form");productForm&&productForm.handleErrorMessage()}getSectionsToRender(){return[`price-${this.dataset.section}`,`price-${this.dataset.section}--sticky`,`product-image-${this.dataset.section}--sticky`,`inventory-${this.dataset.section}`,`sku-${this.dataset.section}`,`quantity-${this.dataset.section}`]}renderProductInfo(){let sections=this.getSectionsToRender();fetch(`${this.dataset.url}?variant=${this.currentVariant.id}&section_id=${this.dataset.section}`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html");sections.forEach(id=>{const destination=document.getElementById(id),source=html.getElementById(id);source&&destination&&(destination.innerHTML=source.innerHTML);const price=document.getElementById(id),price_fixed=document.getElementById(id+"--sticky");price&&price.classList.remove("visibility-hidden"),price_fixed&&price_fixed.classList.remove("visibility-hidden")}),this.toggleAddButton(!this.currentVariant.available,window.theme.variantStrings.soldOut)})}toggleAddButton(disable=!0,text=!1,modifyClass=!0){if(!document.getElementById(`product-form-${this.dataset.section}`))return;const submitButtons=document.querySelectorAll(".single-add-to-cart-button");submitButtons&&submitButtons.forEach(submitButton=>{const submitButtonText=submitButton.querySelector(".single-add-to-cart-button--text");submitButtonText&&(disable?(submitButton.setAttribute("disabled","disabled"),text&&(submitButtonText.textContent=text)):(submitButton.removeAttribute("disabled"),submitButton.classList.remove("loading"),submitButtonText.textContent=window.theme.variantStrings.addToCart))})}setUnavailable(){const submitButtons=document.querySelectorAll(".single-add-to-cart-button"),price=document.getElementById(`price-${this.dataset.section}`),price_fixed=document.getElementById(`price-${this.dataset.section}--sticky`);submitButtons.forEach(submitButton=>{const submitButtonText=submitButton.querySelector(".single-add-to-cart-button--text");submitButton&&(submitButtonText.textContent=window.theme.variantStrings.unavailable,submitButton.classList.add("sold-out"))}),price&&price.classList.add("visibility-hidden"),price_fixed&&price_fixed.classList.add("visibility-hidden")}setDisabled(){if(this.isDisabledFeature!="true")return;const variant_data=this.getVariantData();if(variant_data){const selected_options=this.currentVariant.options.map((value,index)=>({value,index:`option${index+1}`})),available_options=this.createAvailableOptionsTree(variant_data,selected_options);
1this.fieldsets.forEach((fieldset,i)=>{const fieldset_options=Object.values(available_options)[i];fieldset_options&&(fieldset.querySelector("select")?fieldset_options.forEach((option,option_i)=>{option.isUnavailable?fieldset.querySelector("option[value="+JSON.stringify(option.value)+"]").disabled=!0:fieldset.querySelector("option[value="+JSON.stringify(option.value)+"]").disabled=!1}):fieldset.querySelectorAll("input").length&&fieldset.querySelectorAll("input").forEach((input,input_i)=>{input.classList.toggle("is-disabled",fieldset_options[input_i].isUnavailable)}))})}return!0}createAvailableOptionsTree(variant_data,selected_options){return variant_data.reduce((options,variant)=>(Object.keys(options).forEach(index=>{if(variant[index]===null)return;let entry=options[index].find(option=>option.value===variant[index]);typeof entry>"u"&&(entry={value:variant[index],isUnavailable:!0},options[index].push(entry)),selected_options.reduce((count,{value,index:index2})=>variant[index2]===value?count+1:count,0)>=selected_options.length-1&&(entry.isUnavailable=entry.isUnavailable&&variant.available?!1:entry.isUnavailable),(!this.currentVariant||!this.currentVariant.available)&&selected_options.find(option=>option.value===entry.value&&index===option.index)&&(entry.isUnavailable=!0),index==="option1"&&(entry.isUnavailable=entry.isUnavailable&&variant.available?!1:entry.isUnavailable)}),options),{option1:[],option2:[],option3:[]})}getVariantData(){return this.variantData=this.variantData||JSON.parse(this.querySelector('[type="application/json"]').textContent),this.variantData}}customElements.define("variant-selects",VariantSelects);class VariantRadios extends VariantSelects{constructor(){super()}updateOptions(){const fieldsets=Array.from(this.querySelectorAll("fieldset"));this.options=fieldsets.map(fieldset=>Array.from(fieldset.querySelectorAll("input")).find(radio=>radio.checked).value)}}customElements.define("variant-radios",VariantRadios)}if(!customElements.get("product-slider")){class ProductSlider extends HTMLElement{constructor(){super()}connectedCallback(){const _this=this,product_container=this.closest(".thb-product-detail");this.pagination=this.parentElement.querySelector(".product-images-buttons"),this.sliderItems=this.querySelectorAll('[id^="Slide-"]'),this.addEventListener("change",this.setupProductGallery),this.setupProductGallery(),this.pagination&&(this.setupPagination(),this.addEventListener("scroll",this.updatePagination.bind(this)),new ResizeObserver(entries=>this.onPaginationResize()).observe(this))}setupProductGallery(){if(!this.querySelectorAll(".product-single__media-zoom").length)return;let activeImages=Array.from(this.querySelectorAll(".product-single__media-image"));this.setEventListeners(this,activeImages)}buildItems(activeImages){return activeImages.map(item=>{let activelink=item.querySelector(".product-single__media-zoom");return{src:activelink.getAttribute("href"),msrc:activelink.dataset.msrc,w:activelink.dataset.w,h:activelink.dataset.h,title:activelink.getAttribute("title")}})}setEventListeners(container,activeImages){let links=container.querySelectorAll(".product-single__media-zoom"),items=container.buildItems(activeImages),captionEl=container.dataset.captions,pswpElement=document.querySelectorAll(".pswp")[0],options={maxSpreadZoom:2,loop:!1,allowPanToNext:!1,closeOnScroll:!1,showHideOpacity:!1,arrowKeys:!0,history:!1,captionEl,fullscreenEl:!1,zoomEl:!1,shareEl:!1,counterEl:!0,arrowEl:!0,preloaderEl:!0};links.forEach((link=>{link.addEventListener("click",event=>{let i=link.dataset.index;if(options.index=parseInt(i,10),options.getThumbBoundsFn=()=>{const thumbnail=link.closest(".product-single__media"),pageYScroll=window.pageYOffset||document.documentElement.scrollTop,rect=thumbnail.getBoundingClientRect();return{x:rect.left,y:rect.top+pageYScroll,w:rect.width}},typeof PhotoSwipe<"u"){let pswp=new PhotoSwipe(pswpElement,PhotoSwipeUI_Default,items,options);
1pswp.listen("firstUpdate",function(){pswp.listen("parseVerticalMargin",function(item){item.vGap={top:50,bottom:50}})}),pswp.init()}event.preventDefault()})}))}setupPagination(){this.sliderItemsToShow=Array.from(this.sliderItems).filter(element=>element.clientWidth>0),!(this.sliderItemsToShow.length<2)&&(this.sliderItemOffset=this.sliderItemsToShow[1].offsetLeft-this.sliderItemsToShow[0].offsetLeft,this.currentPageElement=this.pagination.querySelector(".slider-counter--current"),this.pageTotalElement=this.pagination.querySelector(".slider-counter--total"),this.prevButton=this.pagination.querySelector('button[name="previous"]'),this.nextButton=this.pagination.querySelector('button[name="next"]'),this.prevButton.addEventListener("click",this.onPaginationButtonClick.bind(this)),this.nextButton.addEventListener("click",this.onPaginationButtonClick.bind(this)),this.updatePagination())}onPaginationResize(){this.sliderItemsToShow=Array.from(this.sliderItems).filter(element=>element.clientWidth>0),!(this.sliderItemsToShow.length<2)&&(this.sliderItemOffset=this.sliderItemsToShow[1].offsetLeft-this.sliderItemsToShow[0].offsetLeft)}onPaginationButtonClick(event){event.preventDefault(),this.slideScrollPosition=event.currentTarget.name==="next"?this.scrollLeft+1*this.sliderItemOffset:this.scrollLeft-1*this.sliderItemOffset,this.scrollTo({left:this.slideScrollPosition})}updatePagination(){if(!this.nextButton)return;const previousPage=this.currentPage;this.currentPage=Math.round(this.scrollLeft/this.sliderItemOffset)+1,this.currentPageElement&&(this.currentPageElement.textContent=this.currentPage),this.currentPage!=previousPage&&this.dispatchEvent(new CustomEvent("slideChanged",{detail:{currentPage:this.currentPage,currentElement:this.sliderItemsToShow[this.currentPage-1]}})),this.isSlideVisible(this.sliderItemsToShow[0])&&this.scrollLeft===0?this.prevButton.setAttribute("disabled","disabled"):this.prevButton.removeAttribute("disabled"),this.isSlideVisible(this.sliderItemsToShow[this.sliderItemsToShow.length-1])?this.nextButton.setAttribute("disabled","disabled"):this.nextButton.removeAttribute("disabled")}isSlideVisible(element,offset=0){const lastVisibleSlide=this.clientWidth+this.scrollLeft-offset;return element.offsetLeft+element.clientWidth<=lastVisibleSlide&&element.offsetLeft>=this.scrollLeft}}customElements.define("product-slider",ProductSlider)}if(customElements.get("product-form")||customElements.define("product-form",class extends HTMLElement{constructor(){super(),this.sticky=this.dataset.sticky,this.form=document.getElementById(`product-form-${this.dataset.section}`),this.form.querySelector("[name=id]").disabled=!1,this.sticky||this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.cartNotification=document.querySelector("cart-notification"),this.body=document.body,this.hideErrors=this.dataset.hideErrors==="true"}onSubmitHandler(evt){if(evt.preventDefault(),!this.form.reportValidity())return;const submitButtons=document.querySelectorAll(".single-add-to-cart-button");submitButtons.forEach(submitButton=>{submitButton.classList.contains("loading")||(submitButton.setAttribute("aria-disabled",!0),submitButton.classList.add("loading"))}),this.handleErrorMessage();const config={method:"POST",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"application/javascript"}};let formData=new FormData(this.form);formData.append("sections",this.getSectionsToRender().map(section=>section.section)),formData.append("sections_url",window.location.pathname),config.body=formData,fetch(`${theme.routes.cart_add_url}`,config).then(response=>response.json()).then(response=>{if(response.status){dispatchCustomEvent("product:variant-error",{source:"product-form",productVariantId:formData.get("id"),errors:response.description,message:response.message}),this.handleErrorMessage(response.description);return}this.renderContents(response),dispatchCustomEvent("cart:item-added",{product:response.hasOwnProperty("items")?response.items[0]:response})}).catch(e=>{console.error(e)}).finally(()=>{submitButtons.forEach(submitButton=>{submitButton.classList.remove("loading"),submitButton.removeAttribute("aria-disabled")})})}getSectionsToRender(){return[{id:"Cart",section:"main-cart",selector:".thb-cart-form"},{id:"Cart-Drawer",section:"cart-drawer",selector:".cart-drawer"},{id:"cart-drawer-toggle",section:"cart-bubble",selector:".thb-item-count"}]}
1renderContents(parsedState){this.getSectionsToRender().forEach((section=>{if(!document.getElementById(section.id))return;const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector),typeof CartDrawer<"u"&&new CartDrawer,typeof Cart<"u"&&new Cart().renderContents(parsedState)}));let product_drawer=document.getElementById("Product-Drawer");product_drawer&&product_drawer.contains(this)?(product_drawer.querySelector(".product-quick-images--container").classList.remove("active"),document.body.classList.remove("open-quick-view"),window.innerWidth<1069?(product_drawer.classList.remove("active"),document.getElementById("Cart-Drawer")&&(document.getElementById("Cart-Drawer").classList.add("active"),document.body.classList.add("open-cart"),document.getElementById("Cart-Drawer").querySelector(".product-recommendations--full").classList.add("active"),dispatchCustomEvent("cart-drawer:open"))):product_drawer.querySelector(".product-quick-images--container").addEventListener("transitionend",function(){product_drawer.classList.remove("active"),document.getElementById("Cart-Drawer")&&(document.getElementById("Cart-Drawer").classList.add("active"),document.body.classList.add("open-cart"),document.getElementById("Cart-Drawer").querySelector(".product-recommendations--full").classList.add("active"),dispatchCustomEvent("cart-drawer:open"))}),document.getElementById("Cart-Drawer")||document.body.classList.remove("open-cc")):document.getElementById("Cart-Drawer")&&(document.body.classList.add("open-cc"),document.body.classList.add("open-cart"),document.getElementById("Cart-Drawer").classList.add("active"),dispatchCustomEvent("cart-drawer:open"))}getSectionInnerHTML(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}handleErrorMessage(errorMessage=!1){this.hideErrors||(this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".product-form__error-message-wrapper"),this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".product-form__error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage&&(this.errorMessage.textContent=errorMessage))}}),!customElements.get("product-add-to-cart-sticky")){class ProductAddToCartSticky extends HTMLElement{constructor(){super(),this.animations_enabled=document.body.classList.contains("animations-true")&&typeof gsap<"u"}connectedCallback(){this.setupObservers(),this.setupToggle()}setupToggle(){const button=this.querySelector(".product-add-to-cart-sticky--inner"),content=this.querySelector(".product-add-to-cart-sticky--content");if(this.animations_enabled){const tl=gsap.timeline({reversed:!0,paused:!0,onStart:()=>{button.classList.add("sticky-open")},onReverseComplete:()=>{button.classList.remove("sticky-open")}});tl.set(content,{display:"block",height:"auto"},"start").from(content,{height:0,duration:.25},"start+=0.001"),button.addEventListener("click",function(){return tl.reversed()?tl.play():tl.reverse(),!1})}else button.addEventListener("click",function(){return content.classList.toggle("active"),!1})}setupObservers(){let _this=this,observer=new IntersectionObserver(function(entries){entries.forEach(entry=>{if(entry.target===footer&&(entry.intersectionRatio>0?_this.classList.remove("sticky--visible"):entry.intersectionRatio==0&&_this.formPassed&&_this.classList.add("sticky--visible")),entry.target===form){let boundingRect=form.getBoundingClientRect();entry.intersectionRatio===0&&window.scrollY>boundingRect.top+boundingRect.height?(_this.formPassed=!0,_this.classList.add("sticky--visible")):entry.intersectionRatio===1&&(_this.formPassed=!1,_this.classList.remove("sticky--visible"))}})},{threshold:[0,1]}),form=document.getElementById(`product-form-${this.dataset.section}`),footer=document.getElementById("footer");_this.formPassed=!1,observer.observe(form),observer.observe(footer)}}customElements.define("product-add-to-cart-sticky",ProductAddToCartSticky)}if(!customElements.get("side-panel-links")){class ProductSidePanelLinks extends HTMLElement{constructor(){super(),this.links=this.querySelectorAll("button"),this.drawer=document.getElementById("Product-Information-Drawer"),this.buttons=this.drawer.querySelector(".side-panel-content--tabs"),this.panels=this.drawer.querySelector(".side-panel-content--inner").querySelectorAll(".side-panel-content--tab-panel"),this.body=document.body}connectedCallback(){this.setupObservers()}disconnectedCallback(){}setupObservers(){this.links.forEach((item,i)=>{item.addEventListener("click",e=>{this.body.classList.add("open-cc"),this.buttons.toggleActiveClass(i),this.drawer.classList.add("active")})})}}customElements.define("side-panel-links",ProductSidePanelLinks)}typeof addIdToRecentlyViewed<"u"&&addIdToRecentlyViewed();
2//# sourceMappingURL=/cdn/shop/t/40/assets/product.js.map?v=160323014714586501751783617028

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.