PageSourceSearch

https://www.lacoquetakids.com/cdn/shop/t/291/assets/store-selector.js?v=91967110598024234931774367740

js lacoquetakids.com collected 2026-09-26 18:43:53 UTC 7,470 bytes, 4 lines download raw bytes

1const{debounce,getElement}=window.BAO.Utils;export class StoreSelector extends window.BAO.CustomElement(){_apiKey="2791f10e5bd44b5086db97abb14e0842";static get requiredElements(){return["items","select"]}constructor(){super(),window.dataLayer=window.dataLayer||[],this.searchString="",this.locationSetup(),this.replaceLocationInfo(),this.createOptionsList(),this.setAttribute("data-initialised",!0)}setupListeners(){super.setupListeners(),this.onSelectClick=this.onSelectClick.bind(this),this.els.select.elements.forEach(openEl=>{this.listeners.add(openEl,"click",this.onSelectClick)}),this.onOptionClick=this.onOptionClick.bind(this),this.els.items.elements.forEach(itemsEl=>{this.listeners.add(itemsEl,"click",this.onOptionClick)}),this.els?.selectClose?.exists&&(this.onSelectClose=this.onSelectClose.bind(this),this.els.items.elements.forEach(closeEL=>{this.listeners.add(closeEL,"click",this.onSelectClose)})),this.onSelectType=this.onSelectType.bind(this),this.debouncedOnKeyUp=debounce(()=>this.onKeyUp(),700),this.debouncedOnKeyUp=this.debouncedOnKeyUp.bind(this),this.els.select.elements.forEach(openEl=>{this.listeners.add(openEl,"keyup",this.onSelectType),this.listeners.add(openEl,"keyup",this.debouncedOnKeyUp)})}onSelectClick(e){e.preventDefault(),e.currentTarget.focus(),this.selectToggle()}selectToggle(){if(this.dataset.menuHidden==="true"){this.dataset.menuHidden=!1;const lastChosenCountry=getElement(".str-StoreSelector_Item-selected",{context:this});typeof lastChosenCountry=="object"&&lastChosenCountry.scrollIntoView({behavior:"smooth",block:"center"})}else this.dataset.menuHidden=!0,this.searchString=""}onSelectType(e){this.searchString=this.searchString.concat(e.key)}onKeyUp(){const searchTerm=this.searchString.charAt(0).toUpperCase()+this.searchString.slice(1),foundCountry=getElement(`[data-country-name^="${searchTerm}"]`,{context:this});if(this.searchString="",foundCountry===null)return;getElement(".str-StoreSelector_Item-selected",{context:this}).classList.remove("str-StoreSelector_Item-selected"),foundCountry.classList.add("str-StoreSelector_Item-selected"),foundCountry.scrollIntoView({behavior:"smooth",block:"center"})}onSelectClose(e){e.preventDefault(),e.target.matches('[data-store-selector-el="selectClose"]')&&(this.dataset.menuHidden=!0)}onOptionClick(e){if(e.preventDefault(),!e.target.matches('[data-store-selector-el="option"]'))return;const countryCode=e.target.dataset.code.toUpperCase(),countryName=e.target.dataset.countryName,currency=e.target.dataset.currency.toLowerCase(),redirect=this.dataset.redirect;window.dataLayer.push({event:"country_selection",element:{action:"form submit",value:countryName,currency,location:this.dataset.clickFrom}}),redirect==="true"?this.doRedirect(countryCode,currency):(this.userCountryCode=countryCode,this.userCountryName=countryName,this.storeCurrency=currency,this.replaceLocationInfo(),this.selectToggle())}doRedirect(countryCode,currency){this.countries[countryCode].site!==void 0&&(this.path.includes("/search-results")?window.location.href=`${this.sites[this.countries[countryCode].site]}?code=${countryCode}&currency=${currency}`:window.location.href=`${this.sites[this.countries[countryCode].site]}${this.path}?code=${countryCode}&currency=${currency}`)}createOptionsList(){const fragment=document.createDocumentFragment();Object.entries(this.countries).forEach(([key,value])=>{const{currency,name,site,flag}=value,isCurrentSite=key.toLowerCase()===this.userCountryCode?.toLowerCase();flag==="OWN"&&fragment.append(document.createRange().createContextualFragment(this.createOptionElement(key,site,isCurrentSite,name,currency)))}),this.els.items.element.appendChild(fragment)}createOptionElement(code,site,isCurrentSite,country,currency){return`<button class="str-StoreSelector_Item${isCurrentSite?" str-StoreSelector_Item-selected":""}" data-store-selector-el="option" data-currency="${currency}" data-country-name="${country}" data-code="${code}" data-site="${site}">
2      <span class="str-StoreSelector_Option fz-12_20">${country} / ${currency}</span>
3    </button>`}
3locationSetup(){if(this.urlParams.currency!==null?this.storeCurrency=this.urlParams.currency:(this.storeCurrency===null||this.storeCurrency==="null")&&(this.storeCurrency=this.dataset.currency),this.urlParams.code!==null){this.setLocalStorageLocation(this.urlParams.code);return}this.replaceLocationInfo()}setLocalStorageLocation(countryCode){this.userCountryName=this.countries[countryCode].name,this.storeCurrency=this.countries[countryCode].currency,this.userCountryCode=countryCode,this.sessionCountryCode=countryCode,this.setCookie()}replaceLocationInfo(){this.replaceFlag(this.sessionCountryCode),this.replaceLocationName(this.userCountryName),this.replaceCurrency(this.storeCurrency)}get urlParams(){return new Proxy(new URLSearchParams(window.location.search),{get:(searchParams,prop)=>searchParams.get(prop)})}replaceLocationName(locationName){this.els?.countryName?.exists&&locationName!=="null"&&locationName!==null&&(this.els.countryName.element.innerText=locationName)}replaceCurrency(currency){currency===null||currency==="null"||this.els?.currency?.exists&&(this.els.currency.element.innerText=currency.toUpperCase())}replaceFlag(code){let chosenCode=code;(chosenCode===null||chosenCode==="null")&&(chosenCode=this.dataset.code);const country=this.countries[chosenCode];let url=`https://raw.githubusercontent.com/catamphetamine/country-flag-icons/master/flags/3x2/${chosenCode}.svg`;country?.flag==="EU"&&(url="https://raw.githubusercontent.com/catamphetamine/country-flag-icons/master/flags/3x2/EU.svg"),(country?.flag==="ROW"||country?.name==="ROW"||country===void 0)&&(url="https://cdn.shopify.com/s/files/1/0549/8912/7731/files/ROW-Flag.svg?v=1651837001"),this.els.flag?.element.setAttribute("src",url),this.els.flag?.element.setAttribute("alt",chosenCode),this.els.flag?.element.classList.remove("str-StoreSelector_Flag-hidden")}get sites(){return{UK:"https://www.lacoquetakids.com",US:"https://us.lacoquetakids.com",INT:"https://int.lacoquetakids.com"}}get path(){return window.location.pathname}get countries(){return window.theme.countries}get labelCountryCode(){return"BAO-session-country-code"}get labelUserCountryCode(){return"BAO-dropdown-country-code"}get userCountryCode(){return window.localStorage.getItem(this.labelUserCountryCode)||null}set userCountryCode(countryCode){window.localStorage.setItem(this.labelUserCountryCode,countryCode)}get sessionCountryCode(){return window.localStorage.getItem(this.labelCountryCode)||null}set sessionCountryCode(countryCode){window.localStorage.setItem(this.labelCountryCode,countryCode)}get labelCountryName(){return"BAO-dropdown-country-name"}get userCountryName(){return window.localStorage.getItem(this.labelCountryName)||null}set userCountryName(countryName){window.localStorage.setItem(this.labelCountryName,countryName)}get labelStoreCurrency(){return"BAO-dropdown-store-currency"}get storeCurrency(){return window.localStorage.getItem(this.labelStoreCurrency)||null}set storeCurrency(storeCurrency){window.localStorage.setItem(this.labelStoreCurrency,storeCurrency)}get cookieName(){return"BAO-GeoIP"}setCookie(){window.Cookies.get(this.cookieName)||(window.Cookies.set(this.cookieName,!0,{expires:7}),this.storeModalActioned=!0)}}customElements.get("store-selector")||customElements.define("store-selector",StoreSelector);
4//# sourceMappingURL=/cdn/shop/t/291/assets/store-selector.js.map?v=91967110598024234931774367740

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.