1(function ($) { 2 Drupal.behaviors.principal = { 3 attach: function (context) { 4 if (context !== document) { 5 return; 6 } 7 8 AOS.init({ 9 duration: 1000, 10 offset: 100, 11 once: true, 12 }); 13 function headerFixed() { 14 let height = $("#header").outerHeight(); 15 $("body").css("margin-top", height); 16 if ($("body").hasClass("user-logged-in")) { 17 $(".main__header .menu-item-level-0 .dropdown-menu").css( 18 "top", 19 height + 80 20 ); 21 } else { 22 $(".main__header .menu-item-level-0 .dropdown-menu").css( 23 "top", 24 height 25 ); 26 } 27 } 28 headerFixed(); 29 30 $("#nav-icon").on("click", function () { 31 $(this).toggleClass("is-active"); 32 $(".responsive__menu").toggleClass("is-active"); 33 $(".main__header .block-domain-menus").toggleClass("is-active"); 34 $(".main__header .menu-item-level-0 .dropdown-menu").css("top", "auto"); 35 }); 36 37 $("#nav-top").on("click", function () { 38 $(this).toggleClass("is-active"); 39 $(".top__header .block-menu").toggleClass("is-active"); 40 }); 41 42 const clickedMap = new WeakMap(); 43 44 $(".level__menu").on("click", function (e) { 45 const $btn = $(this); 46 const $menu = $btn.siblings(".dropdown-menu"); 47 const url = $btn.data("url"); 48 49 e.preventDefault(); 50 e.stopPropagation(); 51 52 if (clickedMap.get(this)) { 53 window.location.href = url; 54 return; 55 } 56 57 const $parentLevel = $btn.closest(".dropdown-menu, .menu"); 58 $parentLevel.find(".dropdown-menu").not($menu).hide(); 59 $parentLevel.find(".level__menu").not($btn).removeClass("active").each(function () { 60 clickedMap.set(this, false); 61 }); 62 63 $menu.toggle(); 64 $btn.toggleClass("active"); 65 clickedMap.set(this, true); 66 67 $(document).one("click", function () { 68 $menu.hide(); 69 $btn.removeClass("active"); 70 clickedMap.set($btn[0], false); 71 }); 72 }); 73 74 $(".dropdown-menu").on("click", function (e) { 75 e.stopPropagation(); 76 }); 77 78 $(".main__header .level-2").each(function () { 79 if ($(this).children().length > 5) { 80 $(this).mCustomScrollbar(); 81 $(this).css('max-height','160px'); 82 } 83 }); 84 $("#playPauseButton").on("click", function () { 85 var $btn = $("#playPauseButton", context); 86 var video = $("#accueilVideo", context).get(0); 87 var lang = drupalSettings.path.currentLanguage; 88 var iconDir = $btn.data("icon-dir"); // défini en Twig via data-icon-dir 89 90 if (video.paused) { 91 video.play(); 92 // on change l'icône du bouton en "pause" 93 $btn.attr({ 94 src: iconDir + "icon_pause.svg", 95 alt: lang === "fr" ? "Pause" : "Pause", 96 }); 97 } else { 98 video.pause(); 99 // on change l'icône du bouton en "play" selon la langue 100 var playIcon = lang === "fr" ? "icon_lire.svg" : "icon_play.svg"; 101 $btn.attr({ 102 src: iconDir + playIcon, 103 alt: lang === "fr" ? "Lire" : "Play", 104 }); 105 } 106 }); 107 108 109 $(window).on('load', function() { 110 // Sélectionne tous les marqueurs Leaflet et déclenche leur événement 'click' 111 $('.leaflet-marker-icon').each(function() { 112 $(this).trigger('click'); 113 }); 114 }); 115 116 function centerpartenaireSwiper() { 117 var $wrapper = $('.swiper-partenaire .swiper-wrapper'); 118 var $nextBtn = $('.swiper-button-next-unique-partner'); 119 var $prevBtn = $('.swiper-button-prev-unique-partner'); 120 121 // console.log($nextBtn.hasClass('swiper-button-lock'), $prevBtn.hasClass('swiper-button-lock')); 122 123 // Si les deux flèches sont verrouillées, on centre le contenu 124 if ($nextBtn.hasClass('swiper-button-lock') && $prevBtn.hasClass('swiper-button-lock')) { 125 $wrapper.addClass('justify-content-center'); 126 // console.log("center") 127 } else { 128 $wrapper.removeClass('justify-content-center'); 129 // console.log("not center") 130 } 131 } 132 centerpartenaireSwiper(); 133 134 $(window).resize(function () { 135 headerFixed(); 136 centerpartenaireSwiper(); 137 }); 138 139 const elements = once('initAccordion', '.views-element-container', context); 140
141 elements.forEach(function (container) { 142 const $firstItem = $(container).find('.accordion-item').first(); 143 144 if ($firstItem.length > 0) { 145 $firstItem.find('.accordion-collapse, .accordionContent') 146 .addClass('show'); 147 148 $firstItem.find('.accordion-button, .accordionTitle') 149 .removeClass('collapsed') 150 .attr('aria-expanded', 'true'); 151 } 152 }); 153 154 $('#edit-field-date-value-min').attr('type', 'date'); 155 $('#edit-field-date-value-max').attr('type', 'date'); 156 157 const $inputs = $('input[type="date"]'); 158 $inputs.each(function () { 159 const $input = $(this); 160 161 // Initial check 162 if ($input.val()) { 163 $input.addClass('active'); 164 } 165 166 $input.on('focus blur change', function () { 167 $input.toggleClass('active', !!$input.val() || $input.is(':focus')); 168 }); 169 }); 170 171 $(once("principal", "body")).each(function () { 172 $(this) 173 .on("click", function () {}) 174 .on("click mousedown", ".bloc__actus .item", function (e) { 175 if (e.which == 1 || e.which == 2) { 176 e.preventDefault(); 177 178 let href = $(this).find('a:not([rel="nofollow"])').attr("href"); 179 let target = $(this) 180 .find('a:not([rel="nofollow"])') 181 .attr("target") 182 ? $(this).find("a").attr("target") 183 : "_self"; 184 target = e.which == 2 ? "_blank" : target; 185 window.open(href, target); 186 return true; 187 } 188 }); 189 }); 190 }, 191 }; 192})(jQuery);
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.