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,aAAa,OAAQC,mBAAmBb,KAEnDnB,GACAT,OAAO0C,QAAQjC,UAAU,CAAEkC,KAAMb,EAAW,GAAK,KAAMvB,EAE/D,IAEZ,CAlEAP,OAAO4C,iBAAiB,SAAUlD,EAAe,CAAEmD,SAAS,IAC5D7C,OAAO4C,iBAAiB,YAAaE,IAC7BA,EAAMC,OAASD,EAAMC,MAAMC,MAC3B3C,EAAcL,OAAOiD,UAAU,GAAM,EACzC,G","sources":["webpack:///./Scripts/brafab.lazypagination.js"],"sourcesContent":["var lazySearching = false;\nwindow.addEventListener('scroll', lazyScrolling, { passive: true });\nwindow.addEventListener('popstate', (event) => {\n if (event.state && event.state.lazy) {\n fetchProducts(window.location, true, false);\n }\n});\n\nfunction lazyScrolling() {\n const lazyLoader = document.getElementById('lazyloader');\n const prodList = document.getElementsByClassName('product-list')[0];\n\n if (window.innerHeight + document.documentElement.scrollTop >= prodList.scrollHeight) {\n const href = lazyLoader.getAttribute('href');\n fetchProducts(href, false, true);\n return false;\n }\n};\n\nfunction fetchProducts(href, all, pushState) {\n if (lazySearching === true) return;\n lazySearching = true;\n var lazyLoader = document.getElementById('lazyloader');\n lazyLoader.classList.add(\"active\");\n const max = parseInt(lazyLoader.getAttribute('data-max'));\n\n fetch(href + (href.indexOf('?') !== -1 ? '&' : '?') + \"lazy=true\",\n {\n method: 'GET',\n headers: {\n 'pragma': 'no-cache',\n 'cache-control': 'no-cache',\n 'lazy': 'true',\n 'all': all\n }\n })\n .then(response => response.json())\n .then(data => {\n lazySearching = false;\n const prodList = document.getElementsByClassName('product-list')[1]; // TODO: ändra i enlighet med PLP:ns styling \n if (all || (!all && !pushState)) {\n prodList.innerHTML = '';\n }\n if (prodList) {\n if (data.dataLayer && typeof dataLayer !== 'undefined' && dataLayer !== null)\n {\n gtag(\"event\", \"view_item_list\", data.dataLayer);\n }\n\n prodList.innerHTML += data.view;\n window.__litium.bootstrapComponents();\n const url = new URL(href);\n const nextPage = getNextPage(url);\n url.searchParams.delete('lazy');\n lazyLoader.classList.remove(\"active\");\n\n if (nextPage > max) {\n window.removeEventListener('scroll', lazyScrolling);\n } else {\n url.searchParams.set(\"page\", nextPage);\n lazyLoader.setAttribute('href', decodeURIComponent(url));\n }\n if (pushState) {\n window.history.pushState({ page: nextPage - 1 }, null, href);\n }\n }\n });\n}\n\nfunction getNextPage(url) {\n var hasPage = url.searchParams.has(\"page\");\n return hasPage ? parseInt(url.searchParams.get(\"page\")) + 1 : 2;\n}"],"names":["lazySearching","lazyScrolling","lazyLoader","document","getElementById","prodList","getElementsByClassName","window","innerHeight","documentElement","scrollTop","scrollHeight","fetchProducts","getAttribute","href","all","pushState","classList","add","max","parseInt","fetch","indexOf","method","headers","then","response","json","data","innerHTML","dataLayer","gtag","view","__litium","bootstrapComponents","url","URL","nextPage","hasPage","searchParams","has","get","getNextPage","delete","remove","removeEventListener","set","setAttribute","decodeURIComponent","history","page","addEventListener","passive","event","state","lazy","location"],"sourceRoot":""}