1var initMenuBurger = (container) => { 2 const menu = container.querySelector('.main-menu-panel') 3 const menuButton = container.querySelector('.btn-menu') 4 const closeButton = container.querySelector('.btn-menu-close') 5 const menuBg = document.querySelector('.menu-bg') 6 const fakeMenu = document.querySelector('.fake-menu') 7 const pageId = Number(container.dataset.pageId) 8 const isHomePage = pageId === 6783 9 10 const heightNavigation = parseInt( 11 getComputedStyle(document.documentElement).getPropertyValue('--height-navigation'), 12 10 13 ) 14 15 if (!menu || !menuButton || !menuBg) return 16 17 const setStickyNav = () => { 18 const hasScrolled = window.scrollY > 0 19 20 if (isHomePage) { 21 container.classList.add('fixed', 'top-0', 'left-0') 22 if (hasScrolled) { 23 container.classList.add('is-sticky') 24 } else { 25 container.classList.remove('is-sticky') 26 } 27 } else { 28 container.classList.add('is-sticky') 29 30 if (hasScrolled) { 31 fakeMenu.classList.remove('hidden') 32 container.classList.add('fixed', 'top-0', 'left-0') 33 container.classList.remove('relative') 34 } else { 35 fakeMenu.classList.add('hidden') 36 container.classList.remove('fixed', 'top-0', 'left-0') 37 container.classList.add('relative') 38 } 39 } 40 } 41 42 const openMenu = () => { 43 container.classList.add('open') 44 menuBg.classList.add('open') 45 document.body.classList.add('overflow-hidden') 46 } 47 48 const closeMenu = () => { 49 container.classList.remove('open') 50 menuBg.classList.remove('open') 51 document.body.classList.remove('overflow-hidden') 52 } 53 54 const toggleMenu = () => { 55 container.classList.contains('open') ? closeMenu() : openMenu() 56 } 57 58 setStickyNav() 59 window.addEventListener('scroll', setStickyNav, { passive: true }) 60 61 if (document.body.classList.contains('onepage')) { 62 const sections = document.querySelectorAll('section[id]') 63 const links = menu.querySelectorAll('a[data-menu], .menu-item') 64 65 links.forEach(link => { 66 link.addEventListener('click', e => { 67 const targetId = link.dataset.menu?.replace('#', '') 68 const target = document.getElementById(targetId) 69 70 if (!target) return 71 72 e.preventDefault() 73 closeMenu() 74 75 const top = target.offsetTop - heightNavigation 76 window.scrollTo({ top, behavior: 'smooth' }) 77 }) 78 }) 79 80 const changeMenuState = () => { 81 const scrollPosition = window.scrollY + heightNavigation + 100 82 let activeIndex = -1 83 84 sections.forEach((section, index) => { 85 if (scrollPosition >= section.offsetTop) activeIndex = index 86 }) 87 88 links.forEach(link => link.classList.remove('text-primary')) 89 if (activeIndex >= 0 && links[activeIndex]) { 90 links[activeIndex].classList.add('text-primary') 91 } 92 } 93 94 changeMenuState() 95 window.addEventListener('scroll', changeMenuState, { passive: true }) 96 } 97 98 menuButton.addEventListener('click', (e) => { 99 e.preventDefault() 100 e.stopPropagation() 101 toggleMenu() 102 }) 103 104 if (closeButton) { 105 closeButton.addEventListener('click', (e) => { 106 e.preventDefault() 107 e.stopPropagation() 108 closeMenu() 109 }) 110 } 111 112 menuBg.addEventListener('click', closeMenu) 113 114 document.addEventListener('keydown', (e) => { 115 if (e.key === 'Escape') closeMenu() 116 }) 117 118 document.querySelectorAll('.menu-item').forEach(btn => { 119 const btnUrl = new URL(btn.href, window.location.origin) 120 const currentUrl = new URL(window.location.href) 121 122 if (btnUrl.pathname === currentUrl.pathname) { 123 btn.classList.add('active') 124 } 125 }) 126 127 const bookingMenu = () => { 128 document.querySelectorAll('.booking-wrapper').forEach((wrapper) => { 129 const button = wrapper.querySelector('.btn-book'); 130 const submenu = wrapper.querySelector('.booking-submenu'); 131 132 if (!button || !submenu) return; 133 134 button.addEventListener('click', (e) => { 135 e.preventDefault(); 136 137 const isOpen = wrapper.classList.toggle('is-open'); 138 button.setAttribute('aria-expanded', isOpen ? 'true' : 'false'); 139 140 if (isOpen) { 141 submenu.classList.remove('opacity-0', 'pointer-events-none', 'translate-y-2'); 142 submenu.classList.add('opacity-100', 'translate-y-0'); 143 } else { 144 submenu.classList.add('opacity-0', 'pointer-events-none', 'translate-y-2'); 145 submenu.classList.remove('opacity-100', 'translate-y-0'); 146 } 147 }); 148 149 document.addEventListener('click', (e) => { 150 if (!wrapper.contains(e.target)) { 151 wrapper.classList.remove('is-open'); 152 button.setAttribute('aria-expanded', 'false'); 153 submenu.classList.add('opacity-0', 'pointer-events-none', 'translate-y-2'); 154 submenu.classList.remove('opacity-100', 'translate-y-0'); 155 } 156 }); 157 }); 158 }; 159 160 bookingMenu(); 161}
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.