PageSourceSearch

https://www.tbotech.com/cdn/shop/t/6/assets/section.slideshow.js?v=176892809315355130961787933787

js tbotech.com collected 2026-10-02 12:33:29 UTC 19,790 bytes, 18 lines download raw bytes

1import Swiper from"vendor.swiper";class SectionSlideshow extends HTMLElement{constructor(){super(),this.slideshowWrapper=this.querySelector("[data-slideshow-wrapper]"),this.slides=this.querySelectorAll("[data-slideshow-slide]"),this.pagination=this.querySelector("[data-slideshow-pagination]"),this.swiper=null,this.settings={},this.autoplayActive=!1,this.header=document.querySelector(".site-header"),this.announcementBar=document.querySelector(".announcement-bar"),this.isInitialized=!1,this.isVisible=!1,this.intersectionObserver=null,this.lastSelectedBlock=null,this.resizeTimer=null,this.lastWindowWidth=window.innerWidth,this.autoplayStartTime=0,this.isResizing=!1,this.customAutoplayTimer=null,this.userInteracted=!1,this.touchMoveCount=0,this.isThemeEditor=typeof window.Shopify<"u"&&window.Shopify.designMode,this.keyboardNavUsed=!1}connectedCallback(){this.settings={enable_autoplay:this.getAttribute("enable-autoplay")==="true",autoplay_interval:parseInt(this.getAttribute("autoplay-interval"),10)||8,mobile_navigation_adjust:this.getAttribute("mobile-navigation-adjust")==="true",slideshow_animation:this.getAttribute("slideshow-animation")||"slide",slide_attraction:parseFloat(this.getAttribute("slide-attraction"))||.03,slide_friction:parseFloat(this.getAttribute("slide-friction"))||.3,slide_transition_speed:parseInt(this.getAttribute("slide-transition-speed"),10)||400,show_navigation_arrows:this.getAttribute("show-navigation-arrows")==="true",slideshow_text_animation:this.getAttribute("slideshow-text-animation")||"none",navigation_arrows_style:this.getAttribute("navigation-arrows-style")||"normal"},this._setupVisibilityDetection(),this.slides.length<=1?this._handleSingleSlide():(this._prepareForSwiper(),this._initSwiper()),(this.classList.contains("slideshow--height-fit-screen")||this.classList.contains("slideshow--height-fit-screen-mobile"))&&(this._setupCSSVariables(),this._positionNavigation()),window.addEventListener("resize",this._handleResize.bind(this)),window.addEventListener("keydown",this._handleTabNavigation.bind(this)),this.isThemeEditor&&this.classList.contains("slideshow--text-below-image-true")&&window.innerWidth<720&&setTimeout(()=>{this.swiper&&this.swiper.update()},1e3)}_handleTabNavigation(event){if(event.key==="Tab"&&this.keyboardNavUsed){event.preventDefault(),this.keyboardNavUsed=!1;const activeSlide=this.swiper?.slides[this.swiper.activeIndex];if(!activeSlide)return;const target=[activeSlide.querySelector(".slideshow-slide__background-link"),activeSlide.querySelector("a[href]:not(.slideshow-slide__background-link), button:not([disabled])"),this.querySelector(".swiper-button-prev")].find(el=>el);target&&target.focus(),this._updateTabIndexes()}}_updateTabIndexes(){if(!this.swiper)return;this.swiper.slides.forEach((slide,index)=>{const tabIndex=index===this.swiper.activeIndex?"0":"-1";slide.querySelectorAll("a[href], button:not([disabled])").forEach(element=>{element.setAttribute("tabindex",tabIndex)})});const navTabIndex=this.keyboardNavUsed?"-1":"0",navElements=[],prevButton=this.querySelector(".swiper-button-prev");prevButton&&navElements.push(prevButton);const nextButton=this.querySelector(".swiper-button-next");nextButton&&navElements.push(nextButton),this.pagination&&this.pagination.querySelectorAll(".slideshow-pagination__button").forEach(button=>navElements.push(button)),navElements.forEach(element=>{element.setAttribute("tabindex",navTabIndex)})}_handleResize(){clearTimeout(this.resizeTimer),this.isResizing=!0;const currentWidth=window.innerWidth,isMobileNow=currentWidth<720,breakpointChanged=this.lastWindowWidth<720!==isMobileNow;this.resizeTimer=setTimeout(()=>{if(this._setupCSSVariables(),this._positionNavigation(),this.swiper&&(this.swiper.update(),breakpointChanged)){const currentSlide=this.swiper.slides[this.swiper.activeIndex];currentSlide&&(currentSlide.querySelectorAll(".slide-element").forEach((element,index)=>{element.style.setProperty("--slide-element-index",index)}),currentSlide.classList.contains("slide--active")||currentSlide.classList.add("slide--active"),this.slideshowWrapper.classList.contains("slideshow--content-hidden")&&this._showActiveContent())}this._setContentHeight(),this.isResizing=!1,this.lastWindowWidth=currentWidth},300)}_setupVisibilityDetection(){"IntersectionObserver"in window?(this.intersectionObserver=new IntersectionObserver(entries=>{const isIntersecting=entries[0].isIntersecting;if(isIntersecting&&!this.isVisible){this.isVisible=!0,this._onBecomeVisible();const animationClass=this.getAttribute("data-scroll-class");animationClass&&animationClass!=="none"&&(this.classList.add("animated"),this.classList.add(animationClass)),this.swiper&&this.classList.contains("slideshow--text-below-image-true")&&window.innerWidth<720&&setTimeout(()=>
1{this.swiper.update()},300)}else!isIntersecting&&this.isVisible&&(this.isVisible=!1)},{root:null,rootMargin:"0px",threshold:.3}),this.intersectionObserver.observe(this)):(this.isVisible=!0,this._onBecomeVisible())}_onBecomeVisible(){const textAnimation=this.settings.slideshow_text_animation||"none";if(this.classList.add(`slideshow--text-animation-${textAnimation}`),this.isInitialized&&this.swiper)this._showActiveContent();else if(this.slides.length<=1){const slide=this.slides[0];slide&&(this.classList.add("slideshow--animate"),slide.classList.add("slide--active"))}}_hideAllContents(){this.isResizing||this.slideshowWrapper.classList.add("slideshow--content-hidden")}_showActiveContent(){if(!this.isVisible)return;this.slideshowWrapper.classList.remove("slideshow--content-hidden");const activeSlide=this.swiper?.slides[this.swiper.activeIndex];activeSlide&&(activeSlide.dataset.textColor&&this.style.setProperty("--slide-text-color",activeSlide.dataset.textColor),this.classList.add("slideshow--animate"),activeSlide.classList.add("slide--active"),this._setContentHeight(),this._positionNavigation(),this._updateTabIndexes())}_setupCSSVariables(){const currentHeaderHeight=this.header?.offsetHeight||0,currentAnnouncementHeight=this.announcementBar?.offsetHeight||0;this.style.setProperty("--header-height",`${currentHeaderHeight-currentAnnouncementHeight}px`),this._setContentHeight(),this.swiper&&this.swiper.update()}_setContentHeight(){if(!this.swiper)return;const slideContent=this.swiper.slides[this.swiper.activeIndex]?.querySelector(".slideshow-slide__content");if(!slideContent)return;const styles=window.getComputedStyle(slideContent),margin=parseFloat(styles.marginTop)+parseFloat(styles.marginBottom),contentHeight=Math.ceil(slideContent.offsetHeight+margin);this.style.setProperty("--content-height",`${contentHeight}px`)}_positionNavigation(){if(this.pagination)if(this.settings.mobile_navigation_adjust&&window.innerWidth<720){const activeSlide=this.swiper?.slides[this.swiper.activeIndex];if(!activeSlide)return;const imageWrapper=activeSlide.querySelector(".slideshow-slide__image-wrapper");if(!imageWrapper)return;if(this.classList.contains("slideshow--text-below-image-true")){const imageHeight=imageWrapper.offsetHeight;this.style.setProperty("--image-height",`${imageHeight}px`),this.pagination.style.removeProperty("top")}else this.pagination.style.removeProperty("top")}else this.pagination.style.removeProperty("top")}_handleSingleSlide(){if(!this.slideshowWrapper||!this.slides[0])return;this.pagination&&(this.pagination.style.display="none");const slide=this.slides[0];slide.dataset.textColor&&this.style.setProperty("--slide-text-color",slide.dataset.textColor),slide.classList.add("slide"),slide.querySelectorAll(".slide-element").forEach((element,elementIndex)=>element.style.setProperty("--slide-element-index",elementIndex)),this.isVisible&&(this.classList.add("slideshow--animate"),slide.classList.add("slide--active"))}_prepareForSwiper(){if(!this.slideshowWrapper||this.slideshowWrapper.classList.contains("swiper-initialized"))return;this.slideshowWrapper.classList.add("swiper");const originalSlides=Array.from(this.slides);if(originalSlides.length===0)return;const swiperWrapper=document.createElement("div");if(swiperWrapper.className="swiper-wrapper",this.slideshowWrapper.innerHTML="",this.slideshowWrapper.appendChild(swiperWrapper),originalSlides.forEach((slide,slideIndex)=>{const slideClone=slide.cloneNode(!0);slideClone.classList.add("swiper-slide"),slideClone.classList.add("slide"),slideClone.style.setProperty("--slide-index",slideIndex),slideClone.querySelectorAll(".slide-element").forEach((element,elementIndex)=>element.style.setProperty("--slide-element-index",elementIndex)),swiperWrapper.appendChild(slideClone)}),this.settings.show_navigation_arrows){const prevButton=document.createElement("div");prevButton.className="swiper-button-prev",prevButton.setAttribute("tabindex","0"),prevButton.setAttribute("role","button"),prevButton.setAttribute("aria-label","Previous slide");const nextButton=document.createElement("div");if(nextButton.className="swiper-button-next",nextButton.setAttribute("tabindex","0"),nextButton.setAttribute("role","button"),nextButton.setAttribute("aria-label","Next slide"),this.settings.navigation_arrows_
1style==="circle"){const prevSvg=document.createElementNS("http://www.w3.org/2000/svg","svg");prevSvg.setAttribute("viewBox","0 0 100 100");const prevPath=document.createElementNS("http://www.w3.org/2000/svg","path");prevPath.setAttribute("d","M95.04 46 21.68 46 48.18 22.8 42.91 16.78 4.96 50 42.91 83.22 48.18 77.2 21.68 54 95.04 54 95.04 46z"),prevPath.setAttribute("class","arrow"),prevSvg.appendChild(prevPath),prevButton.appendChild(prevSvg);const nextSvg=document.createElementNS("http://www.w3.org/2000/svg","svg");nextSvg.setAttribute("viewBox","0 0 100 100");const nextPath=document.createElementNS("http://www.w3.org/2000/svg","path");nextPath.setAttribute("d","M95.04 46 21.68 46 48.18 22.8 42.91 16.78 4.96 50 42.91 83.22 48.18 77.2 21.68 54 95.04 54 95.04 46z"),nextPath.setAttribute("class","arrow"),nextPath.setAttribute("transform","translate(100, 100) rotate(180)"),nextSvg.appendChild(nextPath),nextButton.appendChild(nextSvg)}this.slideshowWrapper.appendChild(prevButton),this.slideshowWrapper.appendChild(nextButton)}this.pagination&&(this.pagination.classList.add("swiper-pagination"),this.pagination.querySelectorAll(".slideshow-pagination__button").forEach(button=>{button.getAttribute("data-selected")==="true"&&button.classList.add("swiper-pagination-bullet-active")}),this.appendChild(this.pagination)),this.slides=this.slideshowWrapper.querySelectorAll(".swiper-slide"),this._hideAllContents()}_initSwiper(){if(!(!this.slides||this.slides.length<=1))try{const enableAutoplay=this.settings.enable_autoplay||!1;this.autoplayActive=enableAutoplay;const self=this,swiperOptions={autoHeight:!0,slidesPerView:1,spaceBetween:0,loop:!0,resistance:!0,speed:this.settings.slide_transition_speed,resistanceRatio:this.settings.slide_friction?1-parseFloat(this.settings.slide_friction):.7,touchRatio:this.settings.slide_attraction?parseFloat(this.settings.slide_attraction)*10:.3,effect:this.settings.slideshow_animation==="fade"?"fade":"slide",fadeEffect:{crossFade:!0},autoplay:!1,pagination:this.pagination?{el:this.pagination,clickable:!0,renderBullet:index=>{const isActive=index===0;let buttonContent="";return enableAutoplay&&(buttonContent=`
2                <div class="circle-timer">
3                  <svg class="circle-timer__svg">
4                    <circle class="circle-timer__countdown" r="3.5" cx="50%" cy="50%"></circle>
5                    <circle class="circle-timer__background" r="3.5" cx="50%" cy="50%"></circle>
6                  </svg>
7                </div>
8              `),`
9              <li class="slideshow-pagination__dot">
10                <button class="slideshow-pagination__button ${isActive?"swiper-pagination-bullet-active":""}" 
11                        data-selected="${isActive?"true":"false"}" 
12                        data-slide-button="${index}">
13                  ${buttonContent}
14                  <span class="visually-hidden">Slide ${index+1}</span>
15                </button>
16              </li>
17            `}}:!1,navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"},on:{init:function(){self.isInitialized=!0,self.isVisible&&setTimeout(()=>{self._showActiveContent()},100),enableAutoplay&&self._startCustomAutoplay()},resize:function(){setTimeout(()=>{self._setContentHeight(),self._positionNavigation()},100)},slideChangeTransitionStart:function(){self.isResizing||(self.settings.slideshow_text_animation!=="none"&&self._hideAllContents(),self.swiper.slides.forEach(sli
17de=>{slide.classList.remove("slide--active")}));const nextSlide=this.slides[this.activeIndex];nextSlide&&nextSlide.dataset.textColor&&self.style.setProperty("--slide-text-color",nextSlide.dataset.textColor)},slideChangeTransitionEnd:function(){if(self.isVisible){self.isResizing?self.slideshowWrapper.classList.contains("slideshow--content-hidden")&&self._showActiveContent():self._showActiveContent();const currentSlide=self.swiper.slides[self.swiper.activeIndex];currentSlide&&(currentSlide.classList.add("slide--active"),currentSlide.querySelectorAll(".slide-element").forEach((element,index)=>{element.style.setProperty("--slide-element-index",index)}))}self._setContentHeight(),self._positionNavigation(),self._updateTabIndexes(),self.keyboardNavUsed&&document.activeElement.blur()},transitionEnd:function(){self.isVisible&&self._showActiveContent()},touchStart:function(){self.touchMoveCount=0},touchMove:function(){self.touchMoveCount++,self.touchMoveCount>=3&&self.autoplayActive&&(self._stopCustomAutoplay(),self.autoplayActive=!1,self.setAttribute("data-autoplay-active","false"),self.userInteracted=!0)},dragStart:function(){self.autoplayActive&&(self._stopCustomAutoplay(),self.autoplayActive=!1,self.setAttribute("data-autoplay-active","false"),self.userInteracted=!0)}}};this.setAttribute("data-autoplay",enableAutoplay),this.setAttribute("data-autoplay-active",enableAutoplay),this.swiper=new Swiper(this.slideshowWrapper,swiperOptions),this.swiper&&(this._setupKeyboardEvents(),enableAutoplay&&this._setupAutoplayEvents(),this.pagination&&(this.swiper.on("slideChange",()=>this._updatePaginationState()),this._updatePaginationState()))}catch(error){console.error("Swiper initialization error:",error)}}_setupKeyboardEvents(){[".swiper-button-prev",".swiper-button-next"].forEach(selector=>{const button=this.querySelector(selector);button&&button.addEventListener("keydown",e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.keyboardNavUsed=!0,selector.includes("prev")?this.swiper.slidePrev():this.swiper.slideNext())})}),this.pagination&&(this.pagination.addEventListener("keydown",e=>{if((e.key==="Enter"||e.key===" ")&&e.target.closest(".slideshow-pagination__button")){e.preventDefault();const slideIndex=parseInt(e.target.closest(".slideshow-pagination__button").dataset.slideButton,10);isNaN(slideIndex)||(this.keyboardNavUsed=!0,this.swiper.slideToLoop(slideIndex,this.settings.slide_transition_speed),this.autoplayActive&&(this._stopCustomAutoplay(),this.autoplayActive=!1,this.setAttribute("data-autoplay-active","false"),this.userInteracted=!0))}}),this.pagination.addEventListener("click",event=>{const button=event.target.closest(".slideshow-pagination__button");if(button){const slideIndex=parseInt(button.getAttribute("data-slide-button"),10);!isNaN(slideIndex)&&this.swiper&&(this.swiper.slideToLoop(slideIndex,this.settings.slide_transition_speed),this.autoplayActive&&(this._stopCustomAutoplay(),this.autoplayActive=!1,this.setAttribute("data-autoplay-active","false"),this.userInteracted=!0))}}))}_setupAutoplayEvents(){this.slideshowWrapper.addEventListener("mouseenter",()=>{this.autoplayActive&&(this.setAttribute("data-hover","true"),this._pauseCustomAutoplay())}),this.slideshowWrapper.addEventListener("mouseleave",()=>{this.setAttribute("data-hover","false"),this.autoplayActive&&this._resumeCustomAutoplay()}),this.slideshowWrapper.addEventListener("click",event=>{event.target.closest(".swiper-button-prev, .swiper-button-next")&&this.autoplayActive&&(this._stopCustomAutoplay(),this.autoplayActive=!1,this.setAttribute("data-autoplay-active","false"),this.userInteracted=!0)}),this._updateCircleTimer()}_startCustomAutoplay(){if(this.customAutoplayTimer&&clearTimeout(this.customAutoplayTimer),this.userInteracted)return;this.autoplayActive=!0,this.setAttribute("data-autoplay-active","true"),this.autoplayStartTime=Date.now(),this._updateCircleTimer();const autoplayInterval=(this.settings.autoplay_interval||8)*1e3;this.customAutoplayTimer=setTimeout(()=>{this.autoplayActive&&this.swiper&&(this.swiper.slideNext(this.settings.slide_transition_speed),setTimeout(()=>this._startCustomAutoplay(),this.settings.slide_transition_speed))},autoplayInterval)}_pauseCustomAutoplay(){if(this.customAutoplayTimer){clearTimeout(this.customAutoplayTimer);const elapsedTime=Date.now()-this.autoplayStartTime;this.remainingTime=(this.settings.autoplay_interval||8)*1e3-elapsedTime,this.autoplayPaused=!0}}_resumeCustomAutoplay(){this.userInteracted||(this.autoplayPaused&&this.remainingTime>0?(this.autoplayPaused=!1,this.customAutoplayTimer=setTimeout(()=>{this.autoplayActive&&this.swiper&&(this.swiper.slideNext(this.settings.slide_transition_speed),setTimeout(()=>{this._startCustomAutoplay()},this.settings.slide_transition_speed))},this.remainingTime),this.autoplayStartTime=Date.now()-((this.settings.autoplay_interval||8)*1e3-this.remainingTime),this._updateCircleTimer()):this._startCustomAutoplay())}_stopCustomAutoplay(){this.customAutoplayTimer&&(clearTimeout(this.customAutoplayTimer),this.customAutoplayTimer=null),this.autoplayActive=!1,this.setAttribute("data-autoplay-active","false"),this.autoplayPaused=!1}_updateCircleTimer(){const activeButton=this.pagination?.querySelector(".swiper-pagination-bullet-active");if(activeButton){const circleTimer=activeButton.querySelector(".circle-timer__countdown");circleTimer&&(circleTimer.style.animation="none",circleTimer.offsetHeight,circleTimer.style.animation=`countdown ${this.settings.autoplay_interval||8}s linear 1`)}}_updatePaginationState(){if(!this.swiper||!this.pagination)return;const activeIndex=this.swiper.realIndex;this.pagination.querySelectorAll(".slideshow-pagination__button").forEach((button,index)=>{const isActive=index===activeIndex;button.setAttribute("data-selected",isActive?"true":"false"),isActive?button.classList.add("swiper-pagination-bullet-active"):button.classList.remove("swiper-pagination-bullet-active")})}onBlockSelect(el){if(!this.swiper)return;const slideIndex=parseInt(el.dataset.slideIndex,10);isNaN(slideIndex)||(this.swiper.slideToLoop(slideIndex,0),this.autoplayActive&&this._stopCustomAutoplay())}onBlockDeselect(){this.swiper&&this.settings.enable_autoplay&&!this.userInteracted&&this._startCustomAutoplay()}disconnectedCallback(){this.swiper&&(this.swiper.destroy(),this.swiper=null),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.customAutoplayTimer&&clearTimeout(this.customAutoplayTimer),clearTimeout(this.resizeTimer),window.removeEventListener("resize",this._handleResize.bind(this)),window.removeEventListener("keydown",this._handleTabNavigation.bind(this))}}typeof window.Shopify<"u"&&window.Shopify.designMode&&(document.addEventListener("shopify:block:select",event=>
17{const slideshow=event.target.closest("section-slideshow");slideshow&&slideshow.onBlockSelect(event.target)}),document.addEventListener("shopify:block:deselect",event=>{const slideshow=event.target.closest("section-slideshow");slideshow&&slideshow.onBlockDeselect()})),window.customElements.get("section-slideshow")||customElements.define("section-slideshow",SectionSlideshow);
18//# sourceMappingURL=/cdn/shop/t/6/assets/section.slideshow.js.map?v=176892809315355130961787933787

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.