PageSourceSearch

https://www.paramountpictures.com/themes/custom/paramount/js/menu.js?v=11.1.2

js paramountpictures.com collected 2026-10-02 03:53:05 UTC 7,140 bytes, 224 lines download raw bytes

1/**
2 * @file
3 * Global utilities.
4 *
5 */
6(function($, Drupal, once) {
7
8  'use strict';
9
10          function setSearchBarPosition() {
11          var navbar = document.getElementById('main-navbar');
12          var searchBar = document.getElementById('block-paramount-views-block-search-navbar-block');
13
14          if (!searchBar) {
15            return;
16          }
17
18          // Always keep search bar at 80px when page is scrolled.
19          if (document.body.classList.contains('page-scrolled')) {
20            searchBar.style.top = '80px';
21            return;
22          }
23
24          // Below desktop breakpoint.
25          if (window.innerWidth < 992) {
26            searchBar.style.top = '80px';
27            return;
28          }
29
30          // Homepage or pages without a navbar title.
31          var navbarTitle = navbar ? navbar.querySelector('.navbar__title') : null;
32
33          if (!navbarTitle) {
34            searchBar.style.top = '80px';
35            return;
36          }
37
38          // Desktop + normal title.
39          if (!navbarTitle.classList.contains('title-color-transparent')) {
40            searchBar.style.top = '198px';
41          } else {
42            searchBar.style.top = '80px';
43          }
44        }
45
46  /** Main Navigation. */
47  Drupal.behaviors.paramountMainNavigation = {
48    attach: function(context, settings) {
49      $(document).ready(function() {
50        function toggleMenu() {
51          const $nav = $('#main-navbar');
52          const $menu = $('#block-paramount-mainnavigation');
53
54          if ($menu.hasClass('open')) {
55            $menu.removeClass('open');
56            $menu.addClass('closing');
57            $nav.removeClass('nav-expanded');
58
59            setTimeout(() => {
60              $('body').removeClass('menu-open');
61              $menu.removeClass('closing');
62            }, 300);
63          } else {
64            $menu.addClass('open');
65            $nav.addClass('nav-expanded');
66            $('body').addClass('menu-open');
67          }
68        }
69
70
71        // Nav toggle.
72        once('main_nav_toggle', '.main-navigation__toggle', context).forEach(
73          (element) => {
74            element.addEventListener('click', () => {
75              $('#screen-blanket').toggleClass('active');
76              $('body').toggleClass('menu-open');
77              toggleMenu();
78            });
79          }
80        );
81
82        // Nav search toggle.
83        once('main_search_open', '.main-navigation__search', context).forEach(
84          (element) => {
85            element.addEventListener('click', () => {
86              setSearchBarPosition();
87              $('#block-paramount-views-block-search-navbar-block').toggleClass('search-open');
88              // Focus on search input if visible.
89              if ($('#block-paramount-views-block-search-navbar-block').hasClass('search-open')) {
90                $('#edit-searchfor').focus();
91              }
92            });
93          }
94        );
95
96        // Nav search close.
97        once('main_search_close', '.close-search', context).forEach(
98          (element) => {
99            element.addEventListener('click', () => {
100              $('#block-paramount-views-block-search-navbar-block').removeClass('search-open');
101            });
102          }
103        );
104
105
106        // Fullscreen blanket.
107        function closeFullscreenElements() {
108          $('.fullscreen-element').each(function() {
109            $(this).removeClass('open');
110          });
111          toggleMenu();
112        }
113
114        once('fullscreen_blanket', '#screen-blanket', context).forEach(
115          function (element) {
116            element.addEventListener('click', () => {
117              $('#screen-blanket').removeClass('active');
118              closeFullscreenElements();
119            });
120          }
121        );
122
123        $('li.menu-child__item a').on('click', function(e) {
124          const link = new URL(this.href, window.location.origin);
125          const currentPath = window.location.pathname.replace(/\/+$/, '');
126          const linkPath = link.pathname.replace(/\/+$/, '');
127
128          if (link.hash && linkPath === currentPath) {
129            toggleMenu();
130            $('#screen-blanket').removeClass('active');
131          }
132          
133        });
134      });
135    }
136  };
137
138  /** Main menu functions. */
139  Drupal.behaviors.paramountMainNavigationUI = {
140    attach: function(context, settings) {
141      $(document).ready(function() {
142        once('main_navigation', 'nav#block-paramount-mainnavigation', context)
143          .forEach(function (element) { prepMainNav(element); });
144
145        function prepMainNav(element) {
146          $('.menu-top__item[data-menu-parent]:not([data-placeholder=""])').each(function(index) {
147            $(this).click(function () {
148              selectParent($(this));
149            });
150
151            if (index === 0) {
152              selectParent($(this));
153            }
154
155            const initialScrollPostion = $(window).scrollTop();
156            if (initialScrollPostion > 0) {
157              $('.navbar').addClass('scrolled');
158              $('#block-paramount-content').addClass('scrolled');
159            }
160
161            const menuScroll = () => {
162              if ($(window).scrollTop() > 0) {
163                $('.navbar').not('.scrolled').addClass('scrolled');
164                $('#block-paramount-content').not('.scrolled').addClass('scrolled');
165                $('body').not('.page-scrolled').addClass('page-scrolled');
166              } else {
167                $('.navbar.scrolled').removeClass('scrolled');
168                $('#block-paramount-content').removeClass('scrolled');
169                $('body').removeClass('page-scrolled');
170              }
171              setSearchBarPosition();
172            };
173
174            $(document).on('scroll', function() {
175              menuScroll();
176            });
177            menuScroll();
178          });
179        }
180
181        function selectParent(parent) {
182          $('.menu-top__item.selected').removeClass('selected');
183          $('.menu-child.show').removeClass('show');
184
185          parent.addClass('selected');
186          $('.menu-child', parent).addClass('show');
187        }
188      });
189    }
190  };
191
192  /** Pre-open menu or search if coming from 404 page. */
193  Drupal.behaviors.paramountMainNavigationFragment = {
194    attach: function(context, settings) {
195      once('404_navigation', 'body', context).forEach(
196        (element) => {
197          if (window.location.hash === '#menu') {
198            setTimeout(() => {
199              $('.main-navigation .main-navigation__toggle').click();
200            }, 100);
201          }
202          if (window.location.hash === '#search') {
203            setTimeout(() => {
204              $('.main-navigation .main-navigation__search').click();
205            }, 100);
206          }
207        }
208      );
209    }
210  };
211
212  /** Preselect menu item based on current page. */
213  Drupal.behaviors.paramountMainNavigationActive = {
214    attach: function(context, settings) {
215      once('menu_active', '.main-nav-menu', context).forEach(
216        (element) => {
217          setTimeout(() => {
218            $('#block-paramount-mainnavigation .menu-item--active-trail > button').click();
219          }, 100);
220        }
221      );
222    }
223  };
224})(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.