PageSourceSearch

https://coalshed-restaurant.co.uk/london/wp-content/themes/the-hideout-theme/js/main.js?ver=1.1

js coalshed-restaurant.co.uk collected 2026-09-26 06:43:45 UTC 54,689 bytes, 1,629 lines download raw bytes

1(function($){
2	
3var iframe,
4	player,
5	videoHeight,
6	videoInit = false,
7	noAnimTimeout,
8	fancyBoxMargin,
9	win = $(window),
10	doc = $(document),
11	wrap = $('#wrap'),
12	body = $('body');
13
14// initialise the scripts when the page is ready
15doc.ready(function(){
16	touchDevices();
17	navigationMenus();
18	restaurantDrawer();
19	signUpDrawer();
20	videos();
21	sliders();
22	accordion();
23	forms();
24	removeTelLinks();
25	closeNotification();
26	contactFormsAjax();
27	deadLinks();
28	scrollToContent();
29	siteSearch();
30	tabs();
31	initVideoHeader();
32	initVideoBlocks();
33	campaignMonitor();
34	mailchimp();
35	gdprCookies();
36	newsPageAjax();
37	eventsPageAjax();
38	initScrollSpeed();
39	svgIcons();
40
41	win.trigger('resize');
42});
43
44// fire scripts on window resize
45win.resize(function(){
46	slidersResize();
47	accordionResize();
48	resizeNoAnim();
49	fancybox();
50	resizeStopScrolling();
51	videoHeaderResize();
52	videoBlocksResize();
53	heroMulti();
54	stickyNav();
55});
56
57win.load(function(){
58	setTimeout(function(){ 
59		$('.page-loader').removeClass('show');
60		$('body').addClass('ready');
61	},300);
62	setTimeout(function(){ 
63		$('.hero-multi').addClass('ready');
64	},500);
65	setTimeout(function(){ 
66		$('.page-loader').remove();
67	},750);
68
69	setTimeout(function(){
70		modalPopup();
71	},850);
72});
73
74$(document).ready(function(){
75	$('.row_gdpr_consent a').attr('target', '_blank');
76});
77
78function svgIcons(){
79	$('.fa-icon').each(function(){
80		// Elements to inject
81		var mySVGsToInject = $(this);
82
83		// Do the injection
84		SVGInjector(mySVGsToInject);
85	});
86}
87
88function touchDevices(){
89    if(is_touch_device()){
90		$('body').addClass('isTouchDevice');
91	} else {
92		$('body').addClass('nonTouchDevice');
93	}
94}
95	
96function is_touch_device() {  
97	return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1);   
98}
99
100// function stickyNav() {
101//     if (win.scrollTop() >= 1) {
102//         $('.header').addClass('sticky-background');
103//         $('.header').addClass('sticky-size');
104//     }
105//     win.scroll(function () {
106//         if (win.scrollTop() >= 1) {
107//             $('.header').addClass('sticky-background');
108//             $('.header').addClass('sticky-size');
109//         } else {
110//             $('.header').removeClass('sticky-background');
111//             $('.header').removeClass('sticky-size');
112//         }
113//     });
114// }
115
116function stickyNav() {
117    win.scroll(function () {
118		if ($(window).scrollTop() === 0) {
119			body.removeClass("scrolling");
120		} else {
121			body.addClass("scrolling");
122		}
123
124		// if (win.scrollTop() >= 1) {
125		// 	$('.header').addClass('sticky-background');
126		// 	$('.header').addClass('sticky-size');
127		// }
128
129		// if (win.scrollTop() >= 1) {
130        //     $('.header').addClass('sticky-background');
131        //     $('.header').addClass('sticky-size');
132        // } else {
133        //     $('.header').removeClass('sticky-background');
134        //     $('.header').removeClass('sticky-size');
135        // }
136
137		if (win.scrollTop() > $('.header.no-promo-banner > .container-fluid').outerHeight()*1) {
138			$('.header').addClass('sticky-fixed');
139		} else {
140			$('.header').removeClass('sticky-fixed');
141		}
142		if (win.scrollTop() > $('.header.no-promo-banner > .container-fluid').outerHeight()*2) {
143			$('.header').addClass('sticky-ready');
144			$('.header').addClass('sticky-background');
145            $('.header').addClass('sticky-size');
146		} else {
147			$('.header').removeClass('sticky-ready');
148			$('.header').removeClass('sticky-background');
149            $('.header').removeClass('sticky-size');
150		}
151		if (win.scrollTop() > $('.header.no-promo-banner > .container-fluid').outerHeight()*3) {
152			$('.header').addClass('sticky');
153		} else {
154			$('.header').removeClass('sticky');
155		}
156
157		if (win.scrollTop() > $('.header.has-promo-banner > .container-fluid').outerHeight()*1+80) {
158			$('.header').addClass('sticky-fixed');
159		} else {
160			$('.header').removeClass('sticky-fixed');
161		}
162		if (win.scrollTop() > $('.header.has-promo-banner > .container-fluid').outerHeight()*2+80) {
163			$('.header').addClass('sticky-ready');
164			$('.header').addClass('sticky-background');
165            $('.header').addClass('sticky-size');
166		} else {
167			$('.header').removeClass('sticky-ready');
168			$('.header').removeClass('sticky-background');
169            $('.header').removeClass('sticky-size');
170		}
171		if (win.scrollTop() > $('.header.has-promo-banner > .container-fluid').outerHeight()*3+80) {
172			$('.header').addClass('sticky');
173		} else {
174			$('.header').removeClass('sticky');
175		}
176    });
177}
178
179function heroMulti() {   
180	sliderHeight = win.height();
181	if ($('.hero-multi--fullscreen')[0] || $('.hero-multi--split')[0]) {
182		$('.hero-multi .slide').css('height',sliderHeight);
183	}
184}
185
186win.load(function(){
187    setTimeout(function(){
188        onScroll();
189        scrollSpeed();
190
191        $(window).on('scroll',function(){
192            onScroll();
193            scrollSpeed();
194        });
195    }, 300);
196})
197
198function onScroll(){
199    $('[data-show]').each(function(){
200        var offset,
201            whentoShow = $(this).data("show-percentage");
202            whentoShowMob = $(this).data("show-percentage-mob");
203
204        if (whentoShowMob) {
205            if(win.width() > 767){
206            	var offset = ($(window).height()/100) * whentoShow;
207            } else {
208            	var offset = ($(window).height()/100) * whentoShowMob;
209            }
210        } else if (whentoShow) {
211            var offset = ($(window).height()/100) * whentoShow;
212        } else {
213            offset = ($(window).height()/100) * 20;
214        }
215
216        if($(this).offset().top < $(window).scrollTop() + $(window).height() - offset){
217            $(this).addClass('scroll-show');
218        }
219    });
220}
221
222function initScrollSpeed(){
223	$('[data-scrollspeed]').each(function(){
224		if(!$(this).hasClass('activated')){
225			$(this).wrapInner('<div class="animate-layer"></div>');
226			$(this).addClass('activated');
227		}
228	});
229}
230
231function scrollSpeed(){
232	windowHeight = win.height();
233	scrollPosition = win.scrollTop();
234	offset = 50;
235
236	$('[data-scrollspeed]').each(function(){
237		element = $(this);
238		animateLayer = element.find('.animate-layer');
239		elementHeight = element.outerHeight();
240		elementTop = element.offset().top;
241		elementBottom = elementTop + elementHeight;
242
243		// calculate if the current element is inside the viewport
244		if(elementTop < windowHeight + scrollPosition + offset && elementBottom > scrollPosition - offset){
245			$(this).addClass('in-view');
246
247			startPoint = elementTop - offset;
248			endPoint = elementBottom + offset;
249			middleOfElement = elementBottom - elementHeight / 2;
250			middleOfViewport = scrollPosition + (windowHeight / 2);
251
252			newPosition = Math.floor((middleOfViewport - middleOfElement) * element.attr('data-scrollspeed'));
253			animateLayer.css('transform','translate3d(0,' + newPosition + 'px,0)');
254		}
255	});
256}
257
258function restaurantDrawer(){
259
260	$('.restaurant-drawer-btn').click(function(){
261		if(!$('.restaurant-drawer').hasClass('show')){
262			$('.restaurant-drawer').addClass('show');
263			body.addClass('show-restaurant-drawer');
264			$('.header').addClass('header-background-change');
265			stopScrolling();
266		} else {
267			$('.restaurant-drawer').removeClass('show');
268			body.removeClass('show-restaurant-drawer');
269			$('.header').removeClass('header-background-change');
270			resumeScrolling();
271		}
272		return false;
273	});
274
275	// // click anywhere in the to close mobile menu
276	$('.restaurant-drawer-overlay').click(function(){
277		body.removeClass('show-restaurant-drawer');
278		$('.restaurant-drawer').removeClass('show');
279		$('.header').removeClass('header-background-change');
280		resumeScrolling();
281	});
282
283	// // click anywhere in the to close mobile menu
284	$('.restaurant-drawer .close-mob-menu-btn').click(function(){
285		body.removeClass('show-restaurant-drawer');
286		body.removeClass('show-mob-menu');
287		$('.restaurant-drawer').removeClass('show');
288		$('.menu-drawer').removeClass('show');
289		$('.header').removeClass('header-background-change');
290		resumeScrolling();
291	});
292}
293
294function navigationMenus(){
295	// append an overlay with a close button for the mobile menu
296	// if($('.header').hasClass('mob-menu-fullscreen')){
297	// 	$('.header').append('<a class="close-menu visible-sm visible-xs"><i class="fal fa-times"></i></a>');
298	// } else if($('.header').hasClass('mob-menu-slidedown')){
299	// 	$('.header').append('<div class="mob-menu-overlay"></div>');
300	// } else {
301	// 	$('.header').append('<div class="mob-menu-overlay"><a class="close-menu"><i class="fal fa-times"></i></div>');
302	// }
303
304	// open mobile menu
305	$('.mob-menu-btn').on('click',function(){
306		if(!$('.menu-drawer').hasClass('show')){
307			$('.menu-drawer').addClass('show');
308			body.addClass('show-mob-menu');
309			body.removeClass('show-restaurant-drawer');
310			$('.header').removeClass('header-background-change');
311			stopScrolling();
312		} else {
313			$('.mob-menu-overlay').trigger('click');
314		}
315		return false;
316	});
317
318	// click anywhere in the to close mobile menu
319	wrap.on('click','.mob-menu-overlay, .close-mob-menu-btn, .menu-drawer .drawer-right',function(){
320		$('.menu-drawer').removeClass('show');
321		body.removeClass('show-mob-menu');
322		// setTimeout(function(){ body.removeClass('raise-mob-overlay'); },300);
323		resumeScrolling();
324	});
325
326	// main navigation with dropdowns
327	$('.main-nav li.menu-item-has-children > a').on('click',function(e){
328		e.preventDefault();
329		if(win.width() > 991) {
330			if(!$(this).hasClass('show')) {
331		        $('.main-nav li.menu-item-has-children > a').removeClass('show');
332		        $(this).addClass('show');
333		    } else {
334	        	$(this).removeClass('show');
335		    }
336		} else {
337			$(this).toggleClass('show');
338	        $(this).next().slideToggle();
339		}
340	});
341
342	doc.on('click', '#wrap', function() {
343		$('.main-nav li.menu-item-has-children > a').removeClass('show');
344	});
345	doc.on('click', '.main-nav', function (e) {
346		e.stopPropagation();
347	});
348}
349
350function signUpDrawer(){
351
352	$('a[data-link="signup"]').click(function(){
353		if(!$('.sign-up-drawer').hasClass('show')){
354			$('.sign-up-drawer').addClass('show');
355			body.addClass('show-sign-up-drawer');
356			stopScrolling();
357			// Force reflow after a short delay
358	        setTimeout(function () {
359	            window.dispatchEvent(new Event('resize'));
360	            stopScrolling();
361	        }, 450);
362		} else {
363			$('.sign-up-drawer').removeClass('show');
364			body.removeClass('show-sign-up-drawer');
365			resumeScrolling();
366		}
367		return false;
368	});
369
370	// // click anywhere in the to close mobile menu
371	$('.sign-up-drawer-overlay').click(function(){
372		body.removeClass('show-sign-up-drawer');
373		$('.sign-up-drawer').removeClass('show');
374		resumeScrolling();
375	});
376}
377
378function scrollToContent(){
379	$('.scroll-down-link').on('click',function(){
380        $('html, body').animate({
381            scrollTop: $('.hero + div, .hero-multi + .main-body').offset().top
382        }, 600);
383    });
384}
385
386function siteSearch(){
387	wrap.append('<div class="site-search-overlay"></div>');
388
389    $('.search-btn').on('click', function () {
390        if (!$('.site-search').hasClass('show')) {
391            $('.site-search').addClass('show');
392            setTimeout(function() { $('.search-input').focus() }, 500);
393            body.addClass('show-site-search raise-search-overlay');
394            stopScrolling();
395        }
396        return false;
397    });
398
399    $('.close-search').on('click', function () {
400    	$('.site-search-overlay').trigger('click');
401    });
402
403    // click anywhere in the to close mobile menu
404    wrap.on('click', '.site-search-overlay', function () {
405        $('.site-search').removeClass('show');
406        body.removeClass('show-site-search');
407        setTimeout(function () {
408            body.removeClass('show-site-search raise-search-overlay');
409        }, 300);
410        resumeScrolling();
411    });
412}
413
414function sliders(){
415	createSlider('.home-slider', true, true, false, false);
416	createSlider('.masthead-slider', true, true, false, false);
417	createSlider('.widget-slider', false, false, false, false);
418	createSlider('.variable-slider', false, false, true, true);
419	// createSlider('.quote-slider', true, true, false, false);
420
421	$('.widget-slider').on('afterChange', function(event, slick, currentSlide, nextSlide){
422		var current = currentSlide + 1;
423		$('.slide-counter .current').text(current);
424	});
425
426	$('.restaurants-slider').slick({
427		appendArrows: $('.restaurant-drawer .arrow-wrap'),
428		prevArrow: '<a class="slick-btn slick-prev"></a>',
429		nextArrow: '<a class="slick-btn slick-next"></a>',
430		accessibility: false,
431		autoplay: false,
432		dots: false,
433		arrows: true,
434		infinite: false,
435		pauseOnHover: false,
436		slidesToShow: 2,
437		slidesToScroll: 1,
438		responsive: [
439		{
440		  breakpoint: 767,
441		  settings: "unslick"
442		},
443		]
444	});
445
446	$('.quote-slider').slick({
447		prevArrow: '<a class="slick-btn slick-prev"></a>',
448		nextArrow: '<a class="slick-btn slick-next"></a>',
449    	accessibility: false,
450    	autoplay: true,
451		dots: $('.quote-slider').data('dots'),
452		arrows: $('.quote-slider').data('arrows'),
453		fade: true,
454		speed: 800,
455		autoplaySpeed: $('.quote-slider').data('autoplay-speed'),
456		pauseOnHover: false,
457		centerMode: false,
458		variableWidth: false
459	});
460}
461
462function createSlider(selector, autoPlayValue, fadeValue, centerMode, variableWidth){
463	slider = $(selector);
464	slider.slick({
465		prevArrow: '<a class="slick-btn slick-prev"></a>',
466		nextArrow: '<a class="slick-btn slick-next"></a>',
467    	accessibility: false,
468    	autoplay: autoPlayValue,
469		dots: slider.data('dots'),
470		arrows: slider.data('arrows'),
471		fade: fadeValue,
472		speed: 800,
473		autoplaySpeed: 5000,
474		pauseOnHover: false,
475		centerMode: centerMode,
476		variableWidth: variableWidth
477	});
478}
479
480function slidersResize() {
481    if (!(body.hasClass('raise-mob-overlay') || $('.modalPop').hasClass('raise-modal'))) {
482        $('[data-slider-type="window-height"]').each(function(){
483            if(win.width() > 767){
484                offset = $(this).attr('data-window-height-offset') ? $(this).attr('data-window-height-offset') : 0;
485                minHeight = $(this).attr('data-min-height');
486            } else {
487                offset = $(this).attr('data-window-height-offset-mobile') ? $(this).attr('data-window-height-offset-mobile') : 0;
488                minHeight = $(this).attr('data-min-height-mobile');
489            }
490            sliderHeight = win.height() - $(this).offset().top - offset;
491            if(sliderHeight < minHeight){
492                $(this).find('.slick-slide').css('height',minHeight);
493            } else {
494                $(this).find('.slick-slide').css('height',sliderHeight);
495            }
496        });
497    }
498}
499
500function resizeNoAnim(){
501	if(!body.hasClass('show-mob-menu')){
502		body.addClass('no-anim');
503		clearTimeout(noAnimTimeout);
504		noAnimTimeout = setTimeout(function(){
505			body.removeClass('no-anim');
506		},150);
507	}
508}
509
510function forms(){
511	if ($('.date-picker')[0]) {
512		$(".date-picker").datepicker({dateFormat: "dd/mm/yy",changeYear: true,yearRange: "-100:+100"});
513	}
514	$('.contact-widget, .newsletter-widget').on('change focus blur keyup keydown', 'input[type="text"], input[type="email"], input[type="number"], input[type="tel"], input[type="password"], textarea', function(){
515		thisInput = $(this);
516		if(thisInput.val() && thisInput.val() !== thisInput.attr('placeholder')){
517			thisInput.closest('.border-input').addClass('filled');
518		} else {
519			thisInput.closest('.border-input').removeClass('filled');
520		}
521	});
522	$('.contact-widget').on('change', 'select', function(){
523		thisSelect = $(this);
524		if(thisSelect.find('option:selected').val() === ''){
525			thisSelect.closest('.border-input').removeClass('filled');
526		} else {
527			thisSelect.closest('.border-input').addClass('filled');
528		}
529	});
530	$('.file-upload').on('change','input',function(){
531		rawVal = $(this).val();
532		if(rawVal.indexOf('\\') > -1){
533			newVal = rawVal.split('\\');
534			finalVal = newVal[newVal.length-1];
535		} else {
536			finalVal = rawVal;
537		}
538		$(this).parent().addClass('filled').find('.fake-input').text(finalVal);
539	});
540
541	$('.file-upload').on('click','.remove',function(){
542		$(this).parent().removeClass('filled').find('input').val('').parent().find('.fake-input').text('Upload file...');
543	});
544}
545
546function videos(){
547	doc.on('click','.play-video',function(){
548		thisVideoURL = $(this).attr('data-videourl');
549		$(this).closest('.video-container').append('<iframe src="'+thisVideoURL+'" allowfullscreen></iframe>');
550	});
551}
552
553function accordion(){
554	$('.accordion-content').css('height','0');
555	$('.accordion-group.active').each(function(){
556		$(this).find('.accordion-content').css('height',$(this).find('.accordion-content-inner').outerHeight());
557	});
558	$('.accordion').on('click','.accordion-btn',function(){
559		thisAccordion = $(this).closest('.accordion');
560		thisGroup = $(this).closest('.accordion-group');
561		if(thisGroup.hasClass('active')){
562			thisGroup.removeClass('active').find('.accordion-content').css('height','0');
563		} else {
564			thisAccordion.find('.active').removeClass('active').find('.accordion-content').css('height','0');
565			thisGroup.addClass('active').find('.accordion-content').css('height',thisGroup.find('.accordion-content-inner').outerHeight());
566		}
567	});
568}
569
570function accordionResize(){
571	$('.accordion-group.active').each(function(){
572		$(this).find('.accordion-content').css('height',$(this).find('.accordion-content-inner').outerHeight());
573	});
574}
575
576function changeTabContent(ThisBlock, thisTab) {
577	$(ThisBlock).parents('.tabs-container').find('.tabs-content > div[data-tab="'+thisTab+'"]').addClass('active');
578}
579
580function tabs(){
581	$('.tabs').on('click','a[data-tab]',function(){
582	    $(this).parent().find('.active').removeClass('active');
583	    $(this).parent().next().find('.active').removeClass('active');
584	    $(this).addClass('active');
585	    var thisTab = $(this).attr('data-tab');
586
587	    // Change the tab content
588	    changeTabContent(this, thisTab);
589
590	    // Store the index of the selected tab button
591	    var selectedIndex = $(this).index();
592
593	    // Apply to tabs
594	    $(this).parent().prev().find('select option').eq(selectedIndex).prop('selected', true);
595	});
596	$('.tabs-mobile > select').on('change', function() {
597	 	$(this).parent().next().next().find('.active').removeClass('active');
598	    var thisMobTab = this.value;
599
600		// Change the tab content
601	    changeTabContent(this, thisMobTab);
602	    
603	    // Get the index of the selected option
604	    var selectedOption = this.selectedIndex;
605
606	    // Apply to tabs
607	    $(this).parent().next().find('a').removeClass('active').eq(selectedOption).addClass('active');
608	});
609}
610
611function removeTelLinks(){
612	if(!Modernizr.inputtypes.tel){
613		$('a[href^=tel]').each(function(){
614			$(this).removeAttr('href').addClass('no-cursor');
615		})
616	}
617}
618
619function fancybox() {
620	$('[data-fancybox]').fancybox({
621		loop: true,
622		idleTime: false,
623		animationEffect: "fade",
624		animationDuration: 600,
625		buttons: [
626		    "close"
627		],
628		baseTpl:
629		    '<div class="fancybox-container" role="dialog" tabindex="-1">' +
630		    '<div class="fancybox-bg"></div>' +
631		    '<div class="fancybox-inner">' +
632		    '<div class="fancybox-infobar">Image <span data-fancybox-index></span> of <span data-fancybox-count></span></div>' +
633		    '<div class="fancybox-toolbar">{{buttons}}</div>' +
634		    '<div class="fancybox-navigation">{{arrows}}</div>' +
635		    '<div class="fancybox-stage"></div>' +
636		    '<div class="fancybox-caption"><div class=""fancybox-caption__body"></div></div>' +
637		    '</div>' +
638		    '</div>',
639		btnTpl: {
640		    close:
641		      '<button data-fancybox-close class="fancybox-button fancybox-button--close" title="{{CLOSE}}">' +
642		      '<i class="fal fa-times"></i>' +
643		      "</button>",
644
645		    arrowLeft:
646		      '<button data-fancybox-prev class="fancybox-button fancybox-button--arrow_left" title="{{PREV}}">' +
647		      '<div><i class="fal fa-arrow-left"></i></div>' +
648		      "</button>",
649
650		    arrowRight:
651		      '<button data-fancybox-next class="fancybox-button fancybox-button--arrow_right" title="{{NEXT}}">' +
652		      '<div><i class="fal fa-arrow-right"></i></div>' +
653		      "</button>"
654		},
655	});
656}
657
658var normalw = window.innerWidth;
659	scrollw = normalw - body.width();
660
661function stopScrolling(){
662	$('html,body').addClass('stop-scrolling');
663	$('body.stop-scrolling').css('margin-right', scrollw);
664    if(body.hasClass('isTouchDevice')){
665	    curScrollPos = win.scrollTop();
666	    wrap.addClass('no-anim-single');
667	    wrap.attr('style','width:'+win.width()+'px; margin-top:-'+curScrollPos+'px;min-height:'+win.height()+'px; position:fixed;');
668	    oldScrollPos = curScrollPos;
669	    setTimeout(function(){ win.trigger('scroll'); },300);
670	}
671}
672
673function resumeScrolling(){
674    if(body.hasClass('stop-scrolling')){
675    	$('html,body').removeClass('stop-scrolling');
676    	$('body').css('margin-right','0');
677    	if(body.hasClass('isTouchDevice')){
678    		wrap.attr('style','');
679    		win.scrollTop(oldScrollPos);
680    	}
681    }
682}
683
684function resizeStopScrolling(){
685	if(body.hasClass('stop-scrolling')){
686		if(body.hasClass('isTouchDevice')){
687			wrap.css('width',win.width());
688		}
689		if(win.width() > 991){
690			resumeScrolling();
691			$('.mob-menu-overlay').click();
692			$('.main-nav li.menu-item-has-children > a').removeClass('show');
693		}
694	}
695	if(win.width() < 992){
696		$('.main-nav li.menu-item-has-children > a').removeClass('show');
697		$('.main-nav li.menu-item-has-children > a + ul').css('display','');
698	}
699}
700
701function validateEmail(email) {
702  var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
703  return re.test(email);
704}
705
706function validatePhone(phone) {
707  var re = /^(?:(?:\(?(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?(?:\(?0\)?[\s-]?)?)|(?:\(?0))(?:(?:\d{5}\)?[\s-]?\d{4,5})|(?:\d{4}\)?[\s-]?(?:\d{5}|\d{3}[\s-]?\d{3}))|(?:\d{3}\)?[\s-]?\d{3}[\s-]?\d{3,4})|(?:\d{2}\)?[\s-]?\d{4}[\s-]?\d{4}))(?:[\s-]?(?:x|ext\.?|\#)\d{3,4})?$/; 
708  return re.test(phone);
709}
710
711function validateUploadExt(file) {
712    var ext = file.match(/\.([^\.]+)$/);
713    if (ext !== null) {
714        switch (ext[1].toLowerCase()) {
715            case 'jpg':
716            case 'png':
717            case 'pdf':
718            case 'xls':
719            case 'xlsx':
720            case 'doc':
721            case 'docx':
722                return true;
723                break;
724        }
725    }
726
727    return false;
728}
729
730function validateUploadSize(input) {
731    // Limit 2 mb
732    if (input[0].files[0].size > 2097152) {
733        return false;
734    }
735    return true;
736}
737
738function validationElement(thisFieldContainer) {	
739	thisFieldType = thisFieldContainer.attr('data-fieldtype');
740	
741	if(thisFieldContainer.data("required") === "") {
742		thisFieldValid = '';
743	
744		if(thisFieldType === 'tf'){
745			if(thisFieldContainer.find('input').val() === '' || thisFieldContainer.find('input').val() === thisFieldContainer.find('input').attr('placeholder')) {
746				thisFieldValid = 'false';
747			} else {
748				if(thisFieldContainer.find('input').attr('type') == "email" && !validateEmail(thisFieldContainer.find('input').val())) {
749					thisFieldValid = 'email-false';
750				}
751			}
752		}
753
754		// Check File Uploads
755        if (thisFieldType === 'fu') {
756            if (thisFieldContainer.find('input').val() === '' || thisFieldContainer.find('input').val() === thisFieldContainer.find('input').attr('placeholder')) {
757                thisFieldValid = 'false';
758
759            } else if (!validateUploadExt(thisFieldContainer.find('input').val())) {
760                thisFieldValid = 'file-ext';
761
762            } else if (!validateUploadSize(thisFieldContainer.find('input'))) {
763                thisFieldValid = 'file-size';
764            }
765        }
766
767		if(thisFieldType === 'ta' && (thisFieldContainer.find('textarea').val() === '' || thisFieldContainer.find('textarea').val() === thisFieldContainer.find('textarea').attr('placeholder'))){
768			thisFieldValid = 'false';
769		}
770		if(thisFieldType === 'dp' && (thisFieldContainer.find('input').val() === '' || thisFieldContainer.find('input').val() === thisFieldContainer.find('input').attr('placeholder'))){
771			thisFieldValid = 'false';
772		}
773		if(thisFieldType === 'cb' && thisFieldContainer.find('input:checked').size() < 1){
774			thisFieldValid = 'false';
775		}
776		if(thisFieldType === 'rb' && thisFieldContainer.find('input:checked').size() < 1){
777			thisFieldValid = 'false';
778		}
779		if(thisFieldType === 'dd' && thisFieldContainer.find('select option:selected').attr('value') === '0'){
780			thisFieldValid = 'false';
781		}
782		
783		if(thisFieldValid === ''){
784			sendForm = true;
785			
786			thisFieldContainer.find('.error-tooltip').removeClass('show');
787			thisFieldContainer.children(".warning").removeClass('show');
788			
789		} else {
790			sendForm = false;
791			
792			thisFieldContainer.find('.error-tooltip').addClass('show');
793			
794			if(thisFieldValid === 'email-false') {
795				thisFieldContainer.children(".warning").addClass('show').html("You have entered an invalid email address");
796				
797			} else if(thisFieldValid === 'phone-false') {
798				thisFieldContainer.children(".warning").addClass('show').html("You have entered an invalid phone number");
799				
800			} else if (thisFieldValid === 'file-ext') {
801                thisFieldContainer.children(".warning").addClass('show').html("This file format is not supported");
802
803            } else if (thisFieldValid === 'file-size') {
804                thisFieldContainer.children(".warning").addClass('show').html("The maximum file size is 2mb");
805
806            } else {
807				thisFieldContainer.children(".warning").addClass('show').html("This is a required field");					
808			}
809		}
810	} else if(thisFieldContainer.data("required") !== "" && thisFieldContainer.find('input').attr('type') == "email") {
811		if(thisFieldContainer.find('input').val() == "" || thisFieldContainer.find('input').val() === thisFieldContainer.find('input').attr('placeholder')) {
812			thisFieldContainer.children(".warning").removeClass('show');
813			thisFieldContainer.find('.error-tooltip').removeClass('show');
814			sendForm = true;
815
816		} else {
817			if(!validateEmail(thisFieldContainer.find('input').val())) {
818				thisFieldContainer.children(".warning").addClass('show').html("You have entered an invalid email address");
819				thisFieldContainer.find('.error-tooltip').addClass('show');
820				sendForm = false;
821			} else {
822				thisFieldContainer.children(".warning").removeClass('show');
823				thisFieldContainer.find('.error-tooltip').removeClass('show');
824				sendForm = true;
825			}
826		}
827		
828	} else if(thisFieldContainer.data("required") !== "" && thisFieldContainer.find('input').attr('type') == "tel") {
829		if(thisFieldContainer.find('input').val() === "" || thisFieldContainer.find('input').val() === thisFieldContainer.find('input').attr('placeholder')) {
830			thisFieldContainer.children(".warning").removeClass('show');
831			thisFieldContainer.find('.error-tooltip').removeClass('show');
832			sendForm = true;
833
834		} else {
835			if(!validatePhone(thisFieldContainer.find('input').val())) {
836				thisFieldContainer.children(".warning").addClass('show').html("You have entered an invalid phone number");
837				thisFieldContainer.find('.error-tooltip').addClass('show');
838				sendForm = false;
839			} else {
840				thisFieldContainer.children(".warning").removeClass('show');
841				thisFieldContainer.find('.error-tooltip').removeClass('show');
842				sendForm = true;
843			}
844		}
845
846	 	// Check File Uploads, if field not required
847    } else if (thisFieldContainer.data("required") !== "" && thisFieldContainer.find('input').attr('type') == "file") {
848        if (thisFieldContainer.find('input').val() && !validateUploadExt(thisFieldContainer.find('input').val())) {
849            thisFieldContainer.children(".warning").addClass('show').html("This file format is not supported");
850            thisFieldContainer.find('.error-tooltip').addClass('show');
851            sendForm = false;
852        } else if (thisFieldContainer.find('input').val() && !validateUploadSize(thisFieldContainer.find('input'))) {
853            thisFieldContainer.children(".warning").addClass('show').html("The maximum file size is 2mb");
854            thisFieldContainer.find('.error-tooltip').addClass('show');
855            sendForm = false;
856        } else {
857            thisFieldContainer.children(".warning").removeClass('show');
858            thisFieldContainer.find('.error-tooltip').removeClass('show');
859            sendForm = true;
860        }
861    } else {
862		sendForm = true;
863	}
864	
865	return sendForm;
866}
867
868function contactFormsAjax() {
869	$('[data-required]').each(function(){
870		$(this).append('<span class="error-tooltip"><i class="fal fa-times"></i></span>');
871	});
872	
873	$('.contact-widget input, .contact-widget textarea, .contact-widget select').change(function() {
874		thisFieldContainer = $(this).parents(".form-group");
875		validationElement(thisFieldContainer);
876	});
877
878	$('.contact-widget').on('submit','form',function(e){
879		e.preventDefault();
880		// first do some validation to check required fields are filled
881		var successMessage = $(this).children('span[data-success]').data('success'),
882            sendFormArray = new Array(),
883            thisForm = $(this),
884            counter = 0;
885
886		thisForm.find('.form-group').each(function(){
887			thisFieldContainer = $(this);
888			validationElement(thisFieldContainer);
889			sendFormArray.push(validationElement(thisFieldContainer));
890		});		
891		
892		if(sendFormArray.indexOf(false) === -1){
893			thisForm.find(".warning").remove();
894			thisForm.addClass('contact-widget-sending');
895
896			// converts form into a js array of name => value objects
897			formData = thisForm.serializeArray();
898			console.log(formData);
899
900			// do some tidying up to merge checkbox dupes, i.e. checkbox=one,checkbox=two,checkbox=three > checkbox=one,two,three
901			var curName, prevName;
902			for(i = 0; i < formData.length; i++) {
903				curName = formData[i].name;
904				if(curName === prevName){
905					formData[i].value = formData[i - 1].value + ', ' + formData[i].value;
906				}
907				prevName = formData[i].name;
908			}
909			for(i = 0; i < formData.length;i++) {
910				curName = formData[i].name;
911				if(curName === prevName){
912					formData.splice(i - 1, 1);
913					i = -1; continue;
914				}
915				prevName = formData[i].name;
916			}
917
918			var data = new FormData(this);
919            data.append("action", "submitformsfunction");
920
921            // merged values rewrite old values
922            for (i = 0; i < formData.length; i++) {
923                data.append(formData[i].name, formData[i].value);
924            }
925			
926			$.ajax({
927				type: "POST",
928                url: $('body').attr('data-siteurl') + "/wp-admin/admin-ajax.php",
929                data: data,
930                cache: true,
931                dataType: 'json',
932                processData: false, // Don't process the files
933                contentType: false, // Set content type to false as jQuery will tell the server its a query string request
934				success: function(results){
935					thisForm.closest('.contact-widget .contact-wrap').wrap('<div class="form-complete form-complete-new" disabled="disabled"></div>');
936					thisForm.removeClass('contact-widget-sending');
937					setTimeout(function(){
938						$('.contact-widget .contact-wrap').css('opacity','0.05');
939					},50);
940					setTimeout(function(){
941						$('.contact-widget .form-complete-new').parent().append('<div class="success-message">' + successMessage + '</div>');
942						$('.contact-widget .success-message').fadeIn();
943					},300);
944					setTimeout(function(){
945						successMsg = $('.contact-widget .success-message');
946						scrollToPos = successMsg.offset().top - ($(window).height() / 2) + (successMsg.outerHeight() / 2);
947						$("html, body").animate({ scrollTop: scrollToPos });
948						$('.form-complete-new').removeClass('form-complete-new');
949					},450);
950				}
951			});
952
953		} else {
954			doNotification("Please fix the errors indicated");	
955		}
956	});
957}
958
959function slugify(text) {
960    // we make the same preparations like in php function (contact_form.php)
961    return text.toString().toLowerCase().replace(/\s+/g, '_').replace(/\./g, '');
962}
963
964var notificationActive = false,
965	notificationTimeout,
966	closeNotificationTimeout,
967	removeNotificationTimeout,
968	notification = $('.notification');
969
970function doNotification(text){
971	if(!notificationActive){
972		notificationActive = true;
973		$('body').append('<div class="notification"><p>'+text+'</p></div>');
974
975		setTimeout(function(){ 
976			$('.notification').addClass('show'); 
977		}, 50);
978
979		closeNotificationTimeout = setTimeout(function(){ 
980			$('.notification').removeClass('show'); 
981		}, 4000);
982
983		removeNotificationTimeout = setTimeout(function(){ 
984			$('.notification').remove(); 
985			notificationActive = false; 
986		}, 4400);
987
988	}
989}
990
991function closeNotification() {
992	doc.on('click', '.notification', function() {
993		var thisNotification = $('.notification');
994		thisNotification.removeClass('show');
995		clearTimeout(notificationTimeout);
996		clearTimeout(closeNotificationTimeout);
997		clearTimeout(removeNotificationTimeout);
998		notificationTimeout = setTimeout(function(){
999			thisNotification.remove();
1000			notificationActive = false;
1001		}, 200);
1002	});
1003}
1004
1005function campaignMonitor() {
1006    $('#signupForm input').change(function () {
1007        validationElement($(this).parents(".form-group"));
1008    });
1009    $('#signupForm').submit(function (e) {
1010        e.preventDefault();
1011
1012        var successMessage = $(this).children('span[data-success]').data('success'),
1013            sendFormArray = new Array(),
1014            thisForm = $(this);
1015
1016        thisForm.find('.form-group').each(function () {
1017            var thisFieldContainer = $(this);
1018            validationElement(thisFieldContainer);
1019            sendFormArray.push(validationElement(thisFieldContainer));
1020        });
1021
1022        if (sendFormArray.indexOf(false) === -1) {
1023            thisForm.find(".warning").removeClass('show');
1024            thisForm.find(".error-tooltip").removeClass('show');
1025            thisForm.addClass('newsletter-widget-sending');
1026
1027            var data = new FormData(this);
1028            data.append("action", "signupformfunction");
1029
1030            $.ajax({
1031                type: "POST",
1032                url: $('body').attr('data-siteurl') + "/wp-admin/admin-ajax.php",
1033                data: data,
1034                cache: true,
1035                dataType: 'json',
1036                processData: false, // Don't process the files
1037                contentType: false, // Set content type to false as $ will tell the server its a query string request
1038                success: function (results) {
1039                    if (results.error) {
1040                        //alert("Error: " + data.Message);
1041                        var message = results.message;
1042                        doNotification("Please fix the errors indicated");
1043                    } else { // 200
1044                        thisForm.find(".warning").removeClass('show');
1045                        $('#signupForm').parent().addClass("form-complete form-complete-new");
1046                        setTimeout(function () {
1047                            $('#signupForm').css('opacity', '0.05');
1048                        }, 50);
1049                        setTimeout(function () {
1050                            $('.newsletter-widget .form-complete-new').append('<div class="success-message">' + successMessage + '</div>');
1051                            $('.newsletter-widget .success-message').fadeIn();
1052                        }, 300);
1053                        setTimeout(function () {
1054                            successMsg = $('.newsletter-widget .success-message');
1055                            scrollToPos = successMsg.offset().top - ($(window).height() / 2) + (successMsg.outerHeight() / 2);
1056							$("html, body").animate({ scrollTop: scrollToPos });
1057                            thisForm.find('.form-complete-new').removeClass('form-complete-new');
1058                        }, 450);
1059                    }
1060                }
1061            });
1062        } else {
1063            doNotification("Please fix the errors indicated");
1064        }
1065    });
1066}
1067
1068function mailchimp() {
1069    $('#mc-embedded-subscribe-form input').change(function () {
1070        thisFieldContainer = $(this).parents(".form-group");
1071        validationElement(thisFieldContainer);
1072    });
1073
1074    $('#mc-embedded-subscribe-form').submit(function (e) {
1075        e.preventDefault();
1076
1077        var errorNotification = 'Please fix the errors indicated',
1078            sendFormArray = new Array(),
1079            thisForm = $(this),
1080            formData = {};
1081
1082        thisForm.find('.form-group').each(function () {
1083            thisFieldContainer = $(this);
1084            sendFormArray.push(validationElement(thisFieldContainer));
1085        });
1086
1087		thisForm.find('.form-group[mailchimp-notice]').children(".warning").removeClass('show');
1088
1089        if (sendFormArray.indexOf(false) === -1) {
1090
1091            //Prevent double click
1092            thisForm.find('button[type="submit"]').attr('disabled', 'disabled');
1093
1094            var formSerializeArray = thisForm.serializeArray(),
1095                successMessage = $(this).children('span[data-success]').data('success')
1096
1097            $.map(formSerializeArray, function (n) {
1098                formData[n['name']] = n['value'];
1099            });
1100
1101            formData['action'] = 'mailchimp';
1102
1103            $.ajax({
1104                type: "POST",
1105                url: $('body').attr('data-siteurl') + "/wp-admin/admin-ajax.php",
1106                cache: true,
1107                dataType: 'json',
1108                data: formData,
1109                success: function (data) {
1110                    if (data.result === 'success') {
1111                        thisForm.find(".warning").removeClass('show');
1112                        $('#mc-embedded-subscribe-form').parent().addClass("form-complete form-complete-new");
1113                        setTimeout(function () {
1114                            $('#mc-embedded-subscribe-form').css('opacity', '0.05');
1115                        }, 50);
1116                        setTimeout(function () {
1117                            $('.newsletter-widget .form-complete-new').append('<div class="success-message">' + successMessage + '</div>');
1118                            $('.newsletter-widget .success-message').fadeIn();
1119                        }, 300);
1120                        setTimeout(function () {
1121                            successMsg = $('.newsletter-widget .success-message');
1122                            scrollToPos = successMsg.offset().top - ($(window).height() / 2) + (successMsg.outerHeight() / 2);
1123							$("html, body").animate({ scrollTop: scrollToPos });
1124                            thisForm.find('.form-complete-new').removeClass('form-complete-new');
1125                        }, 450);
1126                    } else {
1127                        thisForm.find('.form-group[mailchimp-notice]').children(".warning").addClass('show').html(data.msg);
1128                        doNotification(errorNotification);
1129                    }
1130                    thisForm.find('button[type="submit"]').removeAttr('disabled');
1131                },
1132                error: function (data) {
1133                    thisForm.find('.form-group[mailchimp-notice]').children(".warning").addClass('show').html('An error occurred while submitting the form. Please contact the site administrator.');
1134                    thisForm.find('button[type="submit"]').removeAttr('disabled');
1135                    doNotification(errorNotification);
1136                }
1137            });
1138
1139        } else {
1140            doNotification(errorNotification);
1141        }
1142    });
1143}
1144
1145function deadLinks() {
1146	$("a[href=''],a[href='#']").click(function(e) {
1147		e.preventDefault();
1148	});
1149}
1150
1151function initVideoHeader(){
1152	if ($('.video-mask--header')[0]) {
1153        iframe = $('.video-mask--header iframe');
1154        player = new Vimeo.Player(iframe);
1155
1156        player.ready().then(function() {
1157			setTimeout(function() {
1158				iframe.parents().find('.img').addClass('video-ready');
1159			}, 1500);
1160		});
1161
1162		win.resize(function(){
1163	        if(win.width() > 767){
1164	        	player.play();
1165			} else {
1166				if($('.video-mask--header').hasClass('mobile-hide')) {
1167					player.pause();
1168				}
1169			}
1170		});
1171	}
1172}
1173
1174function videoHeaderResize(){
1175	if ($('.video-mask--header')[0]) {
1176		var videoID = $(".video-mask--header").attr("data-video-id");
1177		var videoURL = "https://vimeo.com/api/oembed.json?url=https%3A//vimeo.com/" + videoID;
1178		$.get( videoURL, function(data) {
1179		
1180		    // Storing the return data from AJAX call into variable
1181		    var iframeData = data;
1182		    startingWidth = iframeData.width;
1183		    startingHeight = iframeData.height;
1184
1185			startingRatio = startingWidth/startingHeight;
1186			boxWidth = $('.video-mask--header').outerWidth(true);
1187			boxHeight = $('.video-mask--header').outerHeight(true);
1188			formula = boxWidth / boxHeight;
1189			videoHeight = win.height();
1190
1191			if(formula > startingRatio){
1192				iframe.css('width','auto').css('height','9999px');
1193			} else {
1194				iframe.css('height','auto').css('width','9999px');
1195			}
1196		});
1197	}
1198}
1199
1200function initVideoBlocks(){
1201	if ($('.video-mask--block')[0]) {
1202        $('.video-mask--block').each(function(){
1203        	var thisVideo = $(this);
1204        	var iframe = thisVideo.children('iframe');
1205	        var player = new Vimeo.Player(iframe);
1206
1207	        win.resize(function(){
1208		        if(win.width() > 767){
1209		        	player.play();
1210				} else {
1211					if(thisVideo.hasClass('mobile-hide')) {
1212						player.pause();
1213					}
1214				}
1215			});
1216		});
1217	}
1218}
1219
1220function videoBlocksResize(){
1221	if ($('.video-mask--block')[0]) {
1222		$('.video-mask--block').each(function(){
1223			var thisVideo = $(this);
1224			var thisIframe = thisVideo.children('iframe');
1225			var videoID = thisVideo.attr("data-video-id");
1226			var videoURL = "https://vimeo.com/api/oembed.json?url=https%3A//vimeo.com/" + videoID;
1227			$.get( videoURL, function(data) {
1228		
1229			    // Storing the return data from AJAX call into variable
1230			    var iframeData = data;
1231			    startingWidth = iframeData.width;
1232			    startingHeight = iframeData.height;
1233
1234				startingRatio = startingWidth/startingHeight;
1235				boxWidth = thisVideo.outerWidth(true);
1236				boxHeight = thisVideo.outerHeight(true);
1237				formula = boxWidth / boxHeight;
1238				videoHeight = win.height();
1239
1240				if(formula > startingRatio){
1241					thisIframe.css('width','auto').css('height','9999px');
1242				} else {
1243					thisIframe.css('height','auto').css('width','9999px');
1244				}
1245			});
1246		});
1247	}
1248}
1249
1250function getCookie(name) {
1251    var cookie = document.cookie;
1252    var prefix = name + "=";
1253    var begin = cookie.indexOf("; " + prefix);
1254    if (begin == -1) {
1255        begin = cookie.indexOf(prefix);
1256        if (begin != 0) return null;
1257    } else {
1258        begin += 2;
1259        var end = document.cookie.indexOf(";", begin);
1260        if (end == -1) {
1261        end = cookie.length;
1262        }
1263    }
1264    return unescape(cookie.substring(begin + prefix.length, end));
1265}
1266
1267function gdprCookies(){
1268    // Check if cookie exists, if it does show the cookie banner immediately, otherwise hide it
1269    var myCookie = getCookie("moove_gdpr_popup");
1270
1271	if (myCookie == null) {
1272	    $('#moove_gdpr_cookie_info_bar').show();
1273	} else {
1274	    $('#moove_gdpr_cookie_info_bar').hide();
1275	}
1276
1277	// Custom cookie modal open
1278	$('.change-settings-button').on('click', function() {
1279		setTimeout(function() {
1280            body.addClass('show-cookie-modal');
1281			$( ".moove-gdpr-modal-content" ).prepend('<a href="#" class="cookie-custom-close" onClick="javascript:return false;"><span class="custom-arrow-close"></span></a>');
1282        }, 200);
1283
1284        stopScrolling();
1285    });
1286
1287	// Custom cookie modal close
1288	doc.on('click','.cookie-custom-close, .gdpr_lightbox .mgbutton',function(){
1289		setTimeout(function() {
1290            body.removeClass('show-cookie-modal');
1291        }, 50);
1292		setTimeout(function() {
1293			$('.moove-gdpr-modal-close').trigger('click');
1294			resumeScrolling();
1295        }, 600);
1296	});
1297
1298	// Custom manage cookies buttons
1299	$('.manage-cookies-link a').on('click', function () {
1300		$('.change-settings-button').trigger('click');
1301	});
1302
1303	// Disable hidden links for keyboard nav
1304	$('.moove-gdpr-modal-close, .moove-gdpr-branding, .moove-gdpr-tab-nav, .gdpr_lightbox-close').attr('tabindex','-1');
1305}
1306
1307function newsPageAjax() {
1308	if (body.hasClass("page-template-page-news")) {
1309
1310		function getNewsList(args, append) {
1311			let $news_widget = $('#news-widget'),
1312				nonce = $news_widget.data('nonce'),
1313				post_id = $news_widget.data('post-id');
1314
1315			let url_queries = newsPageUrl(args);
1316
1317			$.ajax({
1318				type: "POST",
1319				url: $('body').attr('data-siteurl') + "/wp-admin/admin-ajax.php",
1320				data: url_queries + 'action=news&nonce=' + nonce,
1321				cache: true,
1322				beforeSend: function (xhr) {
1323					
1324				},
1325				success: function (results) {
1326					if (results) {
1327                        results = $(results);
1328                        if (append) {                            
1329                            $news_widget.find('.news-list').append(results.find('.news-list > *'));
1330                            // Update the page number or remove the load more button if there are no more results
1331                            $load_more_results = results.find('.load-more-results');
1332                            if ($load_more_results.length > 0) {
1333                                $news_widget.find('.load-more-results a').data('pagelink', $load_more_results.find('a').data('pagelink'));
1334                            }
1335                            else {
1336                                $news_widget.find('.load-more-results').hide();
1337                            }
1338                        }
1339                        else {
1340                            $news_widget.html(results);
1341                        }
1342						win.trigger('scroll');
1343					}
1344				}
1345			});
1346		}
1347
1348		function newsPageUrl(data) {
1349			let new_url_queries = '';
1350
1351			// Update the URL before we add the page number as we don't want the page number in the URL
1352            setUrl(new_url_queries, false);
1353
1354			if (data.page.length) {
1355				new_url_queries += 'page=' + data.page + '&';
1356			}
1357
1358			return new_url_queries;
1359		}
1360
1361		$(document).on('click', '#news-widget .load-more-results a', function (e) {
1362			e.preventDefault();
1363
1364            var page  = $(this).data("pagelink"),
1365				paged = page == '1' ? [] : [page];
1366
1367            var scrollOffset = $(".load-more-results").offset().top;
1368
1369            getNewsList({page: paged}, true);
1370
1371            scrollOffset -= win.width() >= 768 ? 80 : 40;
1372
1373			$('html, body').animate({
1374				scrollTop: scrollOffset
1375			}, 600);
1376		});
1377
1378		// Reload the page if using browser back button
1379		$(window).on('popstate', function() {
1380	    	location.reload(true);
1381	   	});
1382	}
1383}
1384
1385function eventsPageAjax() {
1386	if (body.hasClass("page-template-page-events")) {
1387
1388		function getEventsList(args, append) {
1389			var $events_widget = $('#events-widget'),
1390				nonce = $events_widget.data('nonce'),
1391				post_id = $events_widget.data('post-id');
1392
1393			let url_queries = eventsPageUrl(args);
1394
1395			$.ajax({
1396				type: "POST",
1397				url: $('body').attr('data-siteurl') + "/wp-admin/admin-ajax.php",
1398				data: url_queries + 'action=events&nonce=' + nonce,
1399				cache: false,
1400				beforeSend: function (xhr) {
1401				},
1402				success: function (results) {
1403					if (results) {
1404                        results = $(results);
1405                        if (append) {                            
1406                            $events_widget.find('.events-list').append(results.find('.events-list > *'));
1407                            // Update the page number or remove the load more button if there are no more results
1408                            $load_more_results = results.find('.load-more-results');
1409                            if ($load_more_results.length > 0) {
1410                                $events_widget.find('.load-more-results a').data('pagelink', $load_more_results.find('a').data('pagelink'));
1411                            }
1412                            else {
1413                                $events_widget.find('.load-more-results').hide();
1414                            }
1415                        }
1416                        else {
1417                            $events_widget.html(results);
1418                        }
1419						win.trigger('scroll');
1420					}
1421				}
1422			});
1423		}
1424
1425		function eventsPageUrl(data) {
1426			let new_url_queries = '';
1427			
1428			// Update the URL before we add the page number as we don't want the page number in the URL
1429            setUrl(new_url_queries, false);
1430
1431			if (data.page.length) {
1432				new_url_queries += 'page=' + data.page + '&';
1433			}
1434
1435			return new_url_queries;
1436		}
1437
1438		$(document).on('click', '#events-widget .load-more-results a', function (e) {
1439			e.preventDefault();
1440
1441            var page  = $(this).data("pagelink"),
1442				paged = page == '1' ? [] : [page];
1443
1444            var scrollOffset = $(".load-more-results").offset().top;
1445
1446            getEventsList({page: paged}, true);
1447
1448            scrollOffset -= win.width() >= 768 ? 80 : 40;
1449
1450			$('html, body').animate({
1451				scrollTop: scrollOffset
1452			}, 600);
1453		});
1454
1455		// Reload the page if using browser back button
1456		$(window).on('popstate', function() {
1457	    	location.reload(true);
1458	   	});
1459	}
1460}
1461
1462function setUrl(set_url_queries, onlyReturn) {
1463	// If last character is a ampersand, then remove the last character
1464	if (set_url_queries.substr(set_url_queries.length - 1) === "&") {
1465		set_url_queries = set_url_queries.substr(0, set_url_queries.length - 1);
1466	}
1467
1468	// data for return
1469	var url_queries = set_url_queries;
1470
1471	// if all have been cleared
1472	// then make variable for queries completely empty
1473	if (set_url_queries !== "") {
1474		set_url_queries = "?" + set_url_queries;
1475	}
1476
1477	if (!onlyReturn && history.pushState) {
1478		let newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + set_url_queries;
1479		window.history.pushState({path: newurl}, '', newurl);
1480	}
1481
1482	return (url_queries ? url_queries + '&' : url_queries);
1483}
1484
1485function modalPopup(){
1486	// Use dynamic cookie name for global popup
1487	var globalCookieName = (typeof MyPopupData !== 'undefined') ? MyPopupData.cookie_name : 'global_popup_default';
1488
1489	// Handle global modal
1490	if ($('#modalGlobal').length > 0) {
1491		if (!getCookie(globalCookieName)) {
1492			$('.modal-link').trigger('click');
1493			$('.modal-pop').removeClass('visuallyhidden');
1494			Cookies.set(globalCookieName, 'shown', { expires: 1 });
1495		}
1496	}
1497
1498	// Pull across the individual ID for the page modal
1499	var modalID = $('.modal-pop--page').attr('data-modal-id');
1500	var pageCookie = 'pagepopup'+modalID;
1501
1502	if ($('.modal-pop--page').length > 0) {
1503		$('.modal-link').trigger('click');
1504		Cookies.set(pageCookie, '', { expires: 1 });
1505	}
1506
1507	$('.modal-close-btn').click(function(e) {
1508        $.fancybox.close();
1509        return false;
1510    });
1511
1512    $('a[data-src="#modalEvent"').on('click',function(){
1513    	$('.modal-pop-event').removeClass('visuallyhidden');
1514    });
1515}
1516
1517
1518// GOOGLE MAP
1519
1520/*
1521*  render_map
1522*  This function will render a Google Map onto the selected jQuery element
1523*/
1524
1525function render_map($el) {
1526    // vars
1527    var $markers = $el.find('.marker');
1528	var mapStyles = JSON.parse($el.attr('data-style'));
1529
1530    // vars
1531    var args = {
1532        zoom: JSON.parse($el.attr('data-zoom')),
1533        center: new google.maps.LatLng(0, 0),
1534        mapTypeId: google.maps.MapTypeId.ROADMAP,
1535        styles: mapStyles,
1536    };
1537
1538    // create map
1539    var map = new google.maps.Map($el[0], args);
1540
1541    // add a markers reference
1542    map.markers = [];
1543
1544    // add markers
1545    $markers.each(function () {
1546        add_marker($(this), map);
1547    });
1548
1549    // center map
1550    center_map(map);
1551}
1552
1553/*
1554*  add_marker
1555*  This function will add a marker to the selected Google Map
1556*/
1557
1558function add_marker($marker, map) {
1559    // vars
1560    var latlng = new google.maps.LatLng($marker.attr('data-lat'), $marker.attr('data-lng'));
1561    var icon = {
1562        url: $marker.attr('data-img'),
1563        size: new google.maps.Size($marker.attr('data-img-width'), $marker.attr('data-img-height')),
1564        origin: new google.maps.Point(0, 0),
1565        anchor: new google.maps.Point(0, $marker.attr('data-img-height')),
1566        // scaledSize:new google.maps.Size($marker.attr('data-img-width'), $marker.attr('data-img-height'))
1567    };
1568    // create marker
1569    var marker = new google.maps.Marker({
1570        position: latlng,
1571        map: map,
1572        icon: icon,
1573    });
1574
1575    // add to array
1576    map.markers.push(marker);
1577
1578    // if marker contains HTML, add it to an infoWindow
1579    if ($marker.html()) {
1580        // create info window
1581        var infowindow = new google.maps.InfoWindow({
1582            content: $marker.html()
1583        });
1584
1585        // show info window when marker is clicked
1586        google.maps.event.addListener(marker, 'click', function () {
1587            infowindow.open(map, marker);
1588        });
1589    }
1590}
1591
1592/*
1593*  center_map
1594*  This function will center the map, showing all markers attached to this map
1595*/
1596
1597function center_map(map) {
1598    // vars
1599    var bounds = new google.maps.LatLngBounds();
1600
1601    // loop through all markers and create bounds
1602    $.each(map.markers, function (i, marker) {
1603        var latlng = new google.maps.LatLng(marker.position.lat(), marker.position.lng());
1604        bounds.extend(latlng);
1605    });
1606
1607    // only 1 marker?
1608    if (map.markers.length == 1) {
1609        // set center of map
1610        map.setCenter(bounds.getCenter());
1611        // map.setZoom(7);
1612    } else {
1613        // fit to bounds
1614        map.fitBounds(bounds);
1615    }
1616}
1617
1618/*
1619*  document ready
1620*  This function will render each map when the document is ready (page has loaded)
1621*/
1622
1623$(document).ready(function () {
1624    $('.acf-map').each(function () {
1625        render_map($(this));
1626    });
1627});
1628
1629})(this.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.