{"version":3,"file":"scripts.min.js","sources":["assets/js/modules/newsletter.js","assets/js/scripts.js","assets/js/modules/mobileMenuOpen.js","assets/js/modules/mobileMenuClose.js"],"sourcesContent":["export default function validationNewsletter() {\n const newsletterInput = document.querySelector('.js--newsletter-input');\n const newsletterForm = document.querySelector('.newsletter__form');\n let newsletterErrorMessage;\n const newsletterSuccessMessage = document.querySelector('.newsletter__form__success-message');\n const regex = /^(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n let emailValue = '';\n\n const isValidEmail = () => {\n if (!emailValue) return false;\n if (emailValue) {\n const isValid = regex.test(emailValue);\n if (!isValid) return false;\n }\n return true;\n };\n const emailvalidation = () => {\n if (window.innerWidth < 850) {\n newsletterErrorMessage = document.querySelector('.newsletter__form-error--sm');\n } else {\n newsletterErrorMessage = document.querySelector('.newsletter__form-error--lg');\n }\n if (isValidEmail()) {\n newsletterInput.classList.remove('newsletter__input--invalid');\n newsletterErrorMessage.classList.remove('newsletter__form-error--active');\n } else {\n newsletterInput.classList.add('newsletter__input--invalid');\n newsletterErrorMessage.classList.add('newsletter__form-error--active');\n }\n };\n const showSucessMessage = () => {\n newsletterForm.classList.add('newsletter__form--submitted');\n setTimeout(() => {\n newsletterSuccessMessage.classList.add('newsletter__form__success-message--active');\n }, 1500);\n };\n const submitForm = (e) => {\n emailvalidation();\n if (!isValidEmail()) {\n e.preventDefault();\n return false;\n }\n showSucessMessage();\n return false;\n };\n\n newsletterInput.addEventListener('change', (e) => { emailValue = e.target.value; });\n newsletterInput.addEventListener('blur', emailvalidation);\n newsletterForm.addEventListener('submit', submitForm);\n}\n\n","import validationNewsletter from './modules/newsletter';\nimport mobileMenuOpen from './modules/mobileMenuOpen';\nimport mobileMenuClose from './modules/mobileMenuClose';\n\nconst App = (() => {\n\tfunction focusAndOpenKeyboard(el, timeout) {\n\t\tif (!timeout) {\n\t\t\ttimeout = 100;\n\t\t}\n\t\tif (el) {\n\t\t\t// Align temp input element approximately where the input element is\n\t\t\t// so the cursor doesn't jump around\n\t\t\tvar __tempEl__ = document.createElement('input');\n\t\t\t__tempEl__.style.position = 'absolute';\n\t\t\t__tempEl__.style.top = el.offsetTop + 7 + 'px';\n\t\t\t__tempEl__.style.left = el.offsetLeft + 'px';\n\t\t\t__tempEl__.style.height = 0;\n\t\t\t__tempEl__.style.opacity = 0;\n\t\t\t// Put this temp element as a child of the page and focus on it\n\t\t\tdocument.body.appendChild(__tempEl__);\n\t\t\t__tempEl__.focus();\n\n\t\t\t// The keyboard is open. Now do a delayed focus on the target element\n\t\t\tsetTimeout(function() {\n\t\t\t\tel.focus();\n\t\t\t\tel.click();\n\t\t\t\t// Remove the temp element\n\t\t\t\tdocument.body.removeChild(__tempEl__);\n\t\t\t}, timeout);\n\t\t}\n\t}\n\n\tconst setBigLetter = () => {\n\t\tif (document.querySelector('.post-entry__header')) {\n\t\t\tconst firstLetter = document.querySelector('.post-entry__header').textContent.charAt(0);\n\t\t\tconst bigLetter = document.querySelector('.post-entry span');\n\t\t\tbigLetter.textContent = firstLetter;\n\t\t}\n\t};\n\n\tconst handleOpenSearchbar = () => {\n\t\tconst searchIcon = document.querySelector('.header__searchbar__icon');\n\t\tconst header = document.querySelector('.header');\n\t\tconst textInput = header.querySelector('input[type=\"text\"]');\n\t\ttextInput.placeholder = 'Wyszukaj na blogu';\n\t\tsearchIcon.addEventListener('click', () => {\n\t\t\theader.classList.toggle('header--open-searchbar');\n\t\t\tif (header.classList.contains('header--open-searchbar')) {\n\t\t\t\tdocument.querySelector('.algolia-autocomplete').style = 'display: none';\n\t\t\t\ttextInput.value = '';\n\t\t\t}\n\t\t\tvar myElement = document.querySelector('.aa-input');\n\t\t\tvar modalFadeInDuration = 300;\n\t\t\tfocusAndOpenKeyboard(myElement, modalFadeInDuration); // or without the second argument\n\t\t});\n\t};\n\tconst handleCloseSearchbar = () => {\n\t\tconst header = document.querySelector('.header');\n\t\tconst closeButton = document.querySelector('#close-searchbar');\n\t\tif (closeButton) {\n\t\t\tcloseButton.addEventListener('click', () => {\n\t\t\t\theader.classList.remove('header--open-searchbar');\n\t\t\t});\n\t\t}\n\t};\n\n\tconst scrollSearch = () => {\n\t\tconst mq = window.matchMedia('(max-width: 1045px)');\n\t\tconst searchBtn = document.querySelector('.search-btn');\n\t\tconst header = document.querySelector('.header');\n\t\tif (mq.matches) {\n\t\t\tif (!header.classList.contains('header--open-searchbar')) {\n\t\t\t\tsearchBtn.classList.add('search-btn--open');\n\t\t\t}\n\t\t}\n\t\tlet prevScrollpos = window.pageYOffset;\n\t\twindow.onscroll = () => {\n\t\t\tif (mq.matches) {\n\t\t\t\tconst currentScrollPos = window.pageYOffset;\n\t\t\t\tif (currentScrollPos <= 100) {\n\t\t\t\t\tif (!header.classList.contains('header--open-searchbar')) {\n\t\t\t\t\t\tsearchBtn.classList.add('search-btn--open');\n\t\t\t\t\t}\n\t\t\t\t} else if (prevScrollpos > currentScrollPos) {\n\t\t\t\t\tif (!header.classList.contains('header--open-searchbar')) {\n\t\t\t\t\t\tsearchBtn.classList.add('search-btn--open');\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tsearchBtn.classList.remove('search-btn--open');\n\t\t\t\t}\n\t\t\t\tprevScrollpos = currentScrollPos;\n\t\t\t}\n\t\t};\n\t};\n\tconst handleSearchBtn = () => {\n\t\tif (document.querySelector('.search-btn')) {\n\t\t\tconst searchBtn = document.querySelector('.search-btn');\n\t\t\tsearchBtn.addEventListener('click', () => {\n\t\t\t\tsearchBtn.classList.remove('search-btn--open');\n\t\t\t\tdocument.querySelector('.header__searchbar__icon').click();\n\t\t\t});\n\t\t}\n\t};\n\tconst handleInputFocus = () => {\n\t\tif (document.querySelector('.header__searchbar__content')) {\n\t\t\tdocument.querySelector('.header__searchbar__content').addEventListener('click', () => {\n\t\t\t\tdocument.querySelector('.search-btn').classList.remove('search-btn--open');\n\t\t\t});\n\t\t}\n\t\tif (document.querySelector('.header').classList.contains('header--open-searchbar')) {\n\t\t\tdocument.querySelector('.search-btn').classList.remove('search-btn--open');\n\t\t}\n\t};\n\n\tconst lazyLoadInstagramIframe = () => {\n\t\tconst lazyWrapper = document.querySelector('.instagram-iframe');\n\t\tif (lazyWrapper) {\n\t\t\tlet options = {};\n\t\t\tlet hasIframeLoaded = false;\n\n\t\t\tlet observer = new IntersectionObserver((entries, observer) => {\n\t\t\t\tentries.forEach(entry => {\n\t\t\t\t\tif (entry.isIntersecting && !hasIframeLoaded) {\n\t\t\t\t\t\thasIframeLoaded = true;\n\t\t\t\t\t\tconst script = document.createElement('script');\n\t\t\t\t\t\tscript.src = '//www.instagram.com/embed.js';\n\t\t\t\t\t\tlazyWrapper.appendChild(script);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}, options);\n\t\t\tobserver.observe(lazyWrapper);\n\t\t}\n\t};\n\n\tconst imgWithDescription = () => {\n\t\tconst img_mobile = document.querySelector('.image-with-description__image-mobile');\n\t\tif (img_mobile && img_mobile.style.display == 'block') {\n\t\t\tconst img_desktop = document.querySelector('.image-with-description__image');\n\t\t\timg_desktop.style.display = 'block';\n\t\t\timg_mobile.style.display = 'none';\n\t\t}\n\t};\n\n\treturn {\n\t\tinit: () => {\n\t\t\tsetBigLetter();\n\t\t\thandleOpenSearchbar();\n\t\t\thandleCloseSearchbar();\n\t\t\tvalidationNewsletter();\n\t\t\tmobileMenuOpen();\n\t\t\tmobileMenuClose();\n\t\t\tscrollSearch();\n\t\t\thandleSearchBtn();\n\t\t\thandleInputFocus();\n\t\t\timgWithDescription();\n\t\t},\n\t};\n})();\nApp.init();\n","export default function mobileMenuOpen() {\n const headerNav = document.querySelector('.header__nav');\n const hiddenElement = headerNav.querySelector('.has-arrow');\n document.querySelector('.header__hamburger').addEventListener('click', () => {\n hiddenElement.style.display = 'none';\n headerNav.classList.add('header__nav--open');\n document.querySelector('body').classList.add('scroll-disable');\n });\n}\n","export default function mobileMenuClose() {\n const headerNav = document.querySelector('.header__nav');\n const hiddenElement = headerNav.querySelector('.has-arrow');\n if (document.querySelector('.header__nav-close')) {\n const close = document.querySelector('.header__nav-close');\n close.addEventListener('click', () => {\n hiddenElement.style.display = 'block';\n headerNav.classList.remove('header__nav--open');\n document.querySelector('body').classList.remove('scroll-disable');\n });\n }\n}\n"],"names":["validationNewsletter","newsletterInput","document","querySelector","newsletterForm","newsletterErrorMessage","newsletterSuccessMessage","regex","emailValue","isValidEmail","test","emailvalidation","window","innerWidth","classList","remove","add","addEventListener","e","target","value","setTimeout","preventDefault","handleOpenSearchbar","searchIcon","header","textInput","placeholder","toggle","contains","style","el","timeout","__tempEl__","createElement","position","top","offsetTop","left","offsetLeft","height","opacity","body","appendChild","focus","click","removeChild","focusAndOpenKeyboard","init","firstLetter","textContent","charAt","setBigLetter","closeButton","handleCloseSearchbar","headerNav","hiddenElement","display","mobileMenuOpen","mobileMenuClose","mq","matchMedia","searchBtn","matches","prevScrollpos","pageYOffset","onscroll","currentScrollPos","scrollSearch","handleSearchBtn","img_mobile","imgWithDescription"],"mappings":"yBAAe,SAASA,UAChBC,EAAkBC,SAASC,cAAc,yBACzCC,EAAiBF,SAASC,cAAc,yBAC1CE,QACEC,EAA2BJ,SAASC,cAAc,sCAClDI,EAAQ,4JACVC,EAAa,SAEXC,EAAe,SACdD,EAAY,OAAO,KACpBA,EAAY,KACED,EAAMG,KAAKF,GACb,OAAO,SAEhB,GAEHG,EAAkB,KAEpBN,EADEO,OAAOC,WAAa,IACGX,SAASC,cAAc,+BAEvBD,SAASC,cAAc,+BAE9CM,KACFR,EAAgBa,UAAUC,OAAO,8BACjCV,EAAuBS,UAAUC,OAAO,oCAExCd,EAAgBa,UAAUE,IAAI,8BAC9BX,EAAuBS,UAAUE,IAAI,oCAmBzCf,EAAgBgB,iBAAiB,UAAWC,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