{"version":3,"sources":["webpack:///./LeLab.Web/src/js/header.entry.js"],"names":["WindowScrollY","updatedWindowScrollY","window","scrollY","addEventListener","isIOS","CSS","supports","HeaderSubNav","constructor","header","subNav","this","html","document","querySelector","navItem","closest","navLink","clickOutsideHandler","clickOutside","bind","toggleHandler","toggle","openHandler","open","closeHandler","close","e","contains","target","isDesktop","classList","stopPropagation","closeAllSubNav","showOverlay","add","hideOverlay","remove","destroy","removeEventListener","PageComponent","node","overlay","button","banner","menu","subNavRegistry","windowWidth","innerWidth","prevScrollY","toggleMenuHandler","toggleMenu","overlayClickHandler","overlayClick","bannerAnimationEndHandler","bannerAnimationEnd","resizeHandler","resize","scrollHandler","scroll","querySelectorAll","push","isMobile","isPhone","body","style","overflow","forEach","x","closeMenu","offsetY","parseInt","getPropertyValue","isMenuOpen","Math","min","max","headerHeight","setProperty","openMenu","title","dataset","labelClose","labelMenu","matchMedia","matches","buttonClickHandler"],"mappings":"4FAAA,kBAIA,IAAIA,EAAgB,EACpB,MAAMC,EAAuB,WACzBD,EAAgBE,OAAOC,SAE3BF,IACAC,OAAOE,iBAAiB,SAAUH,GAElC,MAAMI,EAAQC,IAAIC,SAAS,iCA8K3B,MAAMC,EAEFC,YAAYC,EAAQC,GAChBC,KAAKF,OAASA,EACdE,KAAKD,OAASA,EACdC,KAAKC,KAAOC,SAASC,cAAc,QACnCH,KAAKI,QAAUJ,KAAKD,OAAOM,QAAQ,qBACnCL,KAAKM,QAAUN,KAAKI,QAAQD,cAAc,qBAE1CH,KAAKO,oBAAsBP,KAAKQ,aAAaC,KAAKT,MAClDA,KAAKU,cAAgBV,KAAKW,OAAOF,KAAKT,MACtCA,KAAKY,YAAcZ,KAAKa,KAAKJ,KAAKT,MAClCA,KAAKc,aAAed,KAAKe,MAAMN,KAAKT,MAEpCA,KAAKC,KAAKT,iBAAiB,QAASQ,KAAKO,qBACzCP,KAAKM,QAAQd,iBAAiB,QAASQ,KAAKU,eAC5CV,KAAKI,QAAQZ,iBAAiB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+B,eACL/B,KAAKgC,cACLhC,KAAKiC,cACLjC,KAAKkC,YACLlC,KAAKmC,sBACLnC,KAAKoC,mBACLpC,KAAKT,eACLS,KAAKsC,mBAELtC,KAAK2E,0BACL3E,KAAKyC,2BACLzC,KAAK2C,iCACL3C,KAAK6C,qBACL7C,KAAK+C,mB","file":"header.js","sourcesContent":["import { PageComponent } from \"barba\"\r\n\r\n// Store the window scroll Y at a global level, \r\n// global to all class instance.\r\nlet WindowScrollY = 0\r\nconst updatedWindowScrollY = function UpdateWindowScrollY() {\r\n WindowScrollY = window.scrollY\r\n}\r\nupdatedWindowScrollY()\r\nwindow.addEventListener(\"scroll\", updatedWindowScrollY)\r\n\r\nconst isIOS = CSS.supports(\"(-webkit-touch-callout: none)\")\r\n\r\nclass Header {\r\n\r\n constructor({ node }) {\r\n this.header = node\r\n this.overlay = node.querySelector('.header__overlay')\r\n this.button = node.querySelector('.header-button')\r\n this.banner = node.querySelector('.header-banner')\r\n this.menu = node.querySelector('.header-menu')\r\n this.subNavRegistry = []\r\n this.windowWidth = window.innerWidth\r\n this.scrollY = WindowScrollY\r\n this.prevScrollY = this.scrollY\r\n\r\n this.toggleMenuHandler = this.toggleMenu.bind(this)\r\n this.overlayClickHandler = this.overlayClick.bind(this)\r\n this.bannerAnimationEndHandler = this.bannerAnimationEnd.bind(this)\r\n this.resizeHandler = this.resize.bind(this)\r\n this.scrollHandler = this.scroll.bind(this)\r\n\r\n for (let subNav of node.querySelectorAll('.header-subnav')) {\r\n this.subNavRegistry.push(new HeaderSubNav(this, subNav))\r\n }\r\n\r\n this.button.addEventListener('click', this.toggleMenuHandler)\r\n this.overlay.addEventListener('click', this.overlayClickHandler)\r\n this.banner.addEventListener('animationend', this.bannerAnimationEndHandler)\r\n window.addEventListener(\"resize\", this.resizeHandler)\r\n window.addEventListener(\"scroll\", this.scrollHandler)\r\n \r\n if (this.isMobile() && !this.isPhone() && this.subNavRegistry[0]) {\r\n this.subNavRegistry[0].open()\r\n }\r\n\r\n if (isIOS) {\r\n document.body.style.overflow = \"\"\r\n }\r\n }\r\n\r\n closeAllSubNav() {\r\n this.subNavRegistry.forEach(x => x.close())\r\n }\r\n\r\n resize() {\r\n if (this.windowWidth === window.innerWidth) {\r\n return\r\n }\r\n this.windowWidth = window.innerWidth\r\n this.closeAllSubNav()\r\n this.closeMenu()\r\n this.hideOverlay()\r\n }\r\n\r\n scroll() {\r\n const headerHeight = 56;\r\n let offsetY = parseInt(this.header.style.getPropertyValue('--header-offset-y')) || 0\r\n\r\n this.scrollY = WindowScrollY\r\n \r\n if (!this.isPhone() || this.isMenuOpen() || this.scrollY <= 0) {\r\n offsetY = 0\r\n }\r\n else {\r\n const increment = this.prevScrollY - this.scrollY\r\n offsetY = offsetY + increment\r\n offsetY = Math.min(offsetY, 0)\r\n offsetY = Math.max(offsetY, headerHeight * -1)\r\n }\r\n\r\n this.header.style.setProperty('--header-offset-y', `${offsetY}px`)\r\n this.prevScrollY = this.scrollY\r\n }\r\n\r\n toggleMenu() {\r\n if (this.isMenuOpen()) {\r\n this.closeMenu()\r\n return\r\n }\r\n this.openMenu()\r\n }\r\n\r\n openMenu() {\r\n if (!this.isMobile()) {\r\n return\r\n }\r\n\r\n if (isIOS) {\r\n document.body.style.overflow = \"hidden\"\r\n }\r\n\r\n this.header.style.setProperty('--header-offset-y', '0px')\r\n\r\n this.button.classList.add('header-button--open')\r\n this.menu.classList.add('header-menu--open')\r\n\r\n this.button.title = this.button.dataset.labelClose\r\n }\r\n\r\n closeMenu() {\r\n if (isIOS) {\r\n document.body.style.overflow = \"\"\r\n }\r\n \r\n if (!this.isMobile()) {\r\n return\r\n }\r\n\r\n this.button.classList.remove('header-button--open')\r\n this.menu.classList.remove('header-menu--open')\r\n\r\n this.button.title = this.button.dataset.labelMenu\r\n }\r\n\r\n isMenuOpen() {\r\n return this.menu.classList.contains('header-menu--open')\r\n }\r\n\r\n overlayClick() {\r\n this.isDesktop() ? this.closeAllSubNav() : null\r\n }\r\n\r\n showOverlay() {\r\n this.overlay.classList.add('header__overlay--show')\r\n }\r\n\r\n hideOverlay() {\r\n this.overlay.classList.remove('header__overlay--show')\r\n }\r\n\r\n isMobile() {\r\n return !this.isDesktop()\r\n }\r\n\r\n isDesktop() {\r\n return window.matchMedia(\"(min-width: 992px)\").matches\r\n }\r\n\r\n isPhone() {\r\n return !window.matchMedia(\"(min-width: 768px)\").matches\r\n }\r\n\r\n bannerAnimationEnd() {\r\n this.banner.classList.remove('header-banner--translate-y')\r\n }\r\n\r\n destroy() {\r\n this.subNavRegistry.forEach(x => x.destroy())\r\n\r\n this.button.removeEventListener('click', this.buttonClickHandler)\r\n this.overlay.removeEventListener('click', this.overlayClickHandler)\r\n this.banner.removeEventListener('animationend', this.bannerAnimationEndHandler)\r\n window.removeEventListener(\"resize\", this.resizeHandler)\r\n window.removeEventListener(\"scroll\", this.scrollHandler)\r\n\r\n delete this.header\r\n delete this.overlay\r\n delete this.button\r\n delete this.banner\r\n delete this.menu\r\n delete this.subNavRegistry\r\n delete this.windowWidth\r\n delete this.scrollY\r\n delete this.prevScrollY\r\n\r\n delete this.buttonClickHandler\r\n delete this.overlayClickHandler\r\n delete this.bannerAnimationEndHandler\r\n delete this.resizeHandler\r\n delete this.scrollHandler\r\n }\r\n\r\n}\r\n\r\nclass HeaderSubNav {\r\n\r\n constructor(header, subNav) {\r\n this.header = header\r\n this.subNav = subNav\r\n this.html = document.querySelector('html')\r\n this.navItem = this.subNav.closest('.header-nav__item')\r\n this.navLink = this.navItem.querySelector('.header-nav__link')\r\n\r\n this.clickOutsideHandler = this.clickOutside.bind(this)\r\n this.toggleHandler = this.toggle.bind(this)\r\n this.openHandler = this.open.bind(this)\r\n this.closeHandler = this.close.bind(this)\r\n\r\n this.html.addEventListener('click', this.clickOutsideHandler)\r\n this.navLink.addEventListener('click', this.toggleHandler)\r\n this.navItem.addEventListener('focusin', this.openHandler)\r\n this.navItem.addEventListener('focusout', this.closeHandler)\r\n }\r\n\r\n clickOutside(e) {\r\n if (!this.navItem.contains(e.target) && this.header.isDesktop()) {\r\n this.close()\r\n }\r\n }\r\n\r\n toggle(e) {\r\n if (this.subNav.classList.contains('header-subnav--open')) {\r\n this.close()\r\n return\r\n }\r\n this.open()\r\n // Prevent execution of \"clickOutside\" method\r\n e.stopPropagation()\r\n }\r\n\r\n open() {\r\n if (this.header.isDesktop()) {\r\n this.header.closeAllSubNav()\r\n this.header.showOverlay()\r\n }\r\n this.subNav.classList.add('header-subnav--open')\r\n this.navLink.classList.add('header-nav__link--open')\r\n }\r\n\r\n close() {\r\n if (this.header.isDesktop()) {\r\n this.header.hideOverlay()\r\n }\r\n this.subNav.classList.remove('header-subnav--open')\r\n this.navLink.classList.remove('header-nav__link--open')\r\n }\r\n\r\n destroy() {\r\n this.html.removeEventListener('click', this.clickOutsideHandler)\r\n this.navLink.removeEventListener('click', this.toggleHandler)\r\n this.navItem.removeEventListener('focusin', this.openHandler)\r\n this.navItem.removeEventListener('focusout', this.closeHandler)\r\n\r\n delete this.clickOutsideHandler\r\n delete this.toggleHandler\r\n delete this.openHandler\r\n delete this.closeHandler\r\n\r\n delete this.header\r\n delete this.subNav\r\n delete this.html\r\n delete this.navItem\r\n delete this.navLink\r\n }\r\n\r\n}\r\n\r\nnew PageComponent(\".header\", Header)"],"sourceRoot":""}