PageSourceSearch

https://gameinformer.com/themes/custom/gi5/js/global/menus.js?06f47765dd36

js gameinformer.com collected 2026-10-02 02:15:20 UTC 6,988 bytes, 180 lines download raw bytes

1(function ($, Drupal, drupalSettings, once) {
2  // Start jQuery
3  Drupal.behaviors.gi5_menus = {
4    attach: function (context, settings) {
5      // Get info from Drupal when it's ready
6      once("gi5_menus", "html", context).forEach(function () {
7          // Only run this once, when Drupal is ready
8
9          // Resize the front page header on scroll
10          if ($("body").hasClass("path-frontpage")) {
11            var shrinkHeader = 100;
12            $(window).scroll(function () {
13              var scroll = getCurrentScroll();
14              //console.log("scroll " + scroll);
15              if ($("body").hasClass("path-frontpage")) {
16                if (
17                  scroll < shrinkHeader - 50 &&
18                  !$(".top-bar").hasClass("expanded")
19                ) {
20                  $(".top-bar").addClass("expanded");
21                } else if (
22                  scroll > shrinkHeader &&
23                  $(".top-bar").hasClass("expanded")
24                ) {
25                  $(".top-bar").removeClass("expanded");
26                }
27              }
28            });
29          }
30
31          function getCurrentScroll() {
32            return window.pageYOffset || document.documentElement.scrollTop;
33          }
34
35          // Main menu hover effects //
36          var timer;
37          // Create a timer variable
38          $(".menu--main .menu-item a").hover(
39            // When you hover over a menu item
40            function () {
41              $(".menu-hovered").removeClass("menu-hovered");
42              // Remove the hovered class from anywhere it already is
43              if ($(this).hasClass("is-active")) {
44                // If this is the active page
45                $(".is-active").removeClass("menu-remove-hover");
46                // Remove the class that hides the hover if it's there
47                //console.log("already active!");
48              } else {
49                if (!$(this).hasClass("menu-hovered")) {
50                  // If it's not already hovered
51                  $(this).addClass("menu-hovered");
52                  // Add the class with hover effects
53                  $(".menu-item .is-active").addClass("menu-remove-hover");
54                  // And hide the active page hover effect
55                  //console.log("changing it up");
56                }
57              }
58            }
59          );
60          $(".menu--main .menu-item a").mouseleave(function () {
61            if (timer) {
62              // If the time was already set,
63              clearTimeout(timer);
64              // Clear the previous timer.
65            }
66            timer = setTimeout(function () {
67              // Set a new timer
68              $(".menu-hovered").removeClass("menu-hovered");
69              $(".is-active").removeClass("menu-remove-hover");
70            }, 1000);
71          });
72
73          // Hamburger Menu Accordion
74          $(document).on("click", ".gi5-hamburger-menu-toggle", function (e) {
75            e.preventDefault();
76            // console.log("Menu item clicked");
77            $(this).parents(".menu-item--expanded").toggleClass("gi5-hamburger-menu-show");
78            $(this).siblings(".menu").slideToggle(350);
79          });
80
81          // IF Main menu length is shorter than main menu content length, show a dropdown at the end
82          itemsInOverflow = 0;
83          menuIsOpen = false;
84
85          function setUpMenu() {
86            if (
87              !$(".gi5-menu-overflow-toggle").length &&
88              $(".header-nav .menu").width() != 0
89            ) {
90              menuArea = $(".header-nav .menu").width();
91              menuWidth = 0;
92              $(".header-nav .menu .menu-item").each(function (index) {
93                //console.log( index + ": " + $( this ).text() + $( this ).width());
94                menuWidth = menuWidth + $(this).width();
95              });
96              if (menuArea < menuWidth) {
97                $(".header-nav").addClass("gi5-menu-has-overflow");
98                $(".header-nav .menu").append(
99                  '<li class="gi5-menu-overflow-toggle"><span id="gi5-menu-overflow-more">More <span id="gi5-menu-overflow-icon"></span></span> <ul class="gi5-menu-overflow"></ul></li>'
100                );
101              }
102              //console.log("setUpMenu menuArea: " + menuArea);
103              //console.log("setUpMenu menuWidth: " + menuWidth);
104            }
105          }
106
107          function setUpMenuItems() {
108            if (
109              $(".gi5-menu-overflow-toggle").length &&
110              $(".header-nav .menu").width() != 0
111            ) {
112              menuArea = $(".header-nav .menu").width();
113              menuWidth = 0;
114              if ($(".gi5-menu-overflow-toggle").length) {
115                menuWidth = 70;
116              }
117              $(".header-nav .menu .menu-item").each(function (index) {
118                //console.log( index + ": " + $( this ).text() + $( this ).width());
119                menuWidth = menuWidth + $(this).width();
120                if (menuArea < menuWidth) {
121                  $(this)
122                    .removeClass("menu-item")
123                    .addClass("menu-item-overflow")
124                    .prependTo(".gi5-menu-overflow");
125                  itemsInOverflow++;
126                }
127              });
128              //console.log("setUpMenuItems menuArea: " + menuArea);
129              //console.log("setUpMenuItems menuWidth: " + menuWidth);
130              //console.log("itemsInOverflow: " + itemsInOverflow);
131              // If there's only one item in the overflow menu, grab another (the last one) to keep it company
132              if (itemsInOverflow === 1) {
133                $(".header-nav .menu .menu-item")
134                  .last()
135                  .removeClass("menu-item")
136                  .addClass("menu-item-overflow")
137                  .prependTo(".gi5-menu-overflow");
138
139                itemsInOverflow++;
140                //console.log("itemsInOverflow: " + itemsInOverflow);
141              }
142            }
143          }
144
145          function openCloseMenu() {
146            if (menuIsOpen) {
147              $(".gi5-menu-overflow").slideUp("slow");
148              $(".gi5-menu-overflow-toggle").removeClass(
149                "gi5-menu-overflow-is-open"
150              );
151              menuIsOpen = false;
152            } else {
153              $(".gi5-menu-overflow").slideDown("slow");
154              $(".gi5-menu-overflow-toggle").addClass(
155                "gi5-menu-overflow-is-open"
156              );
157              menuIsOpen = true;
158            }
159          }
160
161          setUpMenu();
162          setUpMenuItems();
163
164          $(window).resize(function () {
165            setUpMenu();
166            setUpMenuItems();
167          });
168
169          $(".menu").on(
170            "click",
171            ".gi5-menu-overflow-toggle #gi5-menu-overflow-more",
172            function () {
173              openCloseMenu();
174            }
175          );
176        }); // End once call
177    }, // End Drupal behaviors
178  };
179  // end file
180})(jQuery, Drupal, drupalSettings, 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.