PageSourceSearch

https://www.totalenergies.es/themes/custom/total_redesign/dist/assets/js/header.js?tlv34f

js totalenergies.es collected 2026-09-26 00:15:19 UTC 5,028 bytes, 162 lines download raw bytes

1(function ($, Drupal) {
2  Drupal.behaviors.header = {
3    attach: function (context, settings) {
4      function isMobileNavigation() {
5        return window.matchMedia("(max-width: 950px)").matches;
6      }
7
8      function normalizeMegaMenuItems(context) {
9        $("li.navigation__item", context).has(".mega-menu").each(function () {
10          const $item = $(this);
11          const $megaMenu = $item.children(".mega-menu").first();
12          const expandGroup = $item.attr("data-expand") || $megaMenu.attr("data-expand");
13
14          $item.addClass("has-mega-menu expand-colapse__trigger");
15
16          if (expandGroup) {
17            $item.attr("data-expand", expandGroup);
18            $megaMenu.attr("data-expand", expandGroup);
19          }
20        });
21      }
22
23      function openMegaMenu(item) {
24        $("html").addClass("open-body-overlap");
25        $(".navigation__item.has-mega-menu.expanded").not(item).removeClass("expanded");
26        $(item).addClass("expanded");
27      }
28
29      function closeMegaMenu() {
30        $("html").removeClass("open-body-overlap");
31        $(".navigation__item.has-mega-menu.expanded").removeClass("expanded");
32      }
33
34      normalizeMegaMenuItems(context);
35
36      $(document)
37        .off("click.headerMegaMenu", ".navigation__item")
38        .on("click.headerMegaMenu", ".navigation__item", function (evt) {
39          const $item = $(this);
40
41          if (!$item.children(".mega-menu").length) {
42            return;
43          }
44
45          $item.addClass("has-mega-menu").addClass("expand-colapse__trigger");
46
47          const clickedLink = $(evt.target).closest("a")[0];
48          const isMegaMenuClick = $(evt.target).closest(".mega-menu", this).length > 0;
49          const directTriggerLink = $item.children("a")[0] || null;
50          const isDirectTriggerLink = !!clickedLink && clickedLink === directTriggerLink;
51
52          // Allow links inside the mega menu to navigate normally.
53          if (clickedLink && !isDirectTriggerLink) {
54            return;
55          }
56
57          if (isMegaMenuClick) {
58            return;
59          }
60
61          if (!isMobileNavigation()) {
62            evt.preventDefault();
63            openMegaMenu(this);
64            return;
65          }
66
67          if (isDirectTriggerLink) {
68            evt.preventDefault();
69          }
70
71          $(".navigation__item.has-mega-menu.expanded")
72            .not(this)
73            .removeClass("expanded");
74
75          $(this).addClass("expanded");
76        });
77
78      $(document)
79        .off("click.headerSubMenu")
80        .on(
81          "click.headerSubMenu",
82          ".navigation__sub-item.expand-colapse__trigger",
83          function (evt) {
84            // On desktop, nested submenus are always visible.
85            if (!isMobileNavigation()) {
86              return;
87            }
88
89            const trigger = this;
90            const $target = $(evt.target);
91
92            // Ignore clicks inside the nested submenu.
93            if ($target.closest(".expand-colapse__item", trigger).length) {
94              return;
95            }
96
97            // Allow the direct link to navigate normally.
98            if ($target.closest("a", trigger).length) {
99              return;
100            }
101
102            evt.preventDefault();
103            $(trigger).toggleClass("expanded");
104          }
105        );
106
107      $(".bottom_region, .principal-menu", context)
108        .off("focusout.headerMegaMenu")
109        .on("focusout.headerMegaMenu", function (evt) {
110          if (!isMobileNavigation() && !this.contains(evt.relatedTarget)) {
111            closeMegaMenu();
112          }
113        });
114
115      $(document)
116        .off("keyup.headerMegaMenu")
117        .on("keyup.headerMegaMenu", function (evt) {
118          if (evt.key === "Escape") {
119            closeMegaMenu();
120          }
121        });
122
123      $(".body-overlap", context)
124        .off("click.headerMegaMenu")
125        .on("click.headerMegaMenu", function () {
126          if ($("html").hasClass("open-body-overlap")) {
127            closeMegaMenu();
128          }
129        });
130
131      $(".mobile-only-local .menu_bars:not(.active)").on("click", function () {
132        $(this).addClass("active");
133        $(".mobile-only-local .all-screen").addClass("show");
134      });
135
136      $(".mobile-only-local .all-screen .close button").on("click", function () {
137        $(this).removeClass("active");
138        $(".mobile-only-local .all-screen").removeClass("show");
139      });
140
141      const destacado = $(".destacado_region");
142
143      if (destacado.length > 0) {
144        for (let i = 0; i < destacado.length; i++) {
145          const element = $(destacado[i]);
146
147          if (element.find(".item_destacado").length === 1) {
148            element.addClass("is-one-row");
149          }
150        }
151      }
152    },
153  };
154
155  if (document.readyState !== "loading") {
156    Drupal.behaviors.header.attach(document, window.drupalSettings || {});
157  } else {
158    document.addEventListener("DOMContentLoaded", function () {
159      Drupal.behaviors.header.attach(document, window.drupalSettings || {});
160    });
161  }
162})(jQuery, Drupal);

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.