1class GridSwatch extends HTMLElement{getClosest(t,e){for(;t&&t!==document;t=t.parentNode)if(t.matches(e))return t;return null}constructor(){super(),this.el=this,this.swatches=[].slice.call(this.el.querySelectorAll(".grid-swatch")),this.cardWrap=this.getClosest(this.el,".card-wrapper"),this.linkWraps=this.cardWrap.querySelectorAll("a.full-unstyled-link"),this.imgWrap=this.cardWrap.querySelector(".card__media"),this.linkWraps&&this.linkWraps.forEach((t=>{t.setAttribute("data-o-url",t.href)})),this.setupListener(),window.addEventListener("load",this.handlePreload.bind(this))}setupListener(){const t=this;this.linkWraps&&this.linkWraps.forEach((e=>{e.addEventListener("click",t.handleClick.bind(t))})),this.cardWrap&&this.cardWrap.addEventListener("click",this.handleClick.bind(this)),this.swatches.forEach((t=>{t.addEventListener("mouseover",this.handleHover.bind(this)),t.addEventListener("mouseout",this.resetImages.bind(this))}))}handleHover(t){let e=this.getButton(t.target);e&&e.getAttribute("data-image")&&this.changeActiveImage(e)}getButton(t){let e=t;return e.classList.contains("grid-swatch")||(e=this.getClosest(t,".grid-swatch")),e}resetImages(t=!0){this.imgWrap.classList.remove("variant-image-active"),this.linkWraps.forEach((t=>{t.href=t.getAttribute("data-o-url")}))}changeActiveImage(t,e=!0){this.resetImages(),this.linkWraps.forEach((e=>e.setAttribute("href",t.getAttribute("data-url")))),this.linkWraps.forEach((e=>{e.setAttribute("href",t.getAttribute("data-url"))})),"string"==typeof t.getAttribute("data-image")&&"false"!=t.getAttribute("data-image")&&(this.imgWrap.classList.add("variant-image-active"),this.imgWrap.style.backgroundImage="url('"+t.getAttribute("data-image")+"')")}handleClick(t){var e=this.getButton(t.target);this.swatches.includes(e)&&(e.classList.contains("selected")?window.location.href=this.linkWraps[0].href:("false"!=e.getAttribute("data-image")&&this.imgWrap.classList.add("variant-image-active--clicked"),t.preventDefault(),this.changeActiveImage(e),this.swatches.forEach((t=>{t.classList.remove("selected")})),setTimeout((()=>{e.classList.add("selected")}),25)))}handlePreload(){this.swatches.forEach((t=>{(new Image).src=t.getAttribute("data-image")}))}}customElements.define("grid-swatches",GridSwatch);
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.