https://cascadedesigns.com/cdn/shop/t/19/assets/localization-form.js?v=23105369194447057931774294740
1customElements.get("localization-form")||customElements.define("localization-form",class extends HTMLElement{constructor(){super(),this.mql=window.matchMedia("(min-width: 750px)"),this.header=document.querySelector(".header-wrapper"),this.elements={countryInput:this.querySelector('input[name="country_code"]'),localeInput:this.querySelector('input[name="locale_code"]'),button:this.querySelector("button.localization-form__select"),panel:this.querySelector(".disclosure__list-wrapper"),search:this.querySelector('input[name="country_filter"]'),closeButton:this.querySelector(".country-selector__close-button"),resetButton:this.querySelector(".country-filter__reset-button"),searchIcon:this.querySelector(".country-filter__search-icon"),liveRegion:this.querySelector("#sr-country-search-results")},this.addEventListener("keyup",this.onContainerKeyUp.bind(this)),this.addEventListener("keydown",this.onContainerKeyDown.bind(this)),this.addEventListener("focusout",this.closeSelector.bind(this)),this.elements.button&&this.elements.button.addEventListener("click",this.openSelector.bind(this)),this.elements.search&&(this.elements.search.addEventListener("keyup",this.filterCountries.bind(this)),this.elements.search.addEventListener("focus",this.onSearchFocus.bind(this)),this.elements.search.addEventListener("blur",this.onSearchBlur.bind(this)),this.elements.search.addEventListener("keydown",this.onSearchKeyDown.bind(this))),this.elements.closeButton&&this.elements.closeButton.addEventListener("click",this.hidePanel.bind(this)),this.elements.resetButton&&(this.elements.resetButton.addEventListener("click",this.resetFilter.bind(this)),this.elements.resetButton.addEventListener("mousedown",event=>event.preventDefault())),this.querySelectorAll("a").forEach(item=>{item.addEventListener("click",this.onItemClick.bind(this))})}hidePanel(){if(this.elements.button&&this.elements.button.setAttribute("aria-expanded","false"),this.elements.panel&&this.elements.panel.setAttribute("hidden",!0),this.elements.search&&(this.elements.search.value="",this.filterCountries(),this.elements.search.setAttribute("aria-activedescendant","")),!!!this.closest(".custom-dialog-container")){document.body.classList.remove("overflow-hidden-mobile");const drawer=document.querySelector(".menu-drawer");drawer&&drawer.classList.remove("country-selector-open"),this.header&&(this.header.preventHide=!1)}}openSelector(event){if(event&&event.preventDefault(),!this.elements.button||!this.elements.panel)return;const insideLocalizationModal=!!this.closest(".custom-dialog-container");if(this.elements.button.focus(),this.elements.panel.toggleAttribute("hidden"),this.elements.button.setAttribute("aria-expanded",(this.elements.button.getAttribute("aria-expanded")==="false").toString()),!insideLocalizationModal){document.body.classList.contains("overflow-hidden-tablet")||document.body.classList.add("overflow-hidden-mobile"),this.hasAttribute("data-prevent-hide")&&this.header&&(this.header.preventHide=!0);const drawer=document.querySelector(".menu-drawer");drawer&&drawer.classList.add("country-selector-open")}}closeSelector(event){!this.elements.button||!this.elements.panel||event.relatedTarget&&(event.target.classList?.contains("country-selector__overlay")||!this.contains(event.target)||!this.contains(event.relatedTarget))&&this.hidePanel()}onContainerKeyDown(event){const focusableItems=Array.from(this.querySelectorAll("a")).filter(item=>!item.parentElement.classList.contains("hidden"));if(!focusableItems.length)return;let focusedItemIndex=focusableItems.findIndex(item=>item===document.activeElement),itemToFocus;switch(event.code.toUpperCase()){case"ARROWUP":event.preventDefault(),itemToFocus=focusedItemIndex>0?focusableItems[focusedItemIndex-1]:focusableItems[focusableItems.length-1],itemToFocus.focus();break;case"ARROWDOWN":event.preventDefault(),itemToFocus=focusedItemIndex<focusableItems.length-1?focusableItems[focusedItemIndex+1]:focusableItems[0],itemToFocus.focus();break}this.elements.search&&setTimeout(()=>{focusedItemIndex=focusableItems.findIndex(item=>item===document.activeElement),focusedItemIndex>-1?this.elements.search.setAttribute("aria-activedescendant",focusableItems[focusedItemIndex].id||""):this.elements.search.setAttribute("aria-activedescendant","")})}onContainerKeyUp(event){if(this.elements.button)switch(event.code.toUpperCase()){case"ESCAPE":if(event.preventDefault(),this.elements.button.getAttribute("aria-expanded")==="false")return;this.hidePanel(),event.stopPropagation(),this.elements.button.focus();break;case"SPACE":if(event.target===this.elements.search||(event.preventDefault(),this.elements.button.getAttribute("aria-expanded")==="true"))return;this.openSelector();break}}async onItemClick(event){event.preventDefault();const form=this.closest("form");if(!form)return;const value=event.currentTarget.dataset.value,isCountry=!!event.currentTarget.closest("ul.countries, ul.popular-countries"),applyBtn=form.querySelector("[data-localization-apply]"),markSelected=()=>{this.querySelectorAll('a.disclosure__link[aria-current="true"]').forEach(a=>{a.removeAttribute("aria-current")}),event.currentTarget.setAttribute("aria-current","true")},updateCountryButtonUI=()=>{const btnName=this.querySelector(".disclosure__button .disclosure__country-name"),newName=event.currentTarget.querySelector(".country")?.textContent?.trim();btnName&&newName&&(btnName.textContent=newName);const btnIconWrap=this.querySelector(".disclosure__button .disclosure__country-icon"),clickedIconImg=event.currentTarget.querySelector(".disclosure__country-icon img");if(btnIconWrap&&clickedIconImg){const currentBtnImg=btnIconWrap.querySelector("img");currentBtnImg?(currentBtnImg.src=clickedIconImg.src,currentBtnImg.srcset=clickedIconImg.srcset||""):btnIconWrap.innerHTML=clickedIconImg.outerHTML}},updateLanguageButtonUI=()=>{const btnName=this.querySelector(".disclosure__button .disclosure__language-name"),newName=event.currentTarget.querySelector("span:last-child")?.textContent?.trim()||event.currentTarget.textContent?.trim();btnName&&newName&&(btnName.textContent=newName)};if(isCountry){const formCountry=form.querySelector('input[name="country_code"]');formCountry&&(formCountry.value=value),markSelected(),updateCountryButtonUI();const container=form.querySelector("#MarketSwitcherLanguageContainer");(container?container.querySelectorAll(".market-language-group"):[]).forEac
1h(group=>{group.hidden=group.getAttribute("data-country")!==value});const activeGroup=container?.querySelector(`.market-language-group[data-country="${value}"]`),masterLocaleInput=form.querySelector('input[name="locale_code"]');if(activeGroup){const selectedLanguageLink=activeGroup.querySelector('a.disclosure__link[aria-current="true"]')||activeGroup.querySelector("a.disclosure__link[data-value]");masterLocaleInput&&selectedLanguageLink?.dataset.value&&(masterLocaleInput.value=selectedLanguageLink.dataset.value)}else masterLocaleInput&&(masterLocaleInput.value="en-US");applyBtn&&(applyBtn.disabled=!1),typeof this.hidePanel=="function"&&this.hidePanel();return}const formLocale=form.querySelector('input[name="locale_code"]');if(formLocale&&(formLocale.value=value),markSelected(),updateLanguageButtonUI(),applyBtn){const hasCountry=!!form.querySelector('input[name="country_code"]')?.value,hasLocale=!!form.querySelector('input[name="locale_code"]')?.value;applyBtn.disabled=!(hasCountry&&hasLocale)}typeof this.hidePanel=="function"&&this.hidePanel()}normalizeString(str){return str.normalize("NFD").replace(/\p{Diacritic}/gu,"").toLowerCase()}filterCountries(){if(!this.elements.search)return;const searchValue=this.normalizeString(this.elements.search.value),popularCountries=this.querySelector(".popular-countries"),allCountries=this.querySelectorAll("a");let visibleCountries=0;this.elements.resetButton&&this.elements.resetButton.classList.toggle("hidden",!searchValue),popularCountries&&popularCountries.classList.toggle("hidden",!!searchValue),allCountries.forEach(item=>{const countryEl=item.querySelector(".country");(countryEl?this.normalizeString(countryEl.textContent):"").indexOf(searchValue)>-1?(item.parentElement.classList.remove("hidden"),visibleCountries++):item.parentElement.classList.add("hidden")}),this.elements.liveRegion&&window.accessibilityStrings?.countrySelectorSearchCount&&(this.elements.liveRegion.innerHTML=window.accessibilityStrings.countrySelectorSearchCount.replace("[count]",visibleCountries));const selector=this.querySelector(".country-selector"),list=this.querySelector(".country-selector__list");selector&&(selector.scrollTop=0),list&&(list.scrollTop=0)}resetFilter(event){event.stopPropagation(),this.elements.search&&(this.elements.search.value="",this.filterCountries(),this.elements.search.focus())}onSearchFocus(){this.elements.searchIcon&&this.elements.searchIcon.classList.add("country-filter__search-icon--hidden")}onSearchBlur(){this.elements.searchIcon&&this.elements.search&&!this.elements.search.value&&this.elements.searchIcon.classList.remove("country-filter__search-icon--hidden")}onSearchKeyDown(event){event.code.toUpperCase()==="ENTER"&&event.preventDefault()}}); 2//# sourceMappingURL=/cdn/shop/t/19/assets/localization-form.js.map?v=23105369194447057931774294740
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.