1/** 2 * File navigation.js. 3 * 4 * Handles toggling the navigation menu for small screens and enables TAB key 5 * navigation support for dropdown menus. 6 */ 7 8$(".header__nav ul ul li").each(function() { 9 if ($(this).find('ul').length > 0) { 10 $(this).append('<span class="iconify" data-icon="ph:plus"></span>'); 11 } 12 }); 13 14// Ajout du bouton d'ouverture de sous-menu sur les items principaux (niveau 1) 15function addSubMenuToggleButtons() { 16 console.log('addSubMenuToggleButtons called'); 17 $('.header__nav > ul > li').each(function(i) { 18 // Nettoyage : retire le bouton si le sous-menu n'existe plus 19 if ($(this).find('ul').length === 0) { 20 $(this).find('.show__sub-menu').remove(); 21 } else if ($(this).find('.show__sub-menu').length === 0) { 22 // Ajoute le bouton si le sous-menu existe et le bouton n'est pas déjà là 23 console.log('Ajout bouton sous-menu sur li index', i, $(this).text()); 24 $(this).append('<button class="show__sub-menu" aria-label="Ouvrir le sous-menu" tabindex="0"><span class="iconify" data-icon="ph:caret-down-bold"></span></button>'); 25 } 26 }); 27} 28 29// Gère l'ouverture/fermeture du sous-menu sur mobile/tablette 30$(document).on('click', '.show__sub-menu', function(e) { 31 e.preventDefault(); 32 var $li = $(this).closest('li'); 33 var $submenu = $li.children('ul'); 34 console.log('Bouton sous-menu cliqué', $li.text(), 'Sous-menu trouvé:', $submenu.length); 35 if ($submenu.length) { 36 $submenu.slideToggle('fast'); 37 $(this).toggleClass('active'); 38 // Accessibilité : met à jour aria-expanded 39 $(this).attr('aria-expanded', $(this).hasClass('active')); 40 } 41}); 42 43// Initialisation au chargement et au resize 44$(document).ready(function() { 45 console.log('Document ready, ajout des boutons sous-menu'); 46 addSubMenuToggleButtons(); 47 $(window).on('resize', function() { 48 console.log('Resize, ajout des boutons sous-menu'); 49 addSubMenuToggleButtons(); 50 }); 51}); 52 53// Preloader 54$(window).on('load', function () { 55 $('.lds-ellipsis').fadeOut(); // will first fade out the loading animation 56 $('.preloader').delay(333).fadeOut('slow'); // will fade out the white DIV that covers the website. 57 $('body').delay(333); 58}); 59 60 61$(".accordion__toggle").click(function() { 62 $(this).toggleClass("active"); 63 $(this).next(".accordion__content").slideToggle(); 64}); 65 66// Script déplacé depuis header.php pour gérer le menu mobile/tablette 67$(document).ready(function() { 68 // Flash info (conserve la logique si besoin) 69 if (sessionStorage.getItem('flash-info') == 'true') { 70 $('#flashsInfos').hide(); 71 } 72 $('#hideFlashInfo').click(function() { 73 $('#flashsInfos').hide(); 74 sessionStorage.setItem('flash-info', 'true'); 75 }); 76 77 // Ajout dynamique du bouton d'ouverture de sous-menu sur les <li> principaux du menu mobile/tablette 78 function addSubMenuToggleButtons() { 79 $('.header__nav > ul > li').each(function() { 80 if ($(this).find('ul').length === 0) { 81 $(this).find('.show__sub-menu').remove(); 82 } else if ($(this).find('.show__sub-menu').length === 0) { 83 $(this).append('<button class="show__sub-menu" aria-label="Ouvrir le sous-menu" tabindex="0"><span class="iconify" data-icon="ph:caret-down-bold"></span></button>'); 84 } 85 }); 86 } 87 88 // Initialisation au chargement et au resize 89 addSubMenuToggleButtons(); 90 $(window).on('resize', function() { 91 addSubMenuToggleButtons(); 92 if($(window).width() >= 1460){ 93 $('.header__nav > ul > li').find('.show__sub-menu').remove(); 94 $('.header__nav').css("right", "0"); 95 } 96 }); 97 98 // Gestion du clic sur le bouton d'ouverture de sous-menu 99 $(document).on('click', '.show__sub-menu', function(e) { 100 e.preventDefault(); 101 var $li = $(this).closest('li'); 102 var $submenu = $li.children('ul'); 103 if ($submenu.length) { 104 $submenu.slideToggle('fast'); 105 $(this).toggleClass('active'); 106 $(this).attr('aria-expanded', $(this).hasClass('active')); 107 } 108 }); 109 110 // Fonction pour afficher le menu 111 function afficherMenu() { 112 $('.header__nav').animate({"right": '0px'}); 113 $('.wrapper__header').addClass("active"); 114 } 115 // Fonction pour cacher le menu 116 function cacherMenu() { 117 $('.header__nav').animate({"right": '-100%'}); 118 setTimeout(function() { 119 $('.wrapper__header').removeClass("active"); 120 }, 500); 121 } 122 // Gérer le clic sur le bouton pour afficher ou masquer le menu 123 $('#showMenu').click(function() { 124 afficherMenu(); 125 }); 126 $('#hideMenu').click(function() { 127 cacherMenu(); 128 }); 129 130 // Recherche animée 131 var $search = $('.component__search'); 132 var $label = $search.find('.search-label'); 133 var $form = $search.find('.search-form'); 134 var $input = $form.find('.search-input'); 135 var $icon = $search.find('.search-icon'); 136 $search.on('click', function(e) { 137 if (!$search.hasClass('active')) { 138 $search.addClass('active'); 139 $label.hide(); 140 $form.show(); 141 setTimeout(function(){ $input.focus(); }, 100); 142 e.stopPropagation(); 143 } 144 }); 145 $input.on('click', function(e){ e.stopPropagation(); }); 146 $icon.on('click', function(e) { 147 e.stopPropagation(); 148 if ($search.hasClass('active')) { 149 if ($input.val().trim() !== '') { 150 $form.submit(); 151 } else { 152 $input.focus(); 153 } 154 } else { 155 $search.addClass('active'); 156 $label.hide(); 157 $form.show(); 158 setTimeout(function(){ $input.focus(); }, 100); 159 } 160 }); 161 $(document).on('click', function() { 162 if ($search.hasClass('active')) { 163 $search.removeClass('active'); 164 $form.hide(); 165 $label.show(); 166 } 167 }); 168 $input.on('keydown', function(e) { 169 if (e.key === 'Escape') { 170 $search.removeClass('active'); 171 $form.hide(); 172 $label.show(); 173 } 174 }); 175 $form.on('submit', function(e){ 176 if($input.val().trim() === ''){ 177 e.preventDefault(); 178 $input.focus(); 179 } 180 }); 181}); 182 183// Fonction pour afficher la modale 184function afficherModale() { 185 if ($('.connect').length) { 186 $('.connect').css("visibility", "visible"); 187 $('.connect').animate({"right": '0px'}); 188 } 189 if ($('.account').length) { 190 $('.connect').css("visibility", "visible"); 191 $('.account').animate({"right": '0px'}); 192 } 193 $('.wrapper__header').addClass("active"); 194} 195 196// Fonction pour cacher le menu 197function cacherModale() { 198 if ($('.connect').length) { 199 $('.connect').animate({"right": '-100%'}); 200 setTimeout(function() { 201 $('.connect').css("visibility", "hidden"); 202 }, 500); 203 } 204 if ($('.account').length) { 205 $('.account').animate({"right": '-100%'}); 206 setTimeout(function() { 207 $('.account').css("visibility", "hidden"); 208 }, 500); 209 } 210 setTimeout(function() { 211 $('.wrapper__header').removeClass("active"); 212 }, 500); 213} 214 215// Gérer le clic sur le bouton pour afficher ou masquer la modale
216$('#toggleModale').click(function() { 217 afficherModale(); 218}); 219 220$('#closeModale').click(function() { 221 cacherModale(); 222}); 223 224// Filtre Actes municipaux - Animation d'ouverture/fermeture 225document.addEventListener('DOMContentLoaded', () => { 226 document.addEventListener('click', (e) => { 227 const btn = e.target.closest('.acte-filters-toggle'); 228 if (!btn) return; 229 230 const aside = btn.closest('.acte-filters'); 231 if (!aside) return; 232 233 const form = aside.querySelector('.acte-filters-form'); // pas d'optional chaining pour compat 234 if (!form) return; 235 236 const label = btn.querySelector('.btn-label') || btn.querySelector('#btn-label') || btn.querySelector('span'); 237 238 const open = !form.classList.contains('is-visible'); 239 form.classList.toggle('is-visible', open); 240 btn.setAttribute('aria-expanded', open ? 'true' : 'false'); 241 242 if (label) { 243 label.textContent = open ? 'Masquer le filtre' : 'Afficher le filtre'; 244 } 245 }); 246});
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.