PageSourceSearch

https://www.lovisa.co.uk/cdn/shop/t/811/assets/site-header.js?v=98583069637357765891789977862

js lovisa.co.uk collected 2026-09-26 13:25:22 UTC 17,530 bytes, 2 lines download raw bytes

1(function(){const sectionSelector='[data-section-type="site-header"]';function getSearchApp(){const existing=window.theme&&window.theme.SearchApp;if(existing&&typeof existing.showModal=="function")return existing;const predictive=document.querySelector("predictive-search.search");if(predictive&&typeof predictive.showModal=="function")return window.theme=window.theme||{},window.theme.SearchApp=predictive,predictive;const tagalysEl=document.querySelector("#search--app"),tagalysApp=tagalysEl&&tagalysEl.__vue__;return tagalysApp&&typeof tagalysApp.showModal=="function"?(window.theme=window.theme||{},window.theme.SearchApp=tagalysApp,tagalysApp):null}function getSearchPanelElement(){const searchApp=getSearchApp();if(searchApp){if(searchApp.$el)return searchApp.$el;if(searchApp.nodeType===1)return searchApp}return document.querySelector("#search--app")||document.querySelector("predictive-search.search")}function isDesktop(){return window.matchMedia&&window.matchMedia("(min-width: 990px)").matches}function isSearchOpen(){const searchApp=getSearchApp();return searchApp&&searchApp.isVisible||document.body.classList.contains("search-is-visible")}function getDesktopSearch(section){return section.querySelector(".shd__search[data-shd-search]")}function resetDesktopSearchUi(section){const search=getDesktopSearch(section);if(!search)return;search.classList.remove("is-focused");const input=search.querySelector("[data-shd-search-input]");input&&document.activeElement===input&&input.blur()}function syncSearchUiState(section,isOpen){const search=getDesktopSearch(section);if(!search)return;const input=search.querySelector("[data-shd-search-input]"),closeTrigger=search.querySelector("[data-shd-search-close]");search.classList.toggle("is-open",isOpen),isOpen&&search.classList.add("is-focused"),input&&input.setAttribute("aria-expanded",isOpen?"true":"false"),closeTrigger&&(closeTrigger.setAttribute("aria-hidden",isOpen?"false":"true"),closeTrigger.tabIndex=isOpen?0:-1)}function isDesktopSearchTarget(node){return node&&node.closest&&node.closest("[data-shd-search], #shopify-search-host, #search--app, predictive-search.search, .tagalys-search-suggestions, .search-suggestions")}function activateSearch(section,search,input){if(!(section.__shdIgnoreSearchFocus||section.__shdClosingSearch)){if(search.classList.add("is-focused"),!isSearchOpen()){openSearch(section,input);return}syncSearchUiState(section,!0),positionSearch(section),syncQueryToSearchApp(input)}}function patchSearchAppForDesktop(){const app=getSearchApp();if(!app||app.__shdDesktopPatched)return;app.__shdDesktopPatched=!0,app.boundClickHandler&&(app.mainContent&&app.mainContent.removeEventListener("click",app.boundClickHandler),app.bgOverlay&&app.bgOverlay.removeEventListener("click",app.boundClickHandler));const nativeShow=app.showModal.bind(app),nativeHide=app.hideModal.bind(app),panel=app.$el||app;app.showModal=function(){if(!isDesktop()){nativeShow();return}window.theme=window.theme||{},window.theme.lastActiveElement=null,document.body.classList.add("search-is-visible"),app.isVisible=!0,app.bgOverlay&&app.bgOverlay.setAttribute("aria-hidden","false"),panel.setAttribute&&panel.setAttribute("aria-hidden","false"),panel.classList&&panel.classList.add("is-visible"),app.wasModalShown||(typeof app.setTrendingSearches=="function"&&app.setTrendingSearches(),app.wasModalShown=!0)},app.hideModal=function(){if(!isDesktop()){nativeHide();return}window.theme=window.theme||{},window.theme.lastActiveElement=null,document.body.classList.remove("search-is-visible"),app.isVisible=!1,app.bgOverlay&&app.bgOverlay.setAttribute("aria-hidden","true"),panel.setAttribute&&panel.setAttribute("aria-hidden","true"),panel.classList&&panel.classList.remove("is-visible"),document.querySelectorAll(sectionSelector).forEach(function(sec){syncSearchUiState(sec,!1),resetDesktopSearchUi(sec)})}}function syncDesktopSearchState(search){const input=search&&search.querySelector("[data-shd-search-input]");input&&search.classList.toggle("has-value",!!(input.value&&input.value.trim()))}function positionSearch(section){const searchElement=getSearchPanelElement(),headerBar=section.querySelector(".shd__bar");
1if(searchElement&&searchElement.style&&headerBar){const bottom=headerBar.getBoundingClientRect().bottom;searchElement.style.top=Math.max(Math.round(bottom),0)+"px"}}function getSearchAppInput(app){if(!app)return null;if(app.searchInput)return app.searchInput;if(app.$refs&&app.$refs.searchQuery)return app.$refs.searchQuery;const panel=getSearchPanelElement();return panel&&panel.querySelector?panel.querySelector("#search-input-main")||panel.querySelector('input[name="q"]')||panel.querySelector('input[name="query"]'):document.querySelector("#search-input-main")||document.querySelector('#search--app input[name="q"]')}function syncQueryToSearchApp(headerInput){const app=getSearchApp(),appInput=getSearchAppInput(app);if(!appInput||!headerInput)return;const nextValue=headerInput.value;appInput.value!==nextValue&&(appInput.value=nextValue);try{appInput.dispatchEvent(new Event("input",{bubbles:!0})),appInput.dispatchEvent(new Event("keyup",{bubbles:!0}))}catch{}typeof app.onSearch=="function"&&app.onSearch()}function scheduleSearchOpen(section,headerInput){if(section.__shdSearchRetryTimer)return;let attempts=0;function retry(){if(section.__shdSearchRetryTimer=null,!(section.__shdClosingSearch||section.__shdIgnoreSearchFocus)){if(getSearchApp()){openSearch(section,headerInput);return}++attempts<20&&(section.__shdSearchRetryTimer=window.setTimeout(retry,50))}}section.__shdSearchRetryTimer=window.setTimeout(retry,0)}function closeSearch(section){if(section.__shdClosingSearch)return;section.__shdClosingSearch=!0,section.__shdIgnoreSearchFocus=!0,section.__shdSearchRetryTimer&&(window.clearTimeout(section.__shdSearchRetryTimer),section.__shdSearchRetryTimer=null),window.theme=window.theme||{},window.theme.lastActiveElement=null,patchSearchAppForDesktop();const searchApp=getSearchApp();searchApp&&typeof searchApp.hideModal=="function"?(searchApp.isVisible||document.body.classList.contains("search-is-visible"))&&searchApp.hideModal():(document.body.classList.remove("search-is-visible"),syncSearchUiState(section,!1),resetDesktopSearchUi(section)),window.setTimeout(function(){section.__shdClosingSearch=!1,section.__shdIgnoreSearchFocus=!1},150)}function openSearch(section,headerInput){if(section.__shdClosingSearch||section.__shdIgnoreSearchFocus)return;patchSearchAppForDesktop();const searchApp=getSearchApp(),search=getDesktopSearch(section),input=headerInput||search&&search.querySelector("[data-shd-search-input]");if(!searchApp){scheduleSearchOpen(section,input);return}if(isSearchOpen()){syncSearchUiState(section,!0),positionSearch(section),syncQueryToSearchApp(input);return}if(typeof searchApp.showModal=="function")searchApp.showModal();else return;syncSearchUiState(section,!0),requestAnimationFrame(function(){positionSearch(section),syncQueryToSearchApp(input)})}function getActivePlaceholderQuery(search){if(!search||!search.querySelector)return"";const fallback=search.querySelector("[data-ph-word].is-active")||search.querySelector("[data-ph-word]");return fallback?String(fallback.getAttribute("data-label")||fallback.textContent||"").trim():""}function getProviderSearchParam(){return window.theme&&window.theme.searchProvider==="tagalys"?"query":"q"}function rememberSearchQuery(query){if(!query)return;let lastSearches=[];try{lastSearches=localStorage.getItem("lastSearches")?JSON.parse(localStorage.getItem("lastSearches")):[]}catch{lastSearches=[]}lastSearches=lastSearches.filter(function(s){return String(s).toLowerCase()!==query.toLowerCase()}),lastSearches.unshift(query),lastSearches=lastSearches.slice(0,10);try{localStorage.setItem("lastSearches",JSON.stringify(lastSearches))}catch{}}function refreshBag(section){const target=section.querySelector(".header__cart-count");if(!target)return;const count=parseInt(target.textContent,10)||0;target.classList.toggle("hide",count===0);const bagLink=target.closest("a");bagLink&&bagLink.getAttribute("data-bag-label")&&bagLink.setAttribute("aria-label",bagLink.getAttribute("data-bag-label")+" ("+count+")")}function prefersReducedMotion(){return window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function setupPlaceholder(section){const pill=getDesktopSearch(section);if(!pill)return;const goLink=pill.querySelector("[data-shd-search-go]"),input=pill.querySelector("[data-shd-search-input]"),words=pill.querySelectorAll("[data-ph-word]");if(!goLink||words.length===0)return;const openSearchLabel=goLink.getAttribute("aria-label")||"Search",searchUrl=goLink.getAttribute("data-search-url")||"/search";function syncGo(word){const link=word&&word.getAttribute("data-link"),label=word&&word.getAttribute("data-label")||"";link?(goLink.setAttribute("href",link),goLink.removeAttribute("data-no-link"),goLink.setAttribute("aria-label",label?"Go to "+label:openSearchLabel)):(goLink.setAttribute("href",searchUrl),goLink.setAttribute("data-no-link",""),goLink.setAttribute("aria-label",openSearchLabel))}let index=0;for(let i=0;i<words.length;i++)if(words[i].classList.contains("is-active")){index=i;break}if(syncGo(words[index]),goLink.addEventListener("click",function(event){goLink.hasAttribute("data-no-link")&&(event.preventDefault(),input&&(isSearchOpen()||openSearch(section,input),input.focus({preventScroll:!0})))}),words.length<2||prefersReducedMotion())return;let hovering=!1;pill.addEventListener("mouseenter",function(){hovering=!0}),pill.addEventListener("mouseleave",function(){hovering=!1}),pill.addEventListener("focusin",function(){hovering=!0}),pill.addEventListener("focusout",function(){hovering=!1});function paused(){return hovering||document.hidden||pill.classList.contains("is-focused")||pill.classList.contains("has-value")||document.body.classList.contains("search-is-visible")}function getDesktopPhInterval(section2){const raw=section2&&section2.getAttribute("data-ph-interval"),value=parseInt(raw,10);return value>=2e3?value:4e3}function advance(){if(paused())return;const current=words[index],nextIndex=(index+1)%words.length,next=words[nextIndex];current.classList.remove("is-active"),current.classList.add("is-leaving"),window.setTimeout(function(){current.classList.remove("is-leaving")},550),next.classList.remove("is-leaving"),next.classList.add("is-active"),index=nextIndex,syncGo(next)}section.__shdPhTimer=window.setInterval(advance,getDesktopPhInterval(section))}function setupDesktopSearch(section){const search=getDesktopSearch(section);if(!search||search.__shdSearchBound)return;search.__shdSearchBound=!0,patchSearchAppForDesktop();const input=search.querySelector("[data-shd-search-input]"),form=search.querySelector("[data-shd-search-form]"),closeBtn=search.querySelector("[data-shd-search-close]");input&&(input.addEventListener("pointerdown",function(){section.__shdPointerOnInput=!0}),input.addEventListener("focus",function(){section.__shdPointerOnInput||activateSearch(section,search,input)}),input.addEventListener("click",function(){section.__shdPointerOnInput=!1,activateSearch(section,search,input)}),input.addEventListener("input",function(){section.__shdIgnoreSearchFocus||section.__shdClosingSearch||(syncDesktopSearchState(search),isSearchOpen()?syncQueryToSearchApp(input):openSearch(section,input))})),form&&form.addEventListener("submit",function(event){let query=input?input.value.trim():"";if(!query&&input&&(query=getActivePlaceholderQuery(search),query&&(input.value=query,syncDesktopSearchState(search),syncQueryToSearchApp(input))),!query){event.preventDefault();return}rememberSearchQuery(query);const desiredParam=getProviderSearchParam();input&&input.name!==desiredParam&&(event.preventDefault(),window.location.assign((form.getAttribute("action")||"/search")+"?"+desiredParam+"="+encodeURIComponent(query)))}),closeBtn&&(closeBtn.addEventListener("mousedown",function(event){event.preventDefault()}),closeBtn.addEventListener("click",function(event){event.preventDefault(),closeSearch(section)}));const onPointerDownOutside=function(event){!isDesktop()||!isSearchOpen()||isDesktopSearchTarget(event.target)||closeSearch(section)};document.addEventListener("pointerdown",onPointerDownOutside,!0),section.__shdSearchOutsideHandler=onPointerDownOutside,document.addEventListener("keydown",function(event){event.key==="Escape"&&isSearchOpen()&&closeSearch(section)}),syncDesktopSearchState(search),syncSearchUiState(section,isSearchOpen())}function setupSubmenus(section){const items=section.querySelectorAll('.shd__item[data-has-children="true"]');if(!items.length)return;const overlay=document.querySelector(".bg-overlay");let openItem=null,closeTimer=null;function cancelClose(){closeTimer&&(window.clearTimeout(closeTimer),closeTimer=null)}function setExpanded(item,expanded){const link=item.querySelector(".shd__link");link&&link.setAttribute("aria-expanded",expanded?"true":"false")}
1function openPanel(item){if(cancelClose(),openItem===item)return;const switching=openItem&&openItem!==item;openItem&&(openItem.classList.remove("is-open"),setExpanded(openItem,!1)),switching&&document.body.classList.add("shd-submenu-switching"),openItem=item,item.classList.add("is-open"),setExpanded(item,!0),document.body.classList.add("shd-submenu-open"),switching&&window.requestAnimationFrame(function(){document.body.classList.remove("shd-submenu-switching")})}function closePanel(){cancelClose(),openItem&&(openItem.classList.remove("is-open"),setExpanded(openItem,!1),openItem=null,document.body.classList.remove("shd-submenu-open","shd-submenu-switching"))}function scheduleClose(){cancelClose(),closeTimer=window.setTimeout(closePanel,120)}for(let i=0;i<items.length;i++){const item=items[i];item.addEventListener("mouseenter",function(){openPanel(item)}),item.addEventListener("mouseleave",scheduleClose),item.addEventListener("focusin",function(){openPanel(item)}),item.addEventListener("focusout",function(event){item.contains(event.relatedTarget)||scheduleClose()})}const onOverlayClick=function(){closePanel()},onKeydown=function(event){event.key==="Escape"&&closePanel()},onScroll=function(){closePanel()};overlay&&overlay.addEventListener("click",onOverlayClick),document.addEventListener("keydown",onKeydown),window.addEventListener("scroll",onScroll,{passive:!0}),section.__shdSubmenuCleanup=function(){closePanel(),overlay&&overlay.removeEventListener("click",onOverlayClick),document.removeEventListener("keydown",onKeydown),window.removeEventListener("scroll",onScroll)}}function fitHeader(section){const bar=section.querySelector(".shd__bar"),menu=section.querySelector(".shd__menu");!bar||!menu||(menu.classList.remove("shd__menu--wrap"),bar.scrollWidth-bar.clientWidth>1&&menu.classList.add("shd__menu--wrap"))}let fitQueued=!1;function fitAllHeaders(){fitQueued=!1;const nodes=document.querySelectorAll(sectionSelector);for(let i=0;i<nodes.length;i++)fitHeader(nodes[i]);document.dispatchEvent(new CustomEvent("header:metrics-updated"))}function queueFit(){fitQueued||(fitQueued=!0,window.requestAnimationFrame(fitAllHeaders))}function init(section){if(!(!section||section.__shdInit)&&(section.__shdInit=!0,setupDesktopSearch(section),setupPlaceholder(section),setupSubmenus(section),fitHeader(section),section.querySelector(".shd__bag-count"))){refreshBag(section);const onCartChange=function(){refreshBag(section)};document.addEventListener("cart:rendered",onCartChange),document.addEventListener("side-cart:rendered",onCartChange),section.__shdCartHandler=onCartChange}}function notifyHeaderMetrics(){document.dispatchEvent(new CustomEvent("header:metrics-updated"))}function boot(){const nodes=document.querySelectorAll(sectionSelector);for(let i=0;i<nodes.length;i++)init(nodes[i]);notifyHeaderMetrics()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",boot):boot(),document.addEventListener("shopify:section:load",function(event){if(!event.target||!event.target.querySelector)return;const node=event.target.matches&&event.target.matches(sectionSelector)?event.target:event.target.querySelector(sectionSelector);init(node),notifyHeaderMetrics()}),document.addEventListener("shopify:section:unload",function(event){if(!event.target||!event.target.querySelector)return;const node=event.target.matches&&event.target.matches(sectionSelector)?event.target:event.target.querySelector(sectionSelector);node&&node.__shdCartHandler&&(document.removeEventListener("cart:rendered",node.__shdCartHandler),document.removeEventListener("side-cart:rendered",node.__shdCartHandler)),node&&node.__shdPhTimer&&(window.clearInterval(node.__shdPhTimer),node.__shdPhTimer=null),node&&node.__shdSubmenuCleanup&&(node.__shdSubmenuCleanup(),node.__shdSubmenuCleanup=null),node&&node.__shdSearchOutsideHandler&&(document.removeEventListener("pointerdown",node.__shdSearchOutsideHandler,!0),node.__shdSearchOutsideHandler=null),node&&node.__shdSearchRetryTimer&&(window.clearTimeout(node.__shdSearchRetryTimer),node.__shdSearchRetryTimer=null)}),window.addEventListener("resize",function(){if(queueFit(),!document.body.classList.contains("search-is-visible"))return;const nodes=document.querySelectorAll(sectionSelector);for(let i=0;i<nodes.length;i++)positionSearch(nodes[i])}),window.addEventListener("load",function(){patchSearchAppForDesktop(),fitAllHeaders()}),document.fonts&&document.fonts.ready&&document.fonts.ready.then(fitAllHeaders)})();
2//# sourceMappingURL=/cdn/shop/t/811/assets/site-header.js.map?v=98583069637357765891789977862

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.