PageSourceSearch

https://www.lapinliitto.fi/wp-content/themes/iggo20/js/iggo-menu.js?20250413a

js lapinliitto.fi collected 2026-10-02 04:09:21 UTC 8,989 bytes, 325 lines download raw bytes

1jQuery(document).ready(function($)
2{
3
4
5
6/* IGGO Desktop Menu
7---------------------------------------------------------------------------------------------------------------------- */
8
9	// Setting proper functions for toggling classes when opening and closing
10		function openMainNav(selectedmenu)
11		{
12			$("nav#main .menu>li").removeClass('selected');
13			selectedmenu.addClass('selected');
14			$('.nav-overlay').removeClass('inactive').addClass('openedByMain');
15		}
16
17		function closeMainNav()
18		{
19			$("nav#main .menu>li").removeClass('selected');
20			$('.nav-overlay.openedByMain').addClass('inactive');
21		}
22
23
24	// Close mainmenu by clicking anything outside it
25		$(document).on('click touchstart', function(e)
26		{
27			var $clicked_el = $(e.target);
28			if(!$clicked_el.parents('nav#main .menu').length)
29			{
30				closeMainNav();
31			}
32		});
33
34
35	// Toggle submenu open by clicking on mainmenu item
36	    $("nav#main .menu>li>a").on("click touchstart", function()
37		{
38			if(!$(this).next().is('ul'))
39			{
40				// If this is just a single link item with no subitems, then behave as a normal link
41				return true
42			}
43			else
44			{
45				// Get correct submenu item (li)
46				var $mysub = $(this).parent();
47
48				if($mysub.is('.selected'))
49				{
50					closeMainNav();
51				}
52				else
53				{
54					openMainNav($mysub);
55				}
56
57				return false;
58			}
59		});
60
61
62
63
64
65/* IGGO Mobile Menu (Below 992px)
66---------------------------------------------------------------------------------------------------------------------- */
67
68	// IGGO: MOBILE MENU START
69		if($(window).width() < 4096) // If set to 992, it will avoid scripts when over 992px wide, but also forces a refresh so this is disabled
70		{
71
72			// Mobilenav close
73			var closeNav = function(manualcollapse)
74			{
75
76				// Set classes
77				$(".nav-overlay").addClass("inactive");
78				$("#nav-toggler").removeClass("open");
79
80				// If main menu close happened manually due to external reason (search box opening or overlay click), set classes
81				if(manualcollapse)
82				{
83					$("#nav-toggler").removeClass("open");
84				}
85
86				$("#mobile-menu").addClass("inactive");
87			}
88
89
90			// Disables movement when sliding the background overlay
91			$('.nav-overlay').on("touchmove", function(ev) {
92					ev.preventDefault();
93					return false;
94			});
95
96
97			// Mobilemenu open
98			if($("#nav-toggler") && $("#nav-toggler").length > 0)
99			{
100				$("#nav-toggler").on("click", function()
101				{
102					if(!$("#mobile-menu").hasClass("inactive"))
103					{
104						// Menu was open, close it
105						closeNav(false);
106					}
107					else
108					{
109						search_mob_close(); // Close mobile menu
110
111						var myScroll = $(window).scrollTop();   // Get the current scroll value
112
113						var myDisplace = (myScroll * -1) + 50;   // Tuning the value
114
115						jQuery.data(document.body,'myscroll',myScroll);         // save the value in the body element
116						$(".nav-overlay").removeClass("inactive");
117						$("#mobile-menu").removeClass("inactive");
118						$("#nav-toggler").addClass("open");
119
120					}
121
122
123				});
124			}
125
126
127			// Submenu Functionality
128			$("#mobile-menu ul.nav a").on("click", function()
129			{
130				var $li = $(this).parent("li");				// Get clicked li-element
131				var $ul = $li.parents("ul.nav");			// Get the topmost ul.nav element
132				var $descendants = $li.find('ul');			// Get (possible) descendant menus
133
134				// If this menu is set as a toggle-menu (using the automatic toggle-icons functionality), then behave differently
135				if($ul.is('.togglenav'))
136				{
137					// Since this is a togglenav, and user clicked directly on a page link instead of a toggle
138					// we should let the link click go through and go to the page clicked.
139					// However, if there is a toggle here and it has been marked as force-toggle, then we activate it instead
140					var $forcetoggle = $(this).siblings('div.force-toggle');
141					if($forcetoggle.length)
142					{
143						// Forced toggle found, trigger it and cancel the click
144						$forcetoggle.trigger('click');
145						return false;
146					}
147					else
148					{
149						// No forcetoggles found, click through!
150						return true;
151					}
152
153				}
154				else // Not using the toggle-menu functionality, behave as before
155				{
156					// Check if we have descendants
157					if($descendants.length > 0)
158					{
159						// We have descendants, so open/close them instead of behaving as a link
160						if($li.is('.selected'))
161						{
162							// Menu is open, lets close it
163							$li.removeClass('selected');
164						}
165						else
166						{
167							// Menu was closed, lets open it
168
169							// First close all this level menus
170							$li.parent('ul').find('li.selected').removeClass('selected');
171
172							// Then open this menu
173							$li.addClass('selected');
174						}
175
176						return false;
177					}
178				}
179
180			});
181
182			// Submenu Toggle-button functionality
183			$("#mobile-menu ul.togglenav div.toggle-expand").on("click", function()
184			{
185				var $li = $(this).parent("li");				// Get clicked li-element
186
187				if($li.is('.selected'))
188				{
189					// Menu is open, lets close it
190					$li.removeClass('selected');
191				}
192				else
193				{
194					// Menu was closed, lets open it
195
196					// First close all this level menus
197					$li.parent('ul').find('li.selected').removeClass('selected');
198
199					// Then open this menu
200					$li.addClass('selected');
201				}
202
203				return false;
204			});
205
206
207
208
209
210/* IGGO Desktop Search
211---------------------------------------------------------------------------------------------------------------------- */
212
213			// DT search open
214			/*
215			var search_dt_open = function()
216			{
217				var head_searchwrap = $('header .search-wrap');
218				head_searchwrap.removeClass('inactive').addClass('active');
219
220				// Focus the field as soon as CSS transition ends.
221	            head_searchwrap.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',
222	                function(e) {
223	                    $('#search-field').focus();
224	              });
225			}
226
227			// DT search close
228			var search_dt_close = function()
229			{
230				var head_searchwrap = $('header .search-wrap');
231				head_searchwrap.removeClass('active').addClass('inactive');
232
233			}
234
235			// DT search toggle / trigger
236		    $("header").on("click", "a.search-toggle", function(){
237		        var loginBoxObj = $(this).parent().find("div.search-wrap");
238		        if(loginBoxObj.hasClass("inactive")){
239		            search_dt_open();
240
241		        }else{
242		            search_dt_close();
243		        }
244		    return false;
245		    });
246
247		    // Also trigger desktop search close if clicking outside the field anyw
247here
248			jQuery(document).mouseup(function(e){
249			    var loginBoxObj = jQuery("header .search-wrap");
250			    var loginTriggerObj = jQuery("header a.search-toggle");
251			    if (!loginBoxObj.is(e.target) && loginBoxObj.has(e.target).length === 0
252			        && !loginTriggerObj.is(e.target) && loginTriggerObj.has(e.target).length === 0
253			    ){
254			        if(jQuery(loginBoxObj).hasClass("active")){
255			            search_dt_close();
256			        }
257			    }
258			});
259			*/
260
261
262/* IGGO Mobile Search
263---------------------------------------------------------------------------------------------------------------------- */
264
265		    // Mobile search open
266		    var search_mob_open = function()
267			{
268				console.log('search_mob_open triggered!');
269				closeNav(true); // Close mobile menu
270
271				var mob_searchwrap = $('#botbar .search-wrap');
272				mob_searchwrap.removeClass('inactive').addClass('active');
273
274				// activate overlay
275		        $(".nav-overlay").removeClass("inactive");
276
277				// Focus the field as soon as CSS transition ends.
278	            mob_searchwrap.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',
279	                function(e) {
280	                    $('#mobile-search-field').focus();
281	              });
282			}
283
284
285			// Mobile search close
286			var search_mob_close = function()
287			{
288				console.log('search_mob_close triggered!');
289				var mob_searchwrap = $('#botbar .search-wrap');
290				mob_searchwrap.removeClass('active').addClass('inactive');
291
292				// Remove overlay
293		        $(".nav-overlay").addClass("inactive");
294
295			}
296
297
298		    // Mobile search toggle / trigger
299		    $("#botbar").on("click", "button.search-toggle", function(){
300		        var loginBoxObj = $(this).parent().find("div.search-wrap");
301		        if(loginBoxObj.hasClass("inactive")){
302		            search_mob_open();
303		        }else{
304		            search_mob_close();
305		        }
306		    return false;
307		    });
308
309
310			// Close menu by clicking the overlay
311			$(".nav-overlay").on("click", function(){
312				closeNav(true);
313				search_mob_close();
314			});
315
316
317		}
318
319
320
321
322
323/* End of iggo-menu.js
324---------------------------------------------------------------------------------------------------------------------- */
325});

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.