PageSourceSearch

https://www.paralympic.org.au/wp-content/themes/paralympics/assets/js/menu.js?v=1790241547

js paralympic.org.au collected 2026-09-24 09:57:43 UTC 4,599 bytes, 205 lines download raw bytes

1document.addEventListener( 'DOMContentLoaded', function() {	
2	
3	function barClick() {
4		  const barBtn = document.querySelector('.bar-menu span');
5		  const closeBtn = document.querySelector('.top-nav-mobile .menu-close');
6		
7		  if (barBtn) {
8			barBtn.addEventListener('click', function (e) {
9			  e.preventDefault();
10
11			  document.body.classList.toggle('nav-active');
12			  this.classList.toggle('active');
13			});
14		  }
15
16		  if (closeBtn) {
17			closeBtn.addEventListener('click', function (e) {
18			  e.preventDefault();
19
20			  document.body.classList.remove('nav-active');
21
22			  // Also reset hamburger state
23			  if (barBtn) {
24				barBtn.classList.remove('active');
25				
26			  }
27			});
28		  }
29	  }
30	
31	barClick();
32	
33	
34	
35	const overlay = document.createElement('div');
36	overlay.className = 'menu-overlay';
37	document.body.appendChild(overlay);
38
39	let activeLi = null;
40
41	const nav = document.querySelector('.main-nav-lists');
42
43	document.querySelectorAll('.main-nav-lists > ul > li').forEach((li) => {
44		const mega = li.querySelector('.mega-menu-dropdown');
45		const link = li.querySelector(':scope > a');
46
47		if (!mega || !link) return;
48
49		link.addEventListener('click', (e) => {
50			e.preventDefault();
51			e.stopPropagation();
52
53			if (activeLi === li) {
54				deactivate(li);
55				return;
56			}
57
58			if (activeLi) deactivate(activeLi);
59			activate(li);
60		});
61
62	});
63
64	document.addEventListener('click', (e) => {
65		if (!nav.contains(e.target)) {
66			deactivate(activeLi);
67		}
68	});
69
70	overlay.addEventListener('click', () => {
71		deactivate(activeLi);
72	});
73
74	function activate(li) {
75		activeLi = li;
76		li.classList.add('current-hover');
77		overlay.classList.add('is-active');
78	}
79
80	function deactivate(li) {
81		if (!li) return;
82		li.classList.remove('current-hover');
83		overlay.classList.remove('is-active');
84		activeLi = null;
85	}
86});
87jQuery(function ($) {
88
89  const $drilldown = $('.drilldown');
90  let isActive = false;
91
92  function handleMobileDrilldown() {
93    const windowWidth = window.innerWidth;
94
95	  if (windowWidth <= 1024 && !isActive) {
96
97		  $drilldown.data('zfPlugin') || new Foundation.Drilldown($drilldown);
98
99		  isActive = true;
100
101		  $(document).on('click.mobileDrilldown','.drilldown a, .sub-menu-lists .m-title',function () {
102			  $(this).closest('.drilldown').trigger('resize.zf.trigger');
103		  });
104
105		  $(document).on('click.mobileDrilldown','.sub-menu-lists .m-title',function () {
106			  $(this).toggleClass('active');
107		  });
108
109	  } else if (windowWidth > 1024 && isActive) {
110
111		  $drilldown.data('zfPlugin')?.destroy();
112		  $(document).off('.mobileDrilldown');
113
114		  isActive = false;
115	  }
116
117  }
118
119  handleMobileDrilldown();
120
121  $(window).on('resize', function() {
122    handleMobileDrilldown();
123  });
124
125	function cloneBottomNavItems() {
126
127// 	  if (window.innerWidth > 1024) return;
128
129	  let $bottomNav = $('.bottom-nav-mobile');
130
131	  if (!$bottomNav.length) return;
132
133	  if (!$bottomNav.find('.donate-wrap').length) {
134		let donateClone = $('.donate-wrap').first().clone(true, true);
135		$bottomNav.append(donateClone);
136	  }
137
138	  if (!$bottomNav.find('.social-list-wrap').length) {
139		let socialClone = $('.social-list-wrap').first().clone(true, true);
140		$bottomNav.append(socialClone);
141	  }
142
143	}
144
145	cloneBottomNavItems();
146	
147	function updateDrillMenuHeight() {
148
149		const $menuContainer = $('.main-nav-lists .is-drilldown.animate-height');
150
151		if (!$menuContainer.length) return;
152
153		function setMenuHeight($submenu) {
154
155		  if (!$submenu || !$submenu.length) return;
156
157		  requestAnimationFrame(function () {
158
159			const height = $submenu.outerHeight(true);
160
161			$menuContainer.css('height', height + 'px');
162
163			$submenu.closest('.drilldown').trigger('resize.zf.trigger');
164
165		  });
166
167		}
168
169		$(document).on('click','.mega-menu-dropdown .sub-menu-lists .m-title',
170		  function () {
171
172			const $submenu = $(this).closest('.is-drilldown-submenu');
173			setMenuHeight($submenu);
174
175		  }
176		);
177
178		$(document).on('click','.js-drilldown-back',
179		  function () {
180
181			$('.m-title').removeClass('active');
182
183		  }
184		);
185
186	  }
187	
188	$('.bar-menu span').on('click', function() {
189
190		// 1. Find your drilldown element
191		var $drillMenu = $('.drilldown'); // Target your <ul data-drilldown>
192
193		// 2. Check if the menu wrapper is already open (meaning this click will close it)
194		// Adjust this condition to match how you are toggling the visibility of your menu container
195		if ($('body').hasClass('nav-active')) {
196			$('.sub-menu-lists .m-title').removeClass('active');
197			// 3. Force Foundation to reset the drilldown back to the root
198			$drillMenu.foundation('_hideAll');
199		}
200	});
201
202	  $(document).ready(function () {
203		updateDrillMenuHeight();
204	  });
205});

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.