PageSourceSearch

https://oluxring.com/cdn/shop/t/61/assets/sticky-bar.js?v=64491779291134824291786443844

js oluxring.com collected 2026-10-08 07:42:53 UTC 5,100 bytes, 2 lines download raw bytes

1import{$4,$$4,$id4}from"@theme/utilities";import{inView}from"@theme/m";import{ThemeEvents}from"@theme/events";const{cartUpdate,cartError}=ThemeEvents;import{Resize}from"@theme/global";class StickyBar extends Resize{#btns;#controller;#activeClass="is--active";#variantButton;#buyButton;constructor(){super()}connectedCallback(){$4(".hdt-section-main--product .hdt-product__external")&&(this.classList.remove("hdt-sticky-bar-has-atc"),$4("[data-form]",this).remove());const spyItems=$$4("[data-hdt-spy]"),hasBacktop=this.classList.contains("hdt-sticky-bar-has-backtop"),hasATC=this.classList.contains("hdt-sticky-bar-has-atc"),hasSpy=spyItems.length;if(!hasSpy&&!hasBacktop&&!hasATC)return;this.#controller=new AbortController;let attr="";if(hasSpy&&(this.#build(spyItems),attr=attr+"spy"),hasATC&&(this.#stickyATC(),attr=attr+"atc"),hasBacktop){if(attr==""&&this.classList.contains("backtop-active"))return this.classList.remove("hdt-sticky-bar-has-backtop");this.#backtoTop(),attr=attr+"top"}attr!=""&&(this.setAttribute("inted",""),this.#inView(),super.connectedCallback(),attr.length==3&&this.setAttribute("only",attr))}disconnectedCallback(){this.#controller?.abort()}get prefix(){return"sticky-bar"}#build(spyItems){this.classList.add("hdt-sticky-bar-has-scrollspy");const template=$4("template",this);if(!template)return;const content=template.content.cloneNode(!0),container=$4(".hdt-slider__container",content),slideTemplate=$4(".hdt-scrollspy-item",content);!container||!slideTemplate||(container.innerHTML="",spyItems.forEach(item=>{const{id}=item.dataset,text=item.textContent.trim();if(!id||!text)return;const slide=slideTemplate.cloneNode(!0),btn=$4("button",slide);btn.textContent=text,btn.dataset.target=`${id}`,container.appendChild(slide)}),template.replaceWith(content),this.#btns=$$4(".hdt-scrollspy button",this),this.#bindClick(),this.#initScrollSpy())}#bindClick(){const{signal}=this.#controller;this.#btns.forEach((btn,index)=>{btn.addEventListener("click",e=>{e.preventDefault(),$id4(`shopify-section-${btn.dataset.target}`)?.scrollIntoView({behavior:"smooth"}),this.#setActive(index)},signal)})}#setActive(index){this.#btns.forEach(link=>link.classList.remove(this.#activeClass)),this.#btns[index].classList.add(this.#activeClass)}get#firstVisibleSection(){const sections=$$4("#MainContent > .shopify-section");for(const section of sections)if(section.offsetParent!==null)return section;return null}#inView(){let target=document.forms[$4("[tmp-sticky-atc]")?.dataset.form];if((!target||target.offsetParent===null)&&(target=this.#firstVisibleSection),target){const observer=new IntersectionObserver(([entry])=>{entry.boundingClientRect.bottom<0?this.setAttribute("shown",""):this.removeAttribute("shown")},{threshold:0});setTimeout(()=>{observer.observe(target),setTimeout(this.setAttribute("transition",""),60)},60)}}#stickyATC(){const form=document.forms[$4("[tmp-sticky-atc]").dataset.form];if(!form)return;this.#variantButton=$4('[ref="variantButton"]',this);const{signal}=this.#controller;this.#buyButton=form?.querySelector('[type="submit"]'),this.#variantButton?.addEventListener("click",this.#handleAddToCartClick,{signal}),document.addEventListener(cartUpdate,this.#handleCartAddComplete.bind(this,!1),{signal}),document.addEventListener(cartError,this.#handleCartAddComplete.bind(this,!1),{signal}),form?.addEventListener("product:updateInfo",this.#updateInfo,{signal})}#initScrollSpy(){this.#btns.forEach(btn=>{const section=$id4(`shopify-section-${btn.dataset.target}`);section&&inView(section,()=>(this.#btns.forEach(link=>link.classList.remove(this.#activeClass)),btn.classList.add(this.#activeClass),leaveInfo=>{btn.classList.remove(this.#activeClass)}),{amount:section.offsetHeight>window.innerHeight?window.innerHeight/3/section.offsetHeight:.3})})}#backtoTop(){$4(".hdt-back-to-top",this)?.addEventListener("click",()=>window.scrollTo({top:0,behavior:"smooth"}),{signal:this.#controller.signal})}#handleAddToCartClick=async()=>{this.#handleCartAddComplete(!0),this.#buyButton.click()};#handleCartAddComplete(loading=!1){this.#variantButton.toggleAttribute("loading",loading)}#updateInfo=event=>{const{sectionId,html}=event.detail,domFragment=$4(`#shopify-section-${sectionId}`,document.createRange().createContextualFragment(html)),stickyAddToCart=$4("template[tmp-sticky-atc]",domFragment);if(!stickyAddToCart.content.children.length)return;const content=stickyAddToCart.content.cloneNode(!0),refs=["variantImage","variantTitle","variantPrice","variantButton"];
1refs.forEach(ref=>{const newEl=$4(`[ref="${ref}"]`,content),oldEl=$4(`[ref="${ref}"]`,this);if(!(!oldEl||!newEl))if(ref===refs[3]){const oldAttrs=oldEl.attributes,newAttrs=newEl.attributes;[...oldAttrs].forEach(attr=>{newEl.hasAttribute(attr.name)||oldEl.removeAttribute(attr.name)}),[...newAttrs].forEach(attr=>{oldEl.setAttribute(attr.name,attr.value)}),oldEl.className=newEl.className,oldEl.innerHTML=newEl.innerHTML}else oldEl.replaceWith(newEl)})}}customElements.define("hdt-sticky-bar",StickyBar);
2//# sourceMappingURL=/cdn/shop/t/61/assets/sticky-bar.js.map?v=64491779291134824291786443844

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.