PageSourceSearch

https://www.georisques.gouv.fr/themes/custom/georisques/assets/sources/js/content-nav.js?tlugul

js georisques.gouv.fr collected 2026-09-24 09:03:11 UTC 2,795 bytes, 73 lines download raw bytes

1/**
2 * @file
3 * Script for Content Navigation (Summary).
4 *
5 * Uses Drupal.behaviors.
6 *
7 * @see customer/README.md
8 * @see https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview
9 */
10
11'use strict';
12
13(function ($, Drupal, once) {
14  Drupal.behaviors.contentNav = {
15
16     attach: function (context) {
17        const $elements =  $(once('summary', 'body', context));
18        $elements.each(function () {
19          let $summary = $('.content-nav');
20          let $summaryAnchor;
21          if ($summary.length) {
22            let $summaryList = $('.content-nav-list');
23            //let $summaryTitle = $('.layout-inner-content h2');
24            let $summaryTitle = $('.content-wrapper > :not(.onglet-conteneur-wrapper)  h2:not(.fr-summary__title)');
25            let $summaryAnchor;
26            let i = 0;
27
28          setTimeout(function () { //add delay for data injected by other JS
29            $summaryTitle.each(function () {
30              if ($(this).text()) { //if not empty
31                let targetName = 'summary-target-' + i++;
32                let link = '<a href="#' + targetName + '" class="content-nav-link fr-summary__link">' + $(this).text() + '</a>';
33                $(this).attr('id', targetName);
34                $summaryList.append('<li>' + link + '</li>');
35              }
36            });
37          }, 500)
38
39          $summaryAnchor = $('.content-nav-link');
40          $summaryAnchor.on('click', function () {
41            $summaryAnchor.removeClass('active').removeAttr('aria-current');
42            $(this).addClass('active').attr('aria-current', 'true');
43          });
44        }
45
46        let $onglet_sommaire = $('.bloc-onglet-sommaire');
47        if ($onglet_sommaire.length) {
48          let indexOnglet = 0;
49          $onglet_sommaire.each(function () {
50            let $summary_onglet = $(this).find('.content-nav-onglet');
51            if ($summary_onglet.length) {
52
53              let $summaryList = $(this).find('.content-nav-list-onglet');
54              var $summaryTitle = $(this).find('.onglet-title-search   h2');
55
56              $summaryTitle.each(function () {
57                let targetName = 'summary-target-' + indexOnglet++;
58                let link = '<a href="#' + targetName + '" class="content-nav-link fr-summary__link">' + $(this).text() + '</a>';
59                $(this).attr('id', targetName);
60                $summaryList.append('<li>' + link + '</li>');
61              });
62            }
63          });
64          $summaryAnchor = $('.bloc-onglet-sommaire .content-nav-link');
65          $summaryAnchor.on('click', function () {
66            $summaryAnchor.removeClass('active').removeAttr('aria-current');
67            $(this).addClass('active').attr('aria-current', 'true');
68          });
69        }
70      });
71    },
72  };
73}(jQuery, Drupal, once));

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.