1var initMenuBurgerImage = (container) => { 2 const menu = document.querySelector('.main-menu') 3 const menuButton = document.querySelector('.btn-menu') 4 const heightNavigation = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--height-navigation'), 10) 5 6 // Gestion du sticky 7 const setStickyNav = () => { 8 container.classList.toggle('is-sticky', window.scrollY > 0) 9 } 10 11 // Fermeture du menu burger 12 const toggleMenu = () => { 13 container.classList.toggle('open') 14 document.body.classList.toggle('overflow-hidden') 15 } 16 17 // Initialisation sticky 18 if(document.querySelector('.hero')) { 19 setStickyNav() 20 window.addEventListener('scroll', setStickyNav, { capture: true, passive: true }) 21 } 22 else { 23 container.classList.add('is-sticky') 24 } 25 26 // Gestion du scroll onepage 27 if (document.body.classList.contains('onepage')) { 28 const sections = document.querySelectorAll('section[id]') 29 const links = menu.querySelectorAll('a') 30 31 links.forEach(link => { 32 link.addEventListener('click', e => { 33 e.preventDefault() 34 const targetId = link.dataset.menu?.replace('#', '') 35 const target = document.getElementById(targetId) 36 37 if (target) { 38 toggleMenu() 39 const top = target.offsetTop - heightNavigation 40 window.scrollTo({ top, behavior: 'smooth' }) 41 } 42 }) 43 }) 44 45 const changeMenuState = () => { 46 const scrollPosition = window.scrollY + heightNavigation + 100 47 let activeIndex = -1 48 49 sections.forEach((section, index) => { 50 if (scrollPosition >= section.offsetTop) { 51 activeIndex = index 52 } 53 }) 54 55 links.forEach(link => link.classList.remove('text-primary')) 56 if (activeIndex >= 0 && links[activeIndex]) { 57 links[activeIndex].classList.add('text-primary') 58 } 59 } 60 61 changeMenuState() 62 window.addEventListener('scroll', changeMenuState) 63 } 64 65 // Click global pour fermer si clic en dehors 66 document.addEventListener('click', e => { 67 if ((e.target.matches('.btn-menu') || !e.target.closest('.lazy-menu-burger')) && e.target.classList.contains('open')) { 68 toggleMenu() 69 } 70 }, false) 71 72 // Click sur le bouton burger 73 menuButton.addEventListener('click', e => { 74 e.stopImmediatePropagation() 75 toggleMenu() 76 77 menu.querySelectorAll('.menu-images img').forEach(img => { 78 img.src = img.getAttribute('menu-src') 79 img.srcset = img.getAttribute('menu-srcset') 80 81 img.removeAttribute('menu-src') 82 img.removeAttribute('menu-srcset') 83 }) 84 }, { passive: true, capture: true }) 85 86 // Active page 87 document.querySelectorAll('.menu-item').forEach(btn => { 88 const btnUrl = new URL(btn.href, window.location.origin) 89 const currentUrl = new URL(window.location.href) 90 91 // Compare uniquement le chemin sans le hash 92 if (btnUrl.pathname === currentUrl.pathname) { 93 btn.classList.add('active') 94 } 95 }) 96 97 // Hover images 98 const links = menu.querySelectorAll('.menu-links li') 99 const parentImages = menu.querySelectorAll('.menu-images li') 100 const currentUrl = new URL(window.location.href) 101 102 parentImages.forEach(link => { 103 const linkUrl = new URL(link.dataset.href, window.location.origin) 104 105 // Active link 106 if (linkUrl.pathname === currentUrl.pathname) { 107 link.classList.add('active') 108 } 109 }) 110 111 // Hover logic 112 links.forEach(link => { 113 link.addEventListener('mouseover', () => { 114 const target = link.dataset.target 115 const parentLi = [...parentImages].find(li => li.dataset.target === target) 116 if(parentLi) { 117 parentLi.classList.add('active') 118 parentImages.forEach(li => li !== parentLi && li.classList.remove('active')) 119 } 120 else { 121 parentImages[0].classList.add('active') 122 parentImages.forEach(li => li !== parentImages[0] && li.classList.remove('active')) 123 } 124 }) 125 }) 126 127 if (window.location.pathname === '/bookingstep2') { 128 document.body.classList.add('booking-step') 129 } 130}
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.