PageSourceSearch

https://westmontborough.com/_assets_/js/scripts.js

js westmontborough.com collected 2026-09-27 05:08:22 UTC 19,941 bytes, 625 lines download raw bytes

1/*-----------------------------------------------------------------------------------
2
3	Theme Name: Westmont Borough, PA
4	Front-end developer: Abir Hossain
5	Author Design: Ying Liu
6	Author URI: http://www.revize.com/
7	Date: 3/15/2023
8
9-----------------------------------------------------------------------------------*/
10
11(function($) {
12
13	'use strict';
14
15	var $window = $(window),
16		$body = $('body');
17
18	/*!
19	 * IE10 viewport hack for Surface/desktop Windows 8 bug
20	 * Copyright 2014-2015 Twitter, Inc.
21	 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
22	 */
23
24	// See the Getting Started docs for more information:
25	// http://getbootstrap.com/getting-started/#support-ie10-width
26	if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
27		var msViewportStyle = document.createElement('style');
28		msViewportStyle.appendChild(
29			document.createTextNode(
30			  '@-ms-viewport{width:auto!important}'
31			)
32		); document.querySelector('head').appendChild(msViewportStyle);
33	}
34
35	// RZ Class
36	if(typeof RZ !== "undefined"){
37		if(RZ.login){
38			$body.addClass("user-logged-in");
39		} else{
40			$body.addClass("user-not-logged-in");
41		}
42	}
43
44	// Keyboard Navigation: Nav, flyout
45	var isClick = false;
46	$("#nav li a, #flyout  li a, a, button, .toggle, .toggle2").on('focusin', function(e) {
47		if( isClick === false ) {
48			$(".focused").removeClass("focused");
49			$(e.currentTarget).parents("#nav li, #flyout li").addClass("focused");
50			$(".opened:not(.focused) ul:visible,.opened2:not(.focused) ul:visible").slideUp().parent().removeClass("opened opened2");
51		} else {
52			$(".focused").removeClass("focused");
53			isClick = false;
54		}
55	});
56
57	// prevent focused class changes on click - This way arrows wont pop when clicking nav links
58	$("#nav a,#flyout a").on('mousedown',function(){
59		isClick = true;
60	});
61
62	// Search Toggle
63	$('#search-toggle').on('click',function(e){
64		$('#search').stop().slideToggle(200);
65		$(this).toggleClass('fa-search fa-close');
66	});
67
68	$('#search').prepend('<span id="searchtoggle" class="fa fa-search"></span>')
69
70	$('#searchtoggle').click(function(){
71		$('#search form').slideToggle();
72		$(this).toggleClass('fa-search fa-close');
73	})
74
75	// Navigation Toggle
76	$("#nav-toggle").on("click", function(){
77		$("#nav").stop().slideToggle();
78		$(this).toggleClass("fa-bars fa-close");
79	});
80
81	// Menu Arrows and Toggles
82	$("#nav >li>ul,#flyout >li>ul").addClass('first-level');
83	$("#nav  li ul ul").addClass('second-level');
84	$("#nav>li:has(ul)").each(function(){
85		$('<a href="#" class="fa fa-angle-down toggle d-lg-none" tabindex="0" aria-haspopup="true" aria-expanded="false" id="dropdown-toggle-'+$(this).index()+'" aria-label="Show Dropdown for '+ $(this).find('a:first').text() +'"></a>').insertAfter($(this).find('a:first'));
86		$(this).find('ul:first').attr('aria-labelledby', 'dropdown-toggle-'+$(this).index());
87	});
88	$('#nav li ul>li:has(ul)').each(function(index) {
89		$('<a href="#" class="fa fa-angle-down toggle2 d-lg-none" tabindex="0" aria-haspopup="true" aria-expanded="false" id="sub-dropdown-toggle-'+index+'" aria-label="Show Dropdown for '+ $(this).find('a:first').text() +'"></a>').insertAfter($(this).find('a:first'));
90		$(this).find('ul:first').attr('aria-labelledby', 'sub-dropdown-toggle-'+index);
91	});
92	$('#flyout >li:has(ul)').each(function() {
93		$('<a href="#" class="fa fa-angle-down toggle d-lg-none" tabindex="0" aria-haspopup="true" aria-expanded="false" id="flyout-dropdown-toggle-'+$(this).index()+'" aria-label="Show Flyout for '+ $(this).find('a:first').text() +'"></a>').insertAfter($(this).find('a:first'));
94		$(this).find('ul:first').attr('aria-labelledby', 'flyout-dropdown-toggle-'+$(this).index());
95	});
96
97	function addNavClass() {
98		if ($window.width() < 992) {
99			// Insert needed for mobile
100		} else{
101			// Insert needed for desktop
102			$('#nav ul, #flyout ul').css('display', '');
103		}
104
105	}
106	addNavClass();
107	$window.resize(addNavClass);
108
109	$(".toggle").on("click keydown",function(e) {
110		if (e.keyCode === 13 || e.type === 'click') {
111			e.preventDefault();
112			var $parent = $(this).parent();
113			var $parentLi = $parent.parent();
114			$parent.toggleClass('opened');
115			if($parent.addClass('active') && $(this).next('.first-level').is(":visible")){
116				$(this).next('.first-level').slideUp();
117				$parent.removeClass('active');
118				$(this).attr({'aria-expanded': 'false'});
119			} else {
120				$(this).attr({'aria-expanded': 'true'});
121				$(".first-level").slideUp("slow");
122				$parent.addClass('active');
123				$(this).next('.first-level').slideToggle();
124			}
125		}
126	});
127	$(".toggle2").on("click keydown",function(e) {
128		if (e.keyCode === 13 || e.type === 'click') {
129			e.preventDefault();
130			var $parent = $(this).parent();
131			var $parentLi = $parent.parent();
132			$parent.toggleClass('opened2');
133			if($parent.addClass('active') && $(this).next('.second-level').is(":visible")){
134				$(this).next('.second-level').slideUp();
135				$parent.removeClass('active');
136				$(this).attr({'aria-expanded': 'false'});
137			} else {
138				$(this).attr({'aria-expanded': 'true'});
139				$(".second-level").slideUp("slow");
140				$parent.addClass('active');
141				$(this).next('.second-level').slideToggle();
142			}
143		}
144	});
145
146	// close nav if left
147	$(".desktop *").focus(function(e){
148		var $opened = $(".opened");
149		var $opened2 = $(".opened2");
150		if( $opened.length > 0 || $opened2.length > 0 ) {
151			if( $(".opened :focus").length < 1 ){
152				$opened.children("ul").slideUp();
153				$opened.removeClass("opened");
154				$(".opened2").removeClass("opened2");
155			}
156			if( $(".opened2 :focus").length < 1 ){
157				$opened2.children("ul").slideUp();
158				$opened2.removeClass("opened2");
159			}
160		}
161	});
162
163	// search button
164	$('#search-btn').click(function(){
165		$('#search').slideToggle();
166	});
167
168	// Flyout
169	var flyout = $('#flyout'),
170		flyoutwrap = $('#flyout-wrap');
171
172	if (flyout.text().length){
173		flyoutwrap.prepend('<div id="flyout-toggle" class="d-lg-none"><i class="fa fa-bars"></i> Sub Menu</div>');
174	}
175
176	$("#flyout-toggle").on("click", function(){
177		flyout.slideToggle();
178		$(this).toggleClass("active");
179	});
180    
181
182	/*
183	* E-Notify Auto submit
184	*/
185	$.urlParam=function(n){var e=new RegExp("[?&]"+n+"=([^]*)").exec(window.location.href);return null==e?null:e[1]||0};
186	var $enotify = $('iframe[src*="/revize/plugins/notify/notify.jsp"]');
187	if( $enotify.length > 0 ){
188		var emailStr = $.urlParam("email");
189		if( emailStr != null ){
190			$enotify.attr("src", $enotify.attr("src") + "&email=" + emailStr);
191		}
192	}
193
194	// Make sure all calendars have unique ids
195	$('iframe[name="calendar"]').each(function (index, calendar) {
196		calendar.id = 'calendar-' + index;
197	});
198
199	// Start Frame Resizer
200	function resizeIframe(height, frameElement) {
201		if ( frameElement ) {
202			frameElement.height = "";
203			frameElement.height = height;
204		}
205	}
206
207	var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
208	var eventHandler = window[eventMethod];
209	var messageEvent = eventMethod === "attachEvent" ? "onmessage" : "message";
210	eventHandler(messageEvent, function (e) {
211		if ( Array.isArray(e.data) ) {
212			if( e.data[0] === "setCalHeight" || e.data[0] === "setNotifyHeight") {
213				var frames = document.querySelectorAll('iframe');
214				for( var i = 0; i < frames.length; i++ ) {
215					if( frames[i].contentWindow === e.source ){
216						resizeIframe(e.data[1], frames[i]);
217					}
218				}
219			}
220		}
221	});
222	// End Frame Resizer
223
224	// revizeWeather
225	if( typeof $.fn.revizeWeather !== "undefined" ){
226		$.fn.revizeWeather({
227			zip: '60453',
228			city_name: '',
229			unit: 'f',
230			success: function(weather) {
231				var date = new Date();
232				var html ='<span>Current Weather</span>'+'<span class="forecast">'+ '<span>'+weather.forecast+'</span> ' + weather.temp+'&deg;'+'F</span>';
233				html += '<i class="'+weather.icon+'"></i>';
234
235				$("#weather").html(html);
236			},
237			error: function(error) {
238				// better to just hide the secion if there is an error
239				$('.weather').hide();
240				console.log(error);
241			}
242		});
243	}
244
245	// Alert Close Caching
246	if ($("div.alert").length) {
247		var hide = window.sessionStorage && parseInt(window.sessionStorage.getItem("alertClosed")) > 1;
248		if (!hide || $(".user-logged-in").length != 0) {
249			$("div.alert").addClass('show');
250		}
251		$("div.alert button.close").on('click', function(e) {
252			if (window.sessionStorage) {
253				window.sessionStorage.setItem("alertClosed",parseInt(window.sessionStorage.getItem("alertClosed")||0)+1);
254			}
255		});
256	}
257
258	var $translateButton = $('#translate-button');
259	$translateButton.on('keydown click', function(e){
260		if (e.keyCode === 13 || e.type === 'click') {
261			$('#translation-links ul').stop().fadeToggle();
262			$translateButton.attr('aria-expanded', !('true' === $translateButton.attr('aria-expanded')));
263		}
264	});
265
266	$('#translation-links ul').on('mouseleave',function(){
267		$(this).fadeOut();
268		$translateButton.attr('aria-expanded', false);
269	});
270
271	function removeCookieString(value, domain) {
272		domain = domain ? 'domain='+domain+'; ' : '';
273		return value+'; expires=Thu, 01 Jan 1970 00:00:01 GMT; '+domain+'path=/';
274	}
275
276	function unsetGoogtransCookie() {
277		for (var domains = window.location.hostname.split('.'); domains.length >= 2; domains.shift()) {
278			var cookieString = removeCookieString('googtrans=unset', domains.join('.'));
279			document.cookie=cookieString;
280			if	(domains.length === 2) {
281				cookieString = removeCookieString('googtrans=unset', '.'+domains.join('.'));
282				document.cookie=cookieString;
283			}
284		}
285		document.cookie=removeCookieString('googtrans=unset');
286	}
287
288	if (document.cookie.split(';').some(function(item) { return item.trim().startsWith('googtrans=/auto/en'); })) {
289		unsetGoogtransCookie();
290	}
291
292	 // Translate Script
293	var translateURL = "//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit";
294    $.getScript(translateURL);
295    $('#translation-links a').click(function() {
296        var lang = $(this).data('lang');
297        var $frame = $('iframe.skiptranslate');
298        if (lang === 'English') {
299            $frame.contents().find('span.text:contains("English")').parent().parent().get(0).click();
300            return;
301        }
302        if (!$frame.length) {
303            return false;
304        }
305        var $el = $frame.contents().find('span.text:contains(' + lang + ')').parent().parent().get(0).click();
306        console.log($el);
307        if (!$el) {
308            $frame.contents().find('span.text:contains("English")').parent().parent().get(0);
309        }
310        
311        $el.click();
312        return false;
313    });
314
315    
316	// Tiny Slider
317	if (typeof tns !== "undefined") {
318		$('.tiny-slider').each(function(i, el) {
319			tns({
320				autoplay: true,
321				autoplayTimeout: 8000,
322				container: el,
323				items: 1,
324				lazyload: true,
325				lazyloadSelector: '.tns-lazy-img', // accompanied with data src or data-style
326				mode: "gallery",
327				preventScrollOnTouch: 'force',
328                nav: false,
329                controlsText: [
330                    '<img src="_assets_/images/news-arrow-left.png" alt="arrow">',
331                    '<img src="_assets_/images/news-arrow-right.png" alt="arrow">'
332                ],
333                autoplayButtonOutput: false
334			});
335		});
336
337
338		// quicklinks
339		$('#quicklinks .tiny-carousel').each(function(i, el) {
340			var qlinkCount = $('#quicklinks .tiny-item').length;
341			console.log(qlinkCount)
342			var $el = $(el);
343			var tinyItemCount = $el.children().length;
344			var tinyItemData = $el.data('tinyItems') ? $el.data('tinyItems') : 6;
345			tns({
346				container: el,
347				items: Math.min(tinyItemCount, tinyItemData),
348				lazyload: true,
349				lazyloadSelector: '.tns-lazy-img', // accompanied with data src or data-style
350				preventScrollOnTouch: 'force',
351                nav: false,
352				loop:false,
353				speed:500,
354                controlsText: [
355                    '<img src="_assets_/images/news-arrow-left.png" alt="arrow">',
356                    '<img src="_assets_/images/news-arrow-right.png" alt="arrow">'
357                ],
358                autoplayButtonOutput: false,
359                responsive: {
360	
361                    1400 : {
362                        items: (qlinkCount >= 6 ? 6 : qlinkCount)
363                    },
364                    1180 : {
365                        items: (qlinkCount >= 5 ? 5 : qlinkCount)
366                    },
367                    991 : {
368                        items: (qlinkCount >= 4 ? 4 : qlinkCount)
369                    },
370                    767 : {
371                        items: (qlinkCount >= 3 ? 3 : qlinkCount)
372                    },
373                    570 : {
374                        items: (qlinkCount >= 2 ? 2 : qlinkCount)
375                    },
376                    0 : {
377                        items: 1
378                    }
379                }
380			});
381		});
382
383
384		// news
385		$('#news .tiny-carousel').each(function(i, el) {
386			var newsCount = ('#news .news-box').length;
387			var $el = $(el);
388			var tinyItemCount = $el.children().length;
389			var tinyItemData = $el.data('tinyItems') ? $el.data('tinyItems') : 6;
390			var newsSlider = tns({
391				container: el,
392				items: Math.min(tinyItemCount, tinyItemData),
393				lazyload: true,
394				lazyloadSelector: '.tns-lazy-img', // accompanied with data src or data-style
395				preventScrollOnTouch: 'force',
396                nav: true,
397				loop:false,
398				touch:false,
399				speed:500,
400				controlsContainer:'.news-btm .tns-controls',
401                controlsText: [
402                    '<img src="_assets_/images/news-arrow-left.png" alt="arrow">',
403                    '<img src="_assets_/images/news-arrow-right.png" alt="arrow">'
404                ],
405                autoplayButtonOutput: false,
406                responsive: {
407                    1200 : {
408                        items: (newsCount >= 4 ? 4 : newsCount),
409						
410                    },
411                    992 : {
412                        items: (newsCount >= 3 ? 3 : newsCount)
413                    },
414                    768 : {
415                        items: (newsCount >= 2 ? 2 : newsCount)
416                    },
417                    570 : {
418                        items: (newsCount >= 2 ? 2 : newsCount)
419                    },
420                    0 : {
421                        items: 1
422                    }
423                },
424				gutter:13,
425				onInit: function (){
426					$('.news-box-content').addClass('equal');
427					var pagination = $('#news .tns-outer').prepend('<span id="paginationLength">ok</span>');
428				},
429			});
430
431
432			function tnsSliderNav(){
433				var e = $(".tns-outer");
434
435				e.length && e.each(function() {
436					function e(e) {
437						d.css({
438							left: parseInt(e)
439						})
440					}
441					var a = $(this),
442						n = a.find(".tns-nav").find("button"),
443						i = n.first().width(),
444						o = 0,
445						d = a.find(".pagination-line");
446					d.width(i), newsSlider.events.on("transitionEnd", function() {
447						n.each(function() {
448							$(this).hasClass("tns-nav-active") && (o = $(this).position().left)
449						}), e(o)
450					}), n.mouseenter(function() {
451						o = $(this).position().left, setTimeout(function() {
452							e(o)
453						}, 100)
454					}), n.mouseleave(function() {
455						n.each(function() {
456							$(this).hasClass("tns-nav-active") && (o = $(this).position().left)
457						}), setTimeout(function() {
458							e(o)
459						}, 100)
460					})
461				});
462
463				setTimeout(() => {
464					var noticeTNS = '0' + $('#news .tns-nav button:visible').length;
465					var noticeTNSActiveIndex =parseFloat($('#news .tns-nav button.tns-nav-active').attr("data-nav"))+1;
466					$('#paginationLength').html('0'+noticeTNSActiveIndex+'<span class="divider">/</span>'+noticeTNS);
467				}, 5);
468
469
470				if($('#homepage #news .tns-controls').is(':visible')){
471					$('#paginationLength').show();
472				}else{
473					$('#paginationLength').hide();
474				}
475
476			}
477
478			tnsSliderNav();
479			$window.resize(tnsSliderNav);
480			$('#news button[data-controls="prev"]').on('click', tnsSliderNav);
481            $('#news button[data-controls="next"]').on('click', tnsSliderNav);
482			 $('#news .tns-nav button:visible').on('click', tnsSliderNav);
483		});
484	}
485
486	// Responsive Tables
487	$('.post table:not(.layout-table):not(.not-responsive)').wrap('<div class="table-responsive"></div>');
488	$('.layout-table').attr('role', 'presentation');
489
490	$window.ready(function(){
491        
492        // nav mega menu
493        $('#nav').addClass('mega');
494
495
496		// flyout remove underline on hover
497		$(document).ready(function(){
498			$('#flyout li')
499			.mouseover(function(){
500				$(this).addClass('border-color');
501				$(this).prev().addClass('border-color');
502				console.log('ok')
503			})
504			.mouseout(function(){
505				$(this).removeClass('border-color');
506				$(this).prev().removeClass('border-color');
507			})
508		});
509
510		// matchHeight
511		if(typeof $.fn.matchHeight !== "undefined"){
512			$('.equal').matchHeight({
513				//defaults
514				byRow: true,
515				property: 'height', // height or min-height
516				target: null,
517				remove: false
518			});
519		}
520
521		// Video for slider
522		if($('body').attr('id') == 'homepage'){
523			$("#sliderVideo").YTPlayer();
524			$('#wrapper_sliderVideo').css('z-index','1')
525		}
526
527		// hide hero slider control when video will be play
528		var interval = setInterval(hideControl,1000);
529		function hideControl(){
530			var videoId = document.getElementById('wrapper_sliderVideo');
531			if(videoId){
532				if(videoId.style.opacity == '1'){
533				clearInterval(interval);
534				$('#slider>.tns-outer .tns-controls button').hide();
535				}else{
536					$('#slider>.tns-outer .tns-controls button').show();
537				}
538			}
539		}
540		
541
542		// animation text
543			$('.animate1').textyle();
544			$('.animate2').textyle();
545			
546			setTimeout(() => {
547				$('#slider-caption > span').addClass('loaded');
548			}, 1000);
549
550		//#Smooth Scrolling
551		$('a[href*="#"]').not('[href="#"]').not('[href*="#collapse"]').not('.faq-header').click(function(event) {
552			if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
553				var target = $(this.hash);
554				target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
555				if (target.length) {
556					event.preventDefault();
557					$('html,body').animate({
558						scrollTop: target.offset().top-80
559					}, 1000, function() {
560						var $target = $(target);
561						$target.focus();
562					
563					});
564				}
565			}
566		});
567
568		/*global jQuery */
569		/*!
570		* FlexVerticalCenter.js 1.0
571		*
572		* Copyright 2011, Paul Sprangers http://paulsprangers.com
573		* Released under the WTFPL license
574		* http://sam.zoy.org/wtfpl/
575		*
576		* Date: Fri Oct 28 19:12:00 2011 +0100
577		*/
578		$.fn.flexVerticalCenter = function( options ) {
579			var settings = $.extend({
580				cssAttribute:   'margin-top', // the attribute to apply the calculated value to
581				verticalOffset: 0,            // the number of pixels to offset the vertical alignment by
582				parentSelector: null,         // a selector representing the parent to vertically center this element within
583				debounceTimeout: 25,          // a default debounce timeout in milliseconds
584				deferTilWindowLoad: false     // if true, nothing will take effect until the $(window).load event
585			}, options || {});
586
587			return this.each(function(){
588				var $this   = $(this); // store the object
589				var debounce;
590
591				// recalculate the distance to the top of the element to keep it centered
592				var resizer = function () {
593
594					var parentHeight = (settings.parentSelector && $this.parents(settings.parentSelector).length) ?
595						$this.parents(settings.parentSelector).first().height() : $this.parent().height();
596
597					$this.css(
598						settings.cssAttribute, ( ( ( parentHeight - $this.height() ) / 2 ) + parseInt(settings.verticalOffset) )
599					);
600				};
601
602				// Call on resize. Opera debounces their resize by default.
603				$(window).resize(function () {
604					clearTimeout(debounce);
605					debounce = setTimeout(resizer, settings.debounceTimeout);
606				});
607
608				if (!settings.deferTilWindowLoad) {
609					// call it once, immediately.
610					resizer();
611				}
612
613				// Call again to set after window (frames, images, etc) loads.
614				$(window).on('load', function () {
615					resizer();
616				});
617
618			});
619
620		};
621		$('.v-align').flexVerticalCenter();
622
623	}); // Ready
624
625})(jQuery);

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.