PageSourceSearch

https://www.wtatennis.com/resources/v7.50.45/scripts/hero.js

js wtatennis.com collected 2026-09-24 15:21:52 UTC 5,045 bytes, 1 lines download raw bytes

1import{u as t,A as e,U as s,k as i}from"./bundle-es.js";import{a as r}from"./template2.js";import{controlVideo as n}from"./hero-helpers.js";import"./escape.js";import"./tennis.js";import"./moment.js";import"./_commonjsHelpers.js";import"./content.js";import"./tennis-tournament.js";const o=100;class d{constructor(e){this.container=e,this.buttons=this.container.querySelectorAll(".js-hero-buttons"),this.slides=this.container.querySelectorAll('[class*="js-slide-"]'),this.mediaContainer=this.container.querySelector(".js-media"),this.prevButton=this.container.querySelector(".js-hero-prev"),this.nextButton=this.container.querySelector(".js-hero-next"),this.carouselInterval=1e3*this.container.dataset.carouselInterval||5e3,this.currentSlideIndex=0,this.touchStartX=0,this.touchEndX=0,this.interval=null,this.timeout=null,this.progressInterval=null,this.deferFirstSlideVideo=!1,this.initFirstSlide(),t(this.container),this.setListeners()}initFirstSlide(){const t=this.buttons?.[0];if(!t)return;const e=t.dataset.setVideoId||"";this.deferFirstSlideVideo=Boolean(e),setTimeout(()=>{this.startProgress(this.buttons[this.currentSlideIndex]),this.startAutoSlide()},800)}setListeners(){if(this.buttons&&!(this.buttons.length<=1)){if("ontouchstart"in window)this.container.addEventListener("touchstart",t=>{this.touchStartX=t.touches[0].clientX,this.stopAutoSlide()}),this.container.addEventListener("touchend",t=>{this.touchEndX=t.changedTouches[0].clientX,this.handleSwipe();const e=this.buttons[this.currentSlideIndex].dataset.setVideoId||"";this.handleVideoOnSlideChange(e),this.startAutoSlide()});else{this.container.querySelectorAll(".js-content-link").forEach(t=>{t.addEventListener("mouseenter",this.onMouseOver.bind(this)),t.addEventListener("mouseleave",this.onMouseLeave.bind(this))})}this.buttons.forEach((t,e)=>{t.addEventListener("click",()=>{const s=t.dataset.setVideoId||"";this.handleButtonClick(e,s),this.restartAutoSlide()})}),this.prevButton&&this.prevButton.addEventListener("click",()=>{this.handleNavigation(-1)}),this.nextButton&&this.nextButton.addEventListener("click",()=>{this.handleNavigation(1)})}}handleNavigation(t){this.changeSlide(t),this.restartAutoSlide()}restartAutoSlide(){this.stopAutoSlide(),this.startAutoSlide(200)}onMouseOver(){this.stopAutoSlide(),this.resetProgress(this.buttons[this.currentSlideIndex],100)}onMouseLeave(){this.startProgress(this.buttons[this.currentSlideIndex]),this.startAutoSlide()}handleButtonClick(t,e){this.releaseSlideOneDefer(this.currentSlideIndex,t),this.currentSlideIndex=t,this.updateSlide(e)}releaseSlideOneDefer(t,e){this.deferFirstSlideVideo&&0===t&&0!==e&&(this.deferFirstSlideVideo=!1)}handleSwipe(){const t=this.touchStartX-this.touchEndX;Math.abs(t)>50&&(t>0?this.changeSlide(1):this.changeSlide(-1))}handleVideoOnSlideChange(t){if(t){const e=this.mediaContainer.querySelectorAll('[data-widget="hero/video-hero"]');n(null,"pause",e),setTimeout(()=>{const e=this.container.querySelector(`.video-js[data-video-id="${t}"]`);n(e,"play")},200)}}updateSlide(t){this.mountVideoPlayer(),this.handleVideoOnSlideChange(t);const i=`js-slide-${this.currentSlideIndex}`,r=this.buttons[this.currentSlideIndex];this.slides.forEach(t=>{t.classList.contains(i)?(setTimeout(()=>t.classList.add(e),200),t.classList.remove(s)):(t.classList.remove(e),t.classList.add(s))}),this.buttons.forEach(t=>{t.classList.remove(e),this.resetProgress(t)}),r.classList.add(e),this.startProgress(r)}startAutoSlide(t=0){this.stopAutoSlide(),this.timeout=setTimeout(()=>{this.interval=setInterval(()=>{this.changeSlide(1)},this.carouselInterval)},t)}stopAutoSlide(){clearInterval(this.interval),clearTimeout(this.timeout),this.interval=null,this.timeout=null}startProgress(t){this.resetProgress(t);let e=0;t.style.setProperty("--progress-width","0%"),this.progressInterval=setInterval(()=>{e+=o;const s=Math.min(e/this.carouselInterval*o,o);t.style.setProperty("--progress-width",`${s+10}%`),s>=o&&(clearInterval(this.progressInterval),t.style.setProperty("--progress-width","100%"))},o)}resetProgress(t,e=0){this.progressInterval&&(clearInterval(this.progressInterval),this.progressInterval=null),t.style.setProperty("--progress-width",`${e}%`)}changeSlide(t){const e=this.currentSlideIndex;this.currentSlideIndex=(this.currentSlideIndex+t+this.buttons.length)%this.buttons.length,this.releaseSlideOneDefer(e,this.currentSlideIndex);const s=this.buttons[this.currentSlideIndex].dataset.setVideoId||"";this.updateSlide(s)}mountVideoPlayer(){if(this.deferFirstSlideVideo&&0===this.currentSlideIndex)return;const t=this.mediaContainer.querySelector(`.js-hero-video-wrapper[data-sli
1de-index="${this.currentSlideIndex}"]`);if(t&&!t?.getAttribute("data-player-mounted",!0)){if(0===this.currentSlideIndex){const e=t.querySelector(".js-hero-video-poster"),i=e?.closest(".lazy-image-wrapper");i?i.classList.add(s):e&&e.classList.add(s)}const e=r(t);e&&(t.insertAdjacentHTML("beforeend",e.textContent.trim()),e.parentNode?.removeChild(e)),t.dataset.playerMounted="true",i("hero/video-hero",t)}}}export{d as default};

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.