PageSourceSearch

https://www.cnsa.fr/themes/custom/cnsa/assets/js/custom.js?tluugz

js cnsa.fr collected 2026-09-24 18:52:25 UTC 32,435 bytes, 809 lines download raw bytes

1window.addEventListener(
2  "load",
3  (function ($, Drupal, drupalSettings) {
4    // Remove all link title attribute RGAA audit.
5    $("a").removeAttr("title");
6    // Recommandation of P06-1.2 & P15-1.2 RGAA audit.
7    $('img:not([alt]), img[alt=""]').attr('alt', '');
8    // Recommandation of P01-10.1 / P14-10.1 / P13-10.1 RGAA audit.
9    $(".video iframe").removeAttr("height width");
10    // Recommandation of P02-10.1 RGAA audit.
11    $(".webform-submission-contact-form input.form-text").removeAttr("size");
12    $(".webform-submission-contact-form input.form-email").removeAttr("size");
13
14    // Add sr-only when target link is _blank.
15    setTimeout(function () {
16      $('a[target="_blank"]').append(
17        '<span class="sr-only">(Ouverture dans une nouvelle fenêtre)</span>',
18      );
19    }, 500);
20
21    //traitement pour les champs du formulaire voting
22    $("#status-question").removeClass("display-none");
23    $(".votingapi-reaction-radios").removeClass("display-none");
24    $("#welcome-text").addClass("display-none");
25
26    var tabLabels = [];
27    $("#addToCalendar").click(function () {
28      var eventname = drupalSettings.cnsa.event.eventname;
29      var eventloc = drupalSettings.cnsa.event.eventloc;
30      var startdate = new Date(drupalSettings.cnsa.event.startDate.date);
31      var enddate = new Date(drupalSettings.cnsa.event.endDate.date);
32      var eventuid = "";
33      startdate = moment
34        .utc(startdate, "MM/DD/YYYY hh:mm a Z")
35        .format("YYYYMMDD[T]HHmm[00Z]");
36      enddate = moment
37        .utc(enddate, "MM/DD/YYYY hh:mm a Z")
38        .format("YYYYMMDD[T]HHmm[00Z]");
39      for (var i = 16; i--; ) {
40        eventuid += Math.floor(Math.random() * (10 - 1 + 1) + 1);
41      }
42      var filenametrue = eventname.split(" ").join("_");
43      filenametrue = filenametrue.replace(/[_\W]+/g, "_") + ".ics";
44      var icsContent =
45        "BEGIN:VCALENDAR\r\nPRODID:-//Microsoft Corporation//Outlook 12.0 MIMEDIR//EN\r\nVERSION:2.0\r\nMETHOD:PUBLISH\r\nX-MS-OLK-FORCEINSPECTOROPEN:TRUE\r\nBEGIN:VEVENT\r\nCLASS:PUBLIC\r\nDESCRIPTION:\r\nDTEND:" +
46        enddate +
47        "\r\nDTSTART:" +
48        startdate +
49        "\r\nLOCATION:" +
50        eventloc +
51        "\r\nPRIORITY:5\r\nSEQUENCE:0\r\nSUMMARY;LANGUAGE=en-us:" +
52        eventname +
53        "\r\nTRANSP:OPAQUE\r\nUID:" +
54        eventuid +
55        "\r\nX-MICROSOFT-CDO-BUSYSTATUS:BUSY\r\nX-MICROSOFT-CDO-IMPORTANCE:1\r\nX-MICROSOFT-DISALLOW-COUNTER:FALSE\r\nX-MS-OLK-ALLOWEXTERNCHECK:TRUE\r\nX-MS-OLK-AUTOFILLLOCATION:FALSE\r\nX-MS-OLK-CONFTYPE:0\r\nBEGIN:VALARM\r\nTRIGGER:-PT1440M\r\nACTION:DISPLAY\r\nDESCRIPTION:Reminder\r\nEND:VALARM\r\nEND:VEVENT\r\nEND:VCALENDAR";
56
57      var hiddenDL = document.createElement("a");
58      hiddenDL.setAttribute(
59        "href",
60        "data:text/plain;charset=utf-8," + encodeURIComponent(icsContent),
61      );
62      hiddenDL.setAttribute("download", filenametrue);
63      hiddenDL.setAttribute("target", "_blank");
64      hiddenDL.style.display = "none";
65      document.body.appendChild(hiddenDL);
66      hiddenDL.click();
67      document.body.removeChild(hiddenDL);
68    });
69    const headerSearchDesktop = document.getElementById(
70      "header-search-desktop",
71    );
72    headerSearchDesktop?.addEventListener("dsa-submit", () => {
73      window.location.href =
74        window.location.origin +
75        "/moteur-recherche?keywords=" +
76        headerSearchDesktop.input.value;
77    });
78
79    const headerSearchMobile = document.getElementById("header-search-mobile");
80    headerSearchMobile?.addEventListener("dsa-submit", () => {
81      window.location.href =
82        window.location.origin +
83        "/moteur-recherche?keywords=" +
84        headerSearchMobile.input.value;
85    });
86
87    Drupal.behaviors.iframeVideoLang = {
88      attach: function (context, settings) {
89        // Select all iframe elements in the document
90        const iframes = document.querySelectorAll(".video iframe");
91
92        // Loop through each iframe and add the 'lang' attribute.
93        if (iframes.length > 0) {
94          iframes.forEach((iframe) => {
95            // Replace 'en' with your desired language code.
96            var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
97            iframeDoc.documentElement.setAttribute("lang", "fr");
98          });
99        }
100      },
101    };
102
103    Drupal.behaviors.actusFilter = {
104      attach: function (context, settings) {
105        let cpt = 0;
106        let cpt2 = 0;
107        // let cpt3 = 0;
108        let firstElement;
109        $('.empty-search dsa-button[type="button"]').on(
110          "click",
111          function (event) {
112            var url = window.location.href;
113            url = url.split("?")[0];
114            window.location.href = url;
115          },
116        );
117        if (document.getElementById("period")) {
118          managePeriodFilter();
119          once(
120            "actusFilterDefaultPeriod",
121            "#period dsa-radio",
122            context
123          ).forEach(function (element) {
124            // Pour le filter status //////////////////
125            if (drupalSettings.cnsa.search.article.ouvertop) {
126              var ouvertop = drupalSettings.cnsa.search.article.ouvertop;
127              if ($(element).val() === ouvertop) {
128                $(element).click();
129              }
130            }
131            if (drupalSettings.cnsa.search.article.encoursop) {
132              var encoursop = drupalSettings.cnsa.search.article.encoursop;
133              if ($(element).val() === encoursop) {
134                $(element).click();
135              }
136            }
137            if (drupalSettings.cnsa.search.article.fermeop) {
138              var fermeop = drupalSettings.cnsa.search.article.fermeop;
139              if ($(element).val() === fermeop) {
140                $(element).click();
141              }
142            }
143            ///////////////////////////////////
144            else if ($(element).attr("aria-checked") === "false") {
145              if (cpt == 0) {
146                $(element).click();
147              }
148              cpt = cpt + 1;
149            }
150          });
151        }
152        if (document.getElementById("period")) {
153          if (!drupalSettings.cnsa.search.article.periodop)
154            document.getElementsByName("period-op")[0].value = undefined;
155          else
156            document.getElementsByName("period-op")[0].value =
157              drupalSettings.cnsa.search.article.periodop;
158          managePeriodFilter();
159        }
160        if (
161          document.getElementById("organizer") &&
162          !drupalSettings.cnsa.search.article.params.organizers
163        ) {
164          document.getElementsByName("organizer[]")[0].value = undefined;
165        }
166        if (
167          document.getElementById("status") &&
168          !drupalSettings.cnsa.search.article.params.open &&
169          !drupalSettings.cnsa.search.article.params.close &&
170          !drupalSettings.cnsa.search.article.params.loading
171        ) {
172          document.getElementsByName("status")[0].value = undefined;
173        }
174        //set default sort options filter
175        // if first time, check first sort (+ récents aux moins récents).
176        //if not used the parameter to retrieve the previous sort context optio chosen
177        once(
178          "actusFilterDefaultSortBy",
179          "#newsSort dsa-radio",
180          context
181        ).forEach(function (element) {
182          if (drupalSettings.cnsa.search.article.params.sort_by) {
183            var sortBy = drupalSettings.cnsa.search.article.params.sort_by;
184            if (element.getAttribute("value") === sortBy) {
185              document.getElementsByName("sort_by")[0].value = sortBy;
186            }
187          } else {
188            if (cpt2 == 0) {
189              document.getElementsByName("sort_by")[0].value = "byyouth";
190            }
191            cpt2 = cpt2 + 1;
192          }
193        });
194
195        once(
196          "actusFilterDefaultSortBy",
197          "#newsSortForSearchAll dsa-radio",
198          context
199        ).forEach(function (element) {
200          if (drupalSettings.cnsa.search.article.params.sort_by) {
201            var sortBy = drupalSettings.cnsa.search.article.params.sort_by;
202            if (element.getAttribute("value") === sortBy) {
203              document.getElementsByName("sort_by")[0].value = sortBy;
204            }
205          } else {
206            if (cpt2 == 0) {
207              document.getElementsByName("sort_by")[0].value = "bypert";
208              cpt2 = cpt2 + 1;
209            }
210          }
211        });
212
213        //set default keywords values based on previous search (url parameter)
214        once(
215          "actusFilterDefaultKeywords",
216          ".filter dsa-input#keywords",
217          context
218        ).forEach(function (element) {
219          if (drupalSettings.cnsa.search.article.params.keywords) {
220            var keywords = drupalSettings.cnsa.search.article.params.keywords;
221            $(element).val(keywords);
222          }
223        });
224
225        //set default themes (thematiques) values based on previous search (url parameter)
226        once(
227          "actusFilterDefaultStatus",
228          ".statusFilter dsa-checkbox",
229          context
230        ).forEach(function (element) {
231          if (drupalSettings.cnsa.search.article.params.open) {
232            $("dsa-checkbox-group[name='open'] dsa-checkbox").click();
233          }
234          if (drupalSettings.cnsa.search.article.params.close) {
235            $("dsa-checkbox-group[name='close'] dsa-checkbox").click();
236          }
237          if (drupalSettings.cnsa.search.article.params.loading) {
238            $("dsa-checkbox-group[name='oploadingen'] dsa-checkbox").click();
239          }
240        });
241
242        //set active cibles values from current search filter(url parameter).
243        once("actusFilterCibles", ".cibleFilter dsa-checkbox", context).forEach(
244          function (element) {
245            if (drupalSettings.cnsa.search.article.params.cibles) {
246              var cibles = drupalSettings.cnsa.search.article.params.cibles;
247              if (cibles.split(",").includes($(element).val())) {
248                $(element).click();
249              }
250            }
251          },
252        );
253
254        //set active cibles values from current search filter(url parameter).
255        once(
256          "actusFilterDatepub",
257          ".datepubFilter dsa-checkbox",
258          context
259        ).forEach(function (element) {
260          if (drupalSettings.cnsa.search.article.params.annee) {
261            var annee = drupalSettings.cnsa.search.article.params.annee;
262            if (annee.split(",").includes($(element).val())) {
263              $(element).click();
264            }
265          }
266        });
267
268        //set active cibles values from current search filter(url parameter).
269        once(
270          "actusFilterDisciplines",
271          ".disciplineFilter dsa-checkbox",
272          context
273        ).forEach(function (element) {
274          if (drupalSettings.cnsa.search.article.params.disciplines) {
275            var disciplines =
276              drupalSettings.cnsa.search.article.params.disciplines;
277            if (disciplines.split(",").includes($(element).val())) {
278              $(element).click();
279            }
280          }
281        });
282
283        //set default organizer (organisateur) values based on previous search (url parameter)
284        once(
285          "actusFilterDefaultOrganizers",
286          "#organizer dsa-radio",
287          context
288        ).forEach(function (element) {
289          if (drupalSettings.cnsa.search.article.params.organizers) {
290            var organizers =
291              drupalSettings.cnsa.search.article.params.organizers;
292            if (organizers.split(",").includes(element.getAttribute("value"))) {
293              document.getElementsByName("organizer[]")[0].value =
294                element.getAttribute("value");
295            }
296          }
297        });
298
299        //set default population (population) values based on previous search (url parameter)
300        once(
301          "actusFilterDefaultpopulations",
302          "#population dsa-checkbox",
303          context
304        ).forEach(function (element) {
305          if (drupalSettings.cnsa.search.article.params.populations) {
306            var populations =
307              drupalSettings.cnsa.search.article.params.populations;
308            if (populations.split(",").includes($(element).val())) {
309              $(element).click();
310            }
311          }
312        });
313
314        //after clear (reset) values from filter form, set the default sort option
315        $('.filter dsa-button[type="button"]').on("click", function (event) {
316          //clean eventual existing thematiques selected
317          $(".filter ul.chips-list").remove();
318
319          //clean filter radio sort tri
320          if (document.getElementById("newsSortForSearchAll")) {
321            document.getElementsByName("sort_by")[0].value = "bypert";
322          } else if (document.getElementsByName("sort_by")[0])
323            document.getElementsByName("sort_by")[0].value = "byyouth";
324
325          if (document.getElementById("organizer"))
326            document.getElementsByName("organizer[]")[0].value = undefined;
327
328          //reset default themes (thematiques)
329          $(".filter dsa-checkbox").each(function () {
330            if (
331              $(this).attr("checked") === "checked" ||
332              $(this).attr("aria-checked") === "checked"
333            ) {
334              $(this).removeAttr("checked");
335            }
336          });
337          //delete value on dsa-tab-group Theme
338          if (document.getElementsByName("theme[]")[0]) {
339            document.getElementsByName("theme[]")[0].removeAttribute("value");
340            document.getElementsByName("theme[]")[0].value = [];
341            document
342              .getElementsByName("theme[]")[0]
343              .removeAttribute("data-user-valid");
344          }
345
346          //delete value on dsa-tab-group collection
347          if (document.getElementsByName("collection[]")[0]) {
348            document
349              .getElementsByName("collection[]")[0]
350              .removeAttribute("value");
351            document.getElementsByName("collection[]")[0].value = [];
352            document
353              .getElementsByName("collection[]")[0]
354              .removeAttribute("data-user-valid");
355          }
356
357          //delete value on dsa-tab-group population
358          if (document.getElementsByName("partenaire[]")[0]) {
359            document
360              .getElementsByName("partenaire[]")[0]
361              .removeAttribute("value");
362            document.getElementsByName("partenaire[]")[0].value = [];
363            document
364              .getElementsByName("partenaire[]")[0]
365              .removeAttribute("data-user-valid");
366          }
367
368          //delete value on dsa-tab-group population
369          if (document.getElementsByName("type[]")[0]) {
370            document.getElementsByName("type[]")[0].removeAttribute("value");
371            document.getElementsByName("type[]")[0].value = [];
372            document
373              .getElementsByName("type[]")[0]
374              .removeAttribute("data-user-valid");
375          }
376
377          //delete value on dsa-tab-group population
378          if (document.getElementsByName("population[]")[0]) {
379            document
380              .getElementsByName("population[]")[0]
381              .removeAttribute("value");
382            document.getElementsByName("population[]")[0].value = [];
383            document
384              .getElementsByName("population[]")[0]
385              .removeAttribute("data-user-valid");
386          }
387          //reset default filter (status)
388          $(".statusFilter dsa-radio-group").val("");
389
390          //reset default keywords values
391          $(".filter dsa-input#keywords").each(function () {
392            $(this).val("");
393          });
394
395          //reset period wrapper on filter
396          $(".filter dsa-input#periodValue").each(function () {
397            $(this).val("");
398          });
399          if (document.getElementById("period")) {
400            document.getElementsByName("period-op")[0].value = undefined;
401            managePeriodFilter();
402          }
403        });
404
405        // code pour suppression de tag filter theme et keywords pour article
406        $(".close-tag").on("click", function () {
407          const queryString = window.location.search;
408          var url = window.location.href;
409          var decodedUrl = decodeURIComponent(url);
410          var decodedQueryString = decodeURIComponent(queryString);
411          decodedUrl = decodedUrl.replaceAll("+", "");
412          decodedQueryString = decodedQueryString.replaceAll("+", " ");
413          var tag = $(this).attr("id");
414          if ($(this).attr("id").includes("keywords")) {
415            tag = tag.replace("keywords_", "");
416            if (decodedQueryString.includes("," + tag)) {
417              var keywordToBeRemoved = "," + tag;
418            } else if (decodedQueryString.includes(tag + ",")) {
419              var keywordToBeRemoved = tag + ",";
420            } else {
421              keywordToBeRemoved = tag;
422            }
423            decodedQueryString = decodedQueryString.replace(
424              keywordToBeRemoved,
425              "",
426            );
427            window.location.search = encodeURI(
428              decodedQueryString.replace(",", ",+"),
429            );
430          } else if ($(this).attr("id").includes("organizer")) {
431            var wordToBeRemoved =
432              "&organizer-op=" + drupalSettings.cnsa.search.article.organizerOp;
433            decodedQueryString = decodedQueryString.replace(
434              wordToBeRemoved,
435              "",
436            );
437            wordToBeRemoved =
438              "organizer[]=" + drupalSettings.cnsa.search.article.organizer;
439            decodedQueryString = decodedQueryString.replace(
440              wordToBeRemoved,
441              "",
442            );
443            window.location.search = encodeURI(
444              decodedQueryString.replace(",", ",+"),
445            );
446          } else if ($(this).attr("id").includes("period")) {
447            var tagToBeRemoved =
448              "&period[value]=" +
449              periodValue.value +
450              "&period[min]=" +
451              periodMin.value +
452              "&period[max]=" +
453              periodMax.value;
454            decodedUrl = decodedUrl.replace(tagToBeRemoved, "");
455            let tag2ToBeRemoved =
456              "&period-op=" + drupalSettings.cnsa.search.article.periodop;
457            let encode2dElmt = decodedUrl.replace(tag2ToBeRemoved, "");
458            window.location.href = encodeURI(encode2dElmt);
459          } else if ($(this).attr("id").includes("ouvert")) {
460            var tagToBeRemoved =
461              "&ouvert[value]=" +
462              periodValue.value +
463              "&ouvert[min]=" +
464              periodMin.value +
465              "&ouvert[max]=" +
466              periodMax.value;
467            decodedUrl = decodedUrl.replace(tagToBeRemoved, "");
468            let tag2ToBeRemoved =
469              "&ouvert-op=" + drupalSettings.cnsa.search.article.ouvertop;
470            let encode2dElmt = decodedUrl.replace(tag2ToBeRemoved, "");
471            window.location.href = encodeURI(encode2dElmt);
472          } else if ($(this).attr("id").includes("ferme")) {
473            var tagToBeRemoved =
474              "&ferme[value]=" +
475              periodValue.value +
476              "&ferme[min]=" +
477              periodMin.value +
478              "&ferme[max]=" +
479              periodMax.value;
480            decodedUrl = decodedUrl.replace(tagToBeRemoved, "");
481            let tag2ToBeRemoved =
482              "&ferme-op=" + drupalSettings.cnsa.search.article.fermeop;
483            let encode2dElmt = decodedUrl.replace(tag2ToBeRemoved, "");
484            window.location.href = encodeURI(encode2dElmt);
485          } else if ($(this).attr("id").includes("encours")) {
486            var tagToBeRemoved =
487              "&encours[value]=" +
488              periodValue.value +
489              "&encours[min]=" +
490              periodMin.value +
491              "&encours[max]=" +
492              periodMax.value;
493            decodedUrl = decodedUrl.replace(tagToBeRemoved, "");
494            let tag2ToBeRemoved =
495              "&encours-op=" + drupalSettings.cnsa.search.article.encoursop;
496            let encode2dElmt = decodedUrl.replace(tag2ToBeRemoved, "");
497
498            window.location.href = encodeURI(encode2dElmt);
499          } else if ($(this).attr("id").includes("loading")) {
500            var tagToBeRemoved = "&loading=today";
501            decodedUrl = decodedUrl.replace(tagToBeRemoved, "");
502            let tag2ToBeRemoved = "loading-end=today";
503            let encode2dElmt = decodedUrl.replace(tag2ToBeRemoved, "");
504            window.location.href = encodeURI(encode2dElmt);
505          } else if ($(this).attr("id").includes("close")) {
506            var tagToBeRemoved = "&close=today";
507            decodedUrl = decodedUrl.replace(tagToBeRemoved, "");
508            window.location.href = encodeURI(decodedUrl);
509          } else if ($(this).attr("id").includes("open")) {
510            var tagToBeRemoved = "&open=today";
511            decodedUrl = decodedUrl.replace(tagToBeRemoved, "");
512            window.location.href = encodeURI(decodedUrl);
513          } else if ($(this).attr("id").includes("ouvert")) {
514            var decodedUrl = decodeURIComponent(window.location.href);
515            var encodedElmt = decodedUrl.replace("&ouvert-op=", "");
516            window.location.href = encodeURI(encodedElmt);
517          } else if ($(this).attr("id").includes("ferme")) {
518            var decodedUrl = decodeURIComponent(window.location.href);
519            var encodedElmt = decodedUrl.replace("&ferme-op=", "");
520            window.location.href = encodeURI(encodedElmt);
521          } else if ($(this).attr("id").includes("encours")) {
522            var decodedUrl = decodeURIComponent(window.location.href);
523            var encodedElmt = decodedUrl.replace("&encours-op=", "");
524            window.location.href = encodeURI(encodedElmt);
525          } else {
526            var tagToBeRemoved = $(this).attr("id");
527            if (tag.includes("type") && !decodedUrl.includes(tagToBeRemoved)) {
528              tagToBeRemoved = tagToBeRemoved.replace("type[]", "type[0]");
529            }
530            var encodedElmt = decodedUrl.replace(tagToBeRemoved, "");
531            window.location.href = encodeURI(encodedElmt);
532          }
533        });
534        // code pour gestion des filtres dates
535        var decodedUrl = decodeURIComponent(window.location.href);
536
537        if (drupalSettings.cnsa.search.article.params.themes.length == 0) {
538          decodedUrl = decodedUrl.replace("theme[]=", "");
539        }
540        if (decodedUrl != decodeURIComponent(window.location.href)) {
541          window.location.href = encodeURI(decodedUrl);
542        }
543
544        function managePeriodFilter() {
545          var period = document.getElementById("period").value;
546          var periodValue = document.getElementById("periodValue");
547          var periodMin = document.getElementById("periodMin");
548          var periodMax = document.getElementById("periodMax");
549          switch (period) {
550            case "between":
551              periodMin.setAttribute("required", "");
552              periodMax.setAttribute("required", "");
553              periodValue.removeAttribute("required");
554              periodValue.style.display = "none";
555              periodMin.style.display = "";
556              periodMax.style.display = "";
557              break;
558            case "<":
559              periodMax.removeAttribute("required");
560              periodMin.removeAttribute("required");
561              periodValue.setAttribute("required", "");
562              periodValue.style.display = "";
563              periodMin.style.display = "none";
564              periodMax.style.display = "none";
565              break;
566            case ">":
567              periodMax.removeAttribute("required");
568              periodMin.removeAttribute("required");
569              periodValue.setAttribute("required", "");
570              periodValue.style.display = "";
571              periodMin.style.display = "none";
572              periodMax.style.display = "none";
573              break;
574            default:
575              periodMax.removeAttribute("required");
576              periodMin.removeAttribute("required");
577              periodValue.removeAttribute("required");
578              periodValue.style.display = "none";
579              periodMin.style.display = "none";
580              periodMax.style.display = "none";
581              break;
582          }
583        }
584        $("#period").on("click", managePeriodFilter);
585
586        //for an article remove figure's ::before pseudo element if no media (no image)
587        if ($(".p-summary figure").length == 0) {
588          $(".p-summary").addClass("without-before-element");
589        }
590
591        //for a list of articles (actualites) remove first blank empty colomn if no media (no image
592        once(
593          "actusFilterEmptyPhotosListActualites",
594          "article.card .u-photo",
595          context
596        ).forEach(function (element) {
597          if ($(element).children("img").length == 0) {
598            $(element).addClass("without-image-element");
599            $(element).parent().addClass("without-image-element");
600          }
601        });
602
603        $(".publication-card-container article.card").each(function () {
604          if (!$(this).hasClass("without-image-element")) {
605            titlePub = $(this).find(".p-name a.whole").text().trim();
606            $(this).find(".u-photo img").prop("alt", titlePub);
607          }
608        });
609
610        //For social sharing button
611        $("#socialSharing").click(function () {
612          $(this).attr("aria-expanded", true);
613          $("#sharingAddToAnyCnsa").removeClass("customAddToAnyCnsa");
614        });
615        $(document).on("click", function (e) {
616          if ($(e.target).is("#socialSharing") === false) {
617            $("#socialSharing").attr("aria-expanded", false);
618            $("#sharingAddToAnyCnsa").addClass("customAddToAnyCnsa");
619          }
620        });
621      },
622    };
623
624    Drupal.behaviors.votingapiReactionButtons = {
625      attach: function (context) {
626        const buttons = context.querySelectorAll(
627          "#votingapi-reaction-form-vote button",
628        );
629        const hiddenInput = context.querySelector("#votingapi-reaction-value");
630
631        buttons.forEach((btn) => {
632          btn.addEventListener("click", () => {
633            // Réinitialiser tous les boutons
634            buttons.forEach((b) => {
635              b.setAttribute("aria-pressed", "false");
636              b.classList.remove("is-active");
637            });
638
639            // Activer celui cliqué
640            btn.setAttribute("aria-pressed", "true");
641            btn.classList.add("is-active");
642            // Mettre à jour la valeur cachée
643            hiddenInput.value = btn.getAttribute("data-value");
644          });
645        });
646      },
647    };
648
649    Drupal.behaviors.votingReaction = {
650      attach: function () {
651        $(".votingapi-reaction-form .votingapi-reaction-radios").click(
652          function () {
653            $("#vote-comment").val("");
654            $("#div-comment").removeClass("display-none");
655            $("#help-text").removeClass("display-none");
656            $("#send-btn-reaction").removeClass("display-none");
657            $("#send-btn").removeClass("display-none");
658            $("#send-btn").removeAttr("disabled");
659            $("#send-btn").focus();
660          },
661        );
662      },
663    };
664
665    // Adapt name cnsa-radio-group based on the selected status.
666    Drupal.behaviors.StatusFilter = {
667      attach: function () {
668        $(".statusFilter dsa-radio").click(function () {
669          $(".statusFilter dsa-radio").not(this).prop("checked", false);
670          if ($(this).val() == "open") {
671            $(this).parent("dsa-radio-group").attr("name", "open");
672
673            // adapt date filter
674            $("dsa-radio-group#period").attr("name", "ouvert-op");
675            $("dsa-input#periodValue").attr("name", "ouvert[value]");
676            $("dsa-input#periodMin").attr("name", "ouvert[min]");
677            $("dsa-input#periodMax").attr("name", "ouvert[max]");
678
679            // remove field
680            $("#hideField").remove();
681          } else if ($(this).val() == "loading") {
682            $(this).parent("dsa-radio-group").attr("name", "loading");
683
684            // adapt date filter
685            $("dsa-radio-group#period").attr("name", "encours-op");
686            $("dsa-input#periodValue").attr("name", "encours[value]");
687            $("dsa-input#periodMin").attr("name", "encours[min]");
688            $("dsa-input#periodMax").attr("name", "encours[max]");
689
690            // add field
691            $("form#status-projet").append(
692              "<input id='hideField' type='hidden' name='loading-end' value='today'/>",
693            );
694          } else if ($(this).val() == "close") {
695            $(this).parent("dsa-radio-group").attr("name", "close");
696
697            // adapt date filter
698            $("dsa-radio-group#period").attr("name", "ferme-op");
699            $("dsa-input#periodValue").attr("name", "ferme[value]");
700            $("dsa-input#periodMin").attr("name", "ferme[min]");
701            $("dsa-input#periodMax").attr("name", "ferme[max]");
702
703            $("#hideField").remove();
704          }
705          $(this).val("today");
706        });
707
708        $(".filter .horizontal-group").click(function () {
709          $("#status-projet .statusFilter cnsa-radio").each(function () {
710            if ($(this).attr("aria-checked") == "true") {
711              $(this).click();
712            }
713          });
714        });
715      },
716    };
717
718    // Automtically close exposed search details box on mouseup.
719    Drupal.behaviors.closeDetails = {
720      attach: function () {
721        let details = document.querySelector("details.tools");
722        if (details) {
723          document.addEventListener("click", function (e) {
724            if (!details.contains(e.target)) {
725              details.removeAttribute("open");
726            }
727          });
728        }
729      },
730    };
731
732    // Replace default label of the marker (delta value) with tre related label.
733    Drupal.behaviors.tooltipcarto = {
734      attach: function (context, settings) {
735        var id = 1;
736
737        var indexElt = -1;
738
739        //hide tooltip by defaut
740        $(".leaflet-tooltip").hide();
741
742        $(
743          once("leaflet-marker-pane", ".leaflet-marker-pane img", context),
744        ).each(function () {
745          $(this).on("click", function () {
746            // javascript/jQuery code here.
747            indexElt = $(".leaflet-marker-pane img").index($(this)) + 1;
748            let labelPoint = $(".multipt_label" + indexElt).text();
749            setTimeout(function () {
750              if (labelPoint.trim()) {
751                $(".leaflet-popup-content").html(
752                  "<p>" + labelPoint.trim() + "</p>",
753                );
754              }
755            }, 10);
756          });
757        });
758      },
759    };
760
761    // DSA textual alternatives.
762    Drupal.behaviors.textualAlternatives = {
763      attach: function () {
764        const transcriptVideoBtns = document.querySelectorAll(
765          ".content.content-media-video dsa-button",
766        );
767        const transcriptImageBtns = document.querySelectorAll(
768          "figure dsa-button, .photo-cover dsa-button"
769        );
770        if (transcriptVideoBtns.length > 0) {
771          transcriptVideoBtns.forEach((transcriptBtn, index) => {
772            transcriptBtn.addEventListener("click", function () {
773              var dialog = this.nextElementSibling;
774              if (dialog) {
775                dialog.open = true;
776              }
777            });
778          });
779        }
780        if (transcriptImageBtns.length > 0) {
781          transcriptImageBtns.forEach((transcriptBtn, index) => {
782            transcriptBtn.addEventListener("click", function () {
783              var dialog = this.nextElementSibling;
784              if (dialog) {
785                dialog.open = true;
786              }
787            });
788          });
789        }
790      },
791    };
792
793    // // TAC BigAlert Manager.
794    Drupal.behaviors.tacjsBigAlert = {
795      attach: function () {
796        setTimeout(() => {
797          let alertElement = document.querySelector("#tarteaucitronAlertBig");
798          if (alertElement) {
799            let alertElementOpacity = alertElement.style.opacity;
800            let alertElementDisplay = alertElement.style.display;
801            if (alertElementOpacity == 0 && alertElementDisplay == "none") {
802              alertElement.style.setProperty("display", "none", "important");
803            }
804          }
805        }, 3500);
806      },
807    };
808  })(jQuery, Drupal, drupalSettings),
809);

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.