PageSourceSearch

https://clacksandstirlinghscp.org/wp-content/plugins/SD-mobile-nav/js/mobile.nav.frontend.js?ver=6.5.1

js clacksandstirlinghscp.org collected 2026-10-07 02:53:11 UTC 16,548 bytes, 556 lines download raw bytes

1if(document.body.className.match('sdrn_open_sans_yes')) {
2	WebFontConfig = {
3		google: { families: [ 'Open+Sans::latin' ] }
4	};
5	(function() {
6		var wf = document.createElement('script');
7		wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
8		  '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
9		wf.type = 'text/javascript';
10		wf.async = 'true';
11		var s = document.getElementsByTagName('script')[0];
12		s.parentNode.insertBefore(wf, s);
13	})();
14} 
15
16 /**
17 * The main Mobile.Nav script
18 */
19jQuery(document).ready(function( $ ) {
20
21
22	var bar = $('#sdrn_bar'), //top bar that shows/hides the menu
23		bar_height = bar.outerHeight(true), //the bar height
24		from_width = bar.attr('data-from_width'),
25		menu = $('#sdrn_menu'), //the menu div
26		menu_ul = $('#sdrn_menu_ul'), //the menu ul
27		menu_a = menu.find('a'), //single menu link
28		body = $('body'),
29		html = $('html'),
30		animation_speed = 300,
31		ab = $('#wpadminbar'),
32		menu_enabled = (bar.length > 0 && menu.length > 0)? true : false,
33		menu_width = menu.width(),
34		target_height = (window.innerHeight < body.height())? body.height() : window.innerHeight,
35		target_width = (window.innerWidth < body.width())? body.width() : window.innerWidth,
36		fixed_elements = [],
37		fixed_elements_were_adjusted = false,
38		exiting = false;
39
40	//detecting browser
41	var nAgt = navigator.userAgent,
42		chrome = false,
43		mozilla = false;
44		//Safari,Opera,MSIE(ie<11),Trident(IE 11),Safari[or]AppleWebkit
45	if(nAgt.indexOf("Chrome") != -1) chrome = true;
46	if(nAgt.indexOf("Firefox") != -1) mozilla = true;
47
48
49	html.addClass('sdrn_'+Detect({ useUA: true }));
50
51	//fixing the submenu issue on Windows phones
52	if($('html').hasClass('sdrn-device-Nokia')) {
53		menu_ul.find('.menu-item-has-children').attr('aria-haspopup','true');
54	}
55
56	function is_visible(element) {
57		if(element.css("display") == 'none') {
58			return false;
59		}
60		return true;
61	}
62
63	if(menu_enabled) {
64
65		menu_ul.find('li').first().css({'border-top':'none'});
66
67		/**
68		 * Close menu on click outside
69		 */
70		$(document).mouseup(function (e) {
71			if (!menu.is(e.target) && menu.has(e.target).length === 0) {
72				if(is_visible(menu)) {
73
74					if(menu.hasClass('sdrn_jquery')) {
75						close_sub_uls();
76						$.sidr('close', 'sdrn_menu');
77						bar.removeClass('menu_is_opened');
78						body.removeClass('menu_is_opened');
79					}
80					if(menu.hasClass('sdrn_css3')) {
81						close_sub_uls();
82						bar.removeClass('menu_is_opened');
83						body.removeClass('menu_is_opened');
84						$('.fixed_animation').removeClass('fixed_animation_moved');
85					}
86				}
87			}
88		});
89
90		//ENABLE NESTING
91
92		//add arrow element to the parent li items and chide its child uls
93		menu.find('ul.sub-menu').each(function() {
94			var sub_ul = $(this),
95				parent_a = sub_ul.prev('a'),
96				parent_li = parent_a.parent('li').first();
97
98			parent_a.addClass('sdrn_parent_item');
99			parent_li.addClass('sdrn_parent_item_li');
100
101			var expand = parent_a.before('<span tabindex="0" class="sdrn_icon sdrn_icon_par icon_default '+menu.attr('data-custom_icon')+'"></span> ').find('.sdrn_icon_par');
102
103			sub_ul.hide();
104		});
105		if(menu.hasClass('sdrn_custom_icons')) $('#sdrn_menu span.sdrn_icon').removeClass('icon_default');
106
107		//MAYBE APPLY CUSTOM ICONS FOR ITEMS
108
109		menu.find('#sdrn_menu_ul a[data-cii=1]').each(function() {
110			var t = $(this),
111				fa_icon = t.attr('data-fa_icon'),
112				icon_color = t.attr('data-icon_color'),
113				icon_container = t.find('div').first(),
114				icon_src = t.attr('data-icon_src');
115
116			//enable image icon
117			if(icon_src) {
118				icon_container.addClass('sdrn_item_custom_icon');
119				icon_container.html('<img src="'+icon_src+'" width="23" height="23" alt="cii">');
120			}
121		});
122
123		//adjust the a width on parent uls so iyt fits nicely with th eicon elemnt
124		function adjust_expandable_items() {
125			$('.sdrn_parent_item_li').each(function() {
126				var t = $(this),
127					main_ul_width = 0,
128					icon = t.find('.sdrn_icon_par').first(),
129					link = t.find('a.sdrn_parent_item').first();
130
131				if(menu.hasClass('top')) {
132					main_ul_width = window.innerWidth;
133				} else {
134					main_ul_width = menu_ul.innerWidth();
135				}
136
137				if(t.find('.sdrn_clear').length == 0) link.after('<br class="sdrn_clear"/>');
138			});
139		}
140		adjust_expandable_items();
141
142    // Function to handle the sub-menu expansion and collapse
143    function toggleSubMenu(e) {
144    e.preventDefault();
145
146    var t = jQuery(this),
147        li = t.closest('li'),
148        child_ul = li.children('ul.sub-menu').first(),
149        opening = !child_ul.is(':visible');
150
151    // Prevent animation queue build-up (can cause "jumping")
152    child_ul.stop(true, true).slideToggle(300, function () {
153        if (opening) {
154        var firstLink = child_ul.find('li:first-child a').get(0);
155        if (firstLink) {
156            // Modern browsers: focus without scrolling
157            try { firstLink.focus({ preventScroll: true }); }
158            catch (err) { firstLink.focus(); }
159        }
160        }
161    });
162
163    t.toggleClass('sdrn_par_opened');
164
165    if (jQuery('#sdrn_menu').attr('data-custom_icon') !== '') {
166        t.toggleClass(jQuery('#sdrn_menu').attr('data-custom_icon_open'));
167        if (jQuery('#sdrn_menu').attr('data-custom_icon_open') !== '') {
168        t.toggleClass(jQuery('#sdrn_menu').attr('data-custom_icon'));
169        }
170    }
171
172    li.toggleClass('sdrn_no_border_bottom');
173    }
174
175    // Event listener for clicks on .sdrn_icon_par elements
176    $('.sdrn_icon_par').on('click', toggleSubMenu);
177
178    // Event listener for keyboard events on .sdrn_icon_par elements
179    $('.sdrn_icon_par').on('keydown', function (e) {
180        if (e.key === 'Enter' || e.keyCode === 13) {
181            toggleSubMenu.call(this, e);
182        }
183    });
184
185    // Helper function to check if an element is visible
186    function is_visible(element) {
187        return element.is(':visible');
188    }
189
190	//helper - close all submenus when menu is hiding
191	function close_sub_uls() {
192		menu.find('ul.sub-menu').each(function() {
193			var ul = $(this),
194				icon = ul.parent('li').find('.sdrn_icon_par'),
195				li = ul.parent('li');
196
197			if(is_visible(ul)) ul.slideUp(300);
198			icon.removeClass('sdrn_par_opened');
199			icon.removeClass(menu.attr('data-custom_icon_open'));
200			icon.addClass(menu.attr('data-custom_icon'));
201			li.removeClass('sdrn_no_border_bottom');
202		});
203	}
204
205		//Additional fixes on change device orientation
206        if (mozilla) {
207            screen.addEventListener("orientationchange", function() { updateOrientation(); });
208        }
209		function updateOrientation() {
210
211			//trigger page scroll to hide the IOS browser UI
212			window.scrollBy(1,1);
213			window.scrollBy(-1,-1);
214
215			//update widths for new orientation
216			menu_width = menu.width();
217			target_height = (window.innerHeight < body.height())? body.height() : window.innerHeight;
218			target_width = (window.innerWidth < body.width())? body.width() : window.innerWidth;
219
220			//top menu does not need adjustments
221
222			//reset for left & right menu (if opened while changing orientation)
223			if(body.hasClass('menu_is_opened')) {
224				if(menu.hasClass('sdrn_jquery')) {
225					close_sub_uls();
226					//additional adjustment only for 'left' pos
227					if(body.hasClass('sdrn_left')) {
228						body.css({'left':menu_width});
229						body.scrollLeft(0);
230					}
231					$.sidr('close', 'sdrn_menu');
232					bar.removeClass('menu_is_opened');
233					body.removeClass('menu_is_opened');
234				}
235				if(menu.hasClass('sdrn_css3')) {
236					close_sub_uls();
237					bar.removeClass('menu_is_opened');
238					body.removeClass('menu_is_opened');
239				}
240			}
241
242		}
243
244		function update_fixed_elements(fixed_elements) {
245			//if fixed elements are on the page
246			if(fixed_elements.length > 0) {
247				//loop trogh them and
248				$.each(fixed_elements, function(index, el) {
249					//this adjustment is applied only once - at the begining
250					if(fixed_elements_were_adjusted == false) {
251						var el_top = (parseInt(el.css("top"),0) >= 0)? parseInt(el.css("top"),0) : 0,
252							adminbar = $('#wpadminbar');
253
254						//move fixed el down: ADMIN BAR - YES | MENU BAR - YES
255						if(is_visible(adminbar) && is_visible(bar)) el.css({'top':el_top+42+adminbar.height()});
256
257						//move fixed el down: ADMIN BAR - YES | MENU BAR - NO
258						if(is_visible(adminbar) && !is_visible(bar)) el.css({'top':el_top+adminbar.height()});
259
260						//move fixed el down (by bar height): ADMIN BAR - NO | MENU BAR - YES
261						if(!is_visible(adminbar) && is_visible(bar)) el.css({'top':el_top+42});
262
263						//move fixed el down (by bar height): ADMIN BAR - NO | MENU BAR - NO
264						if(!is_visible(adminbar) && !is_visible(bar)) el.css({'top':el_top});
265
266						el.css({'z-index':900});
267						el.addClass('fixed_animation');
268					}
269				});
270			}
271			fixed_elements_were_adjusted = true;
272		}
273
274		function adjust_to_adminbar() {
275			var adminbar = $('#wpadminbar');
276			if(is_visible(adminbar)) {
277				$('#sdrn_menu.left ul#sdrn_menu_ul, #sdrn_menu.right ul#sdrn_menu_ul').css({'padding-top': (42+adminbar.height())});
278				$('#sdrn_bar').css({'top':adminbar.height()});
279			}
280		}
281
282		$('.bar_logo').on('click', function() {
283			var url = $(this).attr('data-url');
284			if(url!= '') {
285				window.location.href = url;
286				exiting = true;
287			}
288		});
289
290		//The left/right menu
291		if(menu.hasClass('left') || menu.hasClass('right')) {
292
293
294			//appy sidr only if animation == jquery
295			if(menu.hasClass('sdrn_jquery')) {
296				var hor_pos = (menu.hasClass('left'))? 'left' : 'right';
297				bar.sidr({
298					name:'sdrn_menu',
299					side: hor_pos,
300					speed: animation_speed
301				});
302			}
303
304			//adjust the bar % menu position according to the WP admin bar + bar top distance (if present)
305			adjust_to_adminbar();
306
307			//css animation setup
308			if(menu.hasClass('sdrn_css3')) {
309				menu.show();
310
311				var wrapper = body.wrapInner('<div id="sdrn_wrapper">').find('#sdrn_wrapper');
312				var inner_wrapper = wrapper.wrapInner('<div id="sdrn_wrapper_inner">').find('#sdrn_wrapper_inner');
313
314				menu.insertBefore(wrapper);
315				bar.insertBefore(wrapper);
316				ab.insertBefore(wrapper);
317
318				//move out fixed elements from the wrapper and append them to the body
319				var x = inner_wrapper.find('> *').filter(function() { return $(this).css("position") === 'fixed'; }).each(function() {
320					var t = $(this);
321					body.append(t);
322					fixed_elements.push(t);
323				});
324				update_fixed_elements(fixed_elements);
325
326				//copy css background from <body> to wrapper and adjust the wrapper to window size if needed
327				if(body.height() < $(window).height()) {
328					body.height($(window).height());
329					wrapper.height($(window).height());
330				}
331				//if no background or if background color is transparent ends with ...0)
332				(body.css('background') == '' || body.css('background-color').indexOf("0)") >= 0)? wrapper.css({'background':'#fff'}) : wrapper.css({'background':body.css('background')});			}
333
334			//if menu is open  - on bar click: close sub ul-s
335			bar.on('click', function() {
336				if(exiting) return;
337				//close_sub_uls();
338				bar.toggleClass('_opened_'); //the normal toggleClass did not work so we are using th e addintional _opened_ class to indicate if we should show or hide the menu.
339				if(bar.hasClass('_opened_')) {
340					bar.addClass('menu_is_opened');
341					body.addClass('menu_is_opened');
342					$('.fixed_animation').addClass('fixed_animation_moved');
343				} else {
344					bar.removeClass('menu_is_opened');
345					body.removeClass('menu_is_opened');
346					$('.fixed_animation').removeClass('fixed_animation_moved');
347				}
348			});
349
350			//when link is clicked - hide the menu first and then change location to new page
351			menu_a.on('click', function(e) {
352				e.preventDefault();
353
354				var url = $(this).attr('href');
355				if(menu.hasClass('sdrn_jquery')) $.sidr('close', 'sdrn_menu');
356				if(menu.hasClass('sdrn_css3')) {
357					close_sub_uls();
358					$('.fixed_animation').removeClass('fixed_animation_moved');
359				}
360				bar.removeClass('menu_is_opened');
361				body.removeClass('menu_is_opened');
362				setTimeout(function() {
363					window.location.href = url;
364				}, animation_speed);
365			});
366
367			$(window).resize(function(){
368				target_width = (window.innerWidth < body.width())? body.width() : window.innerWidth;
369
370				//hide menu when resize window above trigger value
371				if(target_width > from_width && is_visible(menu)) {
372					close_sub_uls();
373					if(menu.hasClass('sdrn_jquery')) $.sidr('close', 'sdrn_menu');
374					if(menu.hasClass('sdrn_css3')) {
375						bar.removeClass('menu_is_opened');
376						body.removeClass('menu_is_opened');
377						$('.fixed_animation').removeClass('fixed_animation_moved');
378					}
379				}
380
381				adjust_to_adminbar();
382
383				//update position for fixed elements when resizing BELOW trigger value
384				update_fixed_elements(fixed_elements);
385			});
386
387		} else if(menu.hasClass('top')) { //The top positioned menu
388
389			body.prepend(menu);
390
391			//adjust the bar % menu position according to the WP admin bar + bar top distance (if present)
392			adjust_to_adminbar();
393
394			//show / hide the menu
395			bar.on('click', function(e) {
396				if(exiting) return;
397				//scroll window top
398				$("html, body").animate({ scrollTop: 0 }, animation_speed);
399
400				bar.toggleClass('_opened_'); //the normal toggleClass did not work so we are using th e addintional _opened_ class to indicate if we should show or hide the menu.
401				if(bar.hasClass('_opened_')) {
402					bar.addClass('menu_is_opened');
403					body.addClass('menu_is_opened');
404				} else {
405					bar.removeClass('menu_is_opened');
406					body.removeClass('menu_is_opened');
407				}
408
409				close_sub_uls();
410				menu.stop(true, false).slideToggle(animation_speed);
411
412			});
413
414			//when link is clicked - hide the menu first and then change location to new page
415			menu_a.on('click', function(e) {
416				e.preventDefault();
417
418				var url = $(this).attr('href');
419
420				menu.slideUp(animation_speed,function() {
421					//go to the url from the link
422					window.location.href = url;
423				});
424			});
425
426			$(window).resize(function(){
427				target_width = (window.innerWidth < body.width())? body.width() : window.innerWidth;
428				if(target_width > from_width && is_visible(menu)) {
429					close_sub_uls();
430					menu.slideUp(animation_speed, function() {});
431				}
432			});
433
434		} //end if class left / top /right
435
436		function close_leftright_menu() {
437			if(menu.hasClass('sdrn_jquery')) {
438				$.sidr('close', 'sdrn_menu');
439				bar.removeClass('menu_is_opened');
440				body.removeClass('menu_is_opened');
441			}
442			if(menu.hasClass('sdrn_css3')) {
443				close_sub_uls();
444				bar.removeClass('menu_is_opened');
445				body.removeClass('menu_is_opened');
446				$('.fixed_animation').removeClass('fixed_animation_moved');
447			}
448		}
449		function open_leftright_menu() {
450			if(menu.hasClass('sdrn_jquery')) {
451				$.sidr('open', 'sdrn_menu');
452				bar.addClass('menu_is_opened');
453				body.addClass('menu_is_opened');
454			}
455				if(menu.hasClass('sdrn_css3')) {
456				bar.addClass('menu_is_opened');
457				body.addClass('menu_is_opened');
458				$('.fixed_animation').addClass('fixed_animation_moved');
459			}
460		}
461
462	} //end if menu enabled
463
464});
465
466/**
467 * Device detection
468 */
469var Detect = function(options) {
470	if (options === undefined) options = {};
471
472	this.init = function() {
473		this.mm = window.matchMedia;
474
475		if (this.mm && !options.useUA) {
476			this.method = 'media queries';
477			this.type   = mq();
478		}
479		else {
480			this.method = 'user agent strings';
481			this.type   = ua();
482		}
483
484		return options.verbose ? [ this.type, this.method ] : this.type;
485	};
486
487	/**
488	 * Media queries
489	 */
490
491	var mq = function() {
492		if (minMatch(320) && maxMatch(480))
493			return 'smartphone';
494
495		if (minMatch(768) && maxMatch(1024))
496			return 'tablet';
497
498		return 'desktop';
499	};
500
501	var match = function(m, width) {
502		return window.matchMedia(
503				'screen and (' + m + '-device-width: '
504					+ width + 'px)').matches;
505	};
506
507	var minMatch = function(width) {
508		return match('min', width);
509	};
510
511	var maxMatch = function(width) {
512		return match('max', width);
513	};
514
515	/**
516	 * User agent strings
517	 */
518
519	var ua = function() {
520		var uas = navigator.userAgent;
521
522		tablets = [ /Android 3/i, /iPad/i ];
523		for (i=0, l=tablets.length; i<l; i++)
524			if (uas.match(tablets[i])) return 'tablet';
525
526		smartphones = [
527			/Mobile/i,
528			/Android/i,
529			/iPhone/i,
530			/BlackBerry/i,
531			/Windows Phone/i,
532			/Windows Mobile/i,
533			/Maemo/i,
534			/PalmSource/i,
535			/SymbianOS/i,
536			/SymbOS/i,
537			/Nokia/i,
538			/MOT-/i,
539			/JDME/i,
540			/Series 60/i,
541			/S60/i,
542			/SonyEricsson/i,
543		];
544		for (i=0, l=smartphones.length; i<l; i++) {
545			if (uas.match(smartphones[i])) {
546				var dev = smartphones[i];
547					dev = String(dev).replace(/\/i/gi,'');
548					dev = String(dev).replace(/\//gi,'');
549				return 'smartphone sdrn-device-'+dev;
550			}
551		}
552		return 'desktop';
553	};
554
555	return this.init();
556};

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.