PageSourceSearch

https://winebc.com/wp-content/themes/wine-bc/assets/js/avia.js

js winebc.com collected 2026-10-03 19:46:38 UTC 60,029 bytes, 1,924 lines download raw bytes

1/**
2 * Polyfill for older browsers https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
3 *
4 * @since 4.8
5 * @return boolean
6 */
7if ( ! Array.isArray )
8{
9	Array.isArray = function( arg )
10	{
11		return Object.prototype.toString.call( arg ) === '[object Array]';
12	};
13}
14
15/**
16 * hack to catch and reroute jQuery custom events (default browser events seem to work even when triggered with jQuery)
17 * As events with '-' cannot be monotored with on.... we rename them to avoid possible conflicts
18 *
19 * https://stackoverflow.com/questions/11132553/how-to-catch-the-jquery-event-trigger
20 * https://stackoverflow.com/questions/36914912/how-to-get-jquery-to-trigger-a-native-custom-event-handler
21 * https://stackoverflow.com/questions/40915156/listen-for-jquery-event-with-vanilla-js
22 *
23 * @since 5.6
24 */
25(function($)
26{
27	"use strict";
28
29	const opt = {
30				'bubbles':		true,
31				'cancelable':	true
32			};
33
34	//	event is always bound to window
35	$( window ).on( 'av-height-change', function( e )
36	{
37		const event = new CustomEvent( 'avia_height_change', opt );
38		window.dispatchEvent( event );
39	});
40
41	//	event is always bound to window
42	$( 'body' ).on( 'av_resize_finished', function( e )
43	{
44		const event = new CustomEvent( 'avia_resize_finished', opt );
45		document.body.dispatchEvent( event );
46	});
47
48})( jQuery );
49
50
51(function($)
52{
53	"use strict";
54
55	$( function()
56	{
57		$.avia_utilities = $.avia_utilities || {};
58
59		AviaBrowserDetection( 'html' );
60		AviaDeviceDetection( 'html' );
61
62		//show scroll top but1ton
63		avia_scroll_top_fade();
64
65		//calculate width of content
66		aviaCalcContentWidth();
67
68		//creates search tooltip
69		new $.AviaTooltip({
70					"class": 'avia-search-tooltip',
71					data: 'avia-search-tooltip',
72					event: 'click',
73					position: 'bottom',
74					scope: "body",
75					attach: 'element',
76					within_screen: true,
77					close_keys: 27
78				});
79
80        //creates relate posts tooltip
81        new $.AviaTooltip({
82					"class": 'avia-related-tooltip',
83					data: 'avia-related-tooltip',
84					scope: ".related_posts, .av-share-box",
85					attach: 'element',
86					delay: 0
87				});
88
89        //creates ajax search
90        new $.AviaAjaxSearch({scope:'#header, .avia_search_element'});
91
92		// actiavte portfolio sorting
93		if( $.fn.avia_iso_sort )
94		{
95			$('.grid-sort-container').avia_iso_sort();
96		}
97
98		// Checks height of content and sidebar and applies shadow class to the higher one
99        AviaSidebarShadowHelper();
100
101        $.avia_utilities.avia_ajax_call();
102
103		// Add single post/portfolio swipe support (in BETA since 5.5)
104		$.avia_utilities.postSwipeSupport();
105    });
106
107	$.avia_utilities = $.avia_utilities || {};
108
109
110	$.avia_utilities.postSwipeSupport = function()
111	{
112		if( ! $.fn.avia_swipe_trigger )
113		{
114			return;
115		}
116
117		const	body = document.getElementsByTagName( 'body' ),
118				methods = {};
119
120		methods.beforeTrigger = function( slider, direction )
121		{
122			const loader = $.avia_utilities.loading();
123			loader.show();
124		};
125
126		methods.afterTrigger = function( slider, direction )
127		{
128			let body = document.getElementsByTagName( 'body' );
129			if( ! body.length )
130			{
131				return;
132			}
133
134			let dir = direction == 'prev' ? 'swiped-ltr' : 'swiped-rtl';
135			body[0].classList.add( 'av-post-swiped-overlay', dir );
136		};
137
138		if( ! body.length || ! body[0].classList.contains( 'avia-post-nav-swipe-enabled' ) )
139		{
140			return;
141		}
142
143		/**
144		 * Add swipe to posts and portfolio
145		 *
146		 * @since 5.5
147		 */
148		let single = document.querySelector( '.single #main' );
149		if( single == null )
150		{
151			return;
152		}
153
154		let prev = document.querySelector( '#wrap_all .avia-post-nav.avia-post-prev' ),
155			next = document.querySelector( '#wrap_all .avia-post-nav.avia-post-next' ),
156			param = {
157					prev: prev,
158					next: next,
159					delay_trigger: true,
160					event: {
161							prev: 'native_click',
162							next: 'native_click'
163						},
164					beforeTrigger: methods.beforeTrigger,
165					afterTrigger: methods.afterTrigger
166				};
167
168		$( single ).avia_swipe_trigger( param );
169	};
170
171	$.avia_utilities.avia_ajax_call = function(container)
172	{
173		if( typeof container == 'undefined' )
174		{
175			container = 'body';
176		};
177
178		$('a.avianolink').on('click', function(e){ e.preventDefault(); });
179        $('a.aviablank').attr('target', '_blank');
180
181        //activates the prettyphoto lightbox
182        if($.fn.avia_activate_lightbox)
183		{
184        	$(container).avia_activate_lightbox();
185        }
186
187        //scrollspy for main menu. must be located before smoothscrolling
188		if( $.fn.avia_scrollspy )
189		{
190			if(container == 'body')
191			{
192				$('body').avia_scrollspy({target:'.main_menu .menu li > a'});
193			}
194			else
195			{
196				$('body').avia_scrollspy('refresh');
197			}
198		}
199
200
201
202    // Disable smooth scrolling, conflicts with Kadence tabs / accordions
203		//smooth scrooling
204		// if( $.fn.avia_smoothscroll )
205		// {
206		// 	$('a[href*="#"]', container).avia_smoothscroll(container);
207		// }
208
209		avia_small_fixes(container);
210
211		avia_hover_effect(container);
212
213		avia_iframe_fix(container);
214
215		//activate html5 video player
216		if( $.fn.avia_html5_activation && $.fn.mediaelementplayer )
217		{
218			$(".avia_video, .avia_audio", container).avia_html5_activation({ratio:'16:9'});
219		}
220
221	};
222
223	// -------------------------------------------------------------------------------------------
224	// Error log helper
225	// -------------------------------------------------------------------------------------------
226	$.avia_utilities.log = function( text, type, extra )
227	{
228		if( typeof console == 'undefined' )
229		{
230			return;
231		}
232
233		if( typeof type == 'undefined' )
234		{
235			type = "log";
236		}
237
238		type = "AVIA-" + type.toUpperCase();
239
240		console.log( "["+type+"] "+text );
241
242		if( typeof extra != 'undefined' )
243		{
244			console.log( extra );
245		}
246	};
247
248
249
250	// -------------------------------------------------------------------------------------------
251	// keep track of the browser and content width
252	// -------------------------------------------------------------------------------------------
253
254
255
256	function aviaCalcContentWidth()
257	{
258
259	var win			= $(window),
260		width_select= $('html').is('.html_header_sidebar') ? "#main" : "#header",
261		outer		= $(width_select),
262		outerParent = outer.parents('div').eq( 0 ),
263		the_main	= $(width_select + ' .container').first(),
264		css_block	= "",
265		calc_dimensions = function()
266		{
267			var css			= "",
268				w_12 		= Math.round( the_main.width() ),
269				w_outer		= Math.round( outer.width() ),
270				w_inner		= Math.round( outerParent.width() );
271
272			//css rules for mega menu
273			css += " #header .three.units{width:"	+ ( w_12 * 0.25)+	"px;}";
274			css += " #header .six.units{width:"		+ ( w_12 * 0.50)+	"px;}";
275			css += " #header .nine.units{width:"	+ ( w_12 * 0.75)+	"px;}";
276			css += " #header .twelve.units{width:"	+( w_12 )		+	"px;}";
277
278			//css rules for tab sections
279			css += " .av-framed-box .av-layout-tab-inner .container{width:"	+( w_inner )+	"px;}";
280			css += " .html_header_sidebar .av-layout-tab-inner .container{width:"	+( w_outer )+	"px;}";
281			css += " .boxed .av-layout-tab-inner .container{width:"	+( w_outer )+	"px;}";
282
283			//css rules for submenu container
284			css += " .av-framed-box#top .av-submenu-container{width:"	+( w_inner )+	"px;}";
285
286			//ie8 needs different insert method
287			try{
288				css_block.text(css);
289			}
290			catch(err){
291				css_block.remove();
292				var headFirst = $( 'head' ).first();
293				css_block = $("<style type='text/css' id='av-browser-width-calc'>"+css+"</style>").appendTo( headFirst );
294			}
295
296		};
297
298
299
300		if($('.avia_mega_div').length > 0 || $('.av-layout-tab-inner').length > 0 || $('.av-submenu-container').length > 0)
301		{
302			var headFirst = $( 'head' ).first();
303			css_block = $("<style type='text/css' id='av-browser-width-calc'></style>").appendTo( headFirst );
304			win.on( 'debouncedresize', calc_dimensions);
305			calc_dimensions();
306		}
307	}
308
309
310    // -------------------------------------------------------------------------------------------
311    // Tiny helper for sidebar shadow
312    // -------------------------------------------------------------------------------------------
313
314	function AviaSidebarShadowHelper()
315	{
316		var $sidebar_container = $('.sidebar_shadow#top #main .sidebar');
317		var $content_container = $('.sidebar_shadow .content');
318
319		if( $sidebar_container.height() >= $content_container.height() )
320		{
321			$sidebar_container.addClass('av-enable-shadow');
322		}
323		else
324		{
325			$content_container.addClass('av-enable-shadow');
326		}
327	}
328
329
330	// -------------------------------------------------------------------------------------------
331	// modified SCROLLSPY by bootstrap
332	// -------------------------------------------------------------------------------------------
333
334
335	  function AviaScrollSpy(element, options)
336	  {
337		var self = this;
338
339		var process = self.process.bind( self ),
340			refresh = self.refresh.bind( self ),
341			$element = $(element).is('body') ? $(window) : $(element),
342			href;
343
344		    self.$body = $('body');
345		    self.$win = $(window);
346		    self.options = $.extend({}, $.fn.avia_scrollspy.defaults, options);
347		    self.selector = (self.options.target
348		      || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
349		      || '');
350
351		   	self.activation_true = false;
352
353		    if(self.$body.find(self.selector + "[href*='#']").length)
354		    {
355		    	self.$scrollElement = $element.on('scroll.scroll-spy.data-api', process);
356		    	self.$win.on('av-height-change', refresh);
357		    	self.$body.on('av_resize_finished', refresh);
358		    	self.activation_true = true;
359		    	self.checkFirst();
360
361		    	setTimeout(function()
362	  			{
363		    		self.refresh();
364		    		self.process();
365
366		    	},100);
367		    }
368
369	  }
370
371	  AviaScrollSpy.prototype = {
372
373	      constructor: AviaScrollSpy
374		, checkFirst: function () {
375
376			var current = window.location.href.split('#')[0],
377				matching_link = this.$body.find(this.selector + "[href='"+current+"']").attr('href',current+'#top');
378		}
379	    , refresh: function () {
380
381	    if(!this.activation_true) return;
382
383	        var self = this
384	          , $targets;
385
386	        this.offsets = $([]);
387	        this.targets = $([]);
388
389	        $targets = this.$body
390	          .find(this.selector)
391	          .map(function () {
392	            var $el = $(this)
393	              , href = $el.data('target') || $el.attr('href')
394	              , hash = this.hash
395	              , hash = hash.replace(/\//g, "")
396	              , $href = /^#\w/.test(hash) && $(hash);
397
398				//	$.isWindow deprecated 3.3 https://api.jquery.com/jquery.iswindow/
399				var obj = self.$scrollElement.get(0);
400				var isWindow = obj != null && obj === obj.window;
401
402	            return ( $href
403	              && $href.length
404	              && [[ $href.position().top + ( ! isWindow && self.$scrollElement.scrollTop() ), href ]] ) || null;
405	          })
406	          .sort(function (a, b) { return a[0] - b[0]; })
407	          .each(function () {
408	            self.offsets.push(this[0]);
409	            self.targets.push(this[1]);
410	          });
411
412	      }
413
414	    , process: function () {
415
416	    	if(!this.offsets) return;
417	    	if(isNaN(this.options.offset)) this.options.offset = 0;
418
419	        var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
420	          , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
421	          , maxScroll = scrollHeight - this.$scrollElement.height()
422	          , offsets = this.offsets
423	          , targets = this.targets
424	          , activeTarget = this.activeTarget
425	          , i;
426
427	        if (scrollTop >= maxScroll) {
428	          return activeTarget != (i = targets.last()[0])
429	            && this.activate ( i );
430	        }
431
432	        for (i = offsets.length; i--;) {
433	          activeTarget != targets[i]
434	            && scrollTop >= offsets[i]
435	            && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
436	            && this.activate( targets[i] );
437	        }
438	      }
439
440	    , activate: function (target) {
441	        var active
442	          , selector;
443
444	        this.activeTarget = target;
445
446	        $(this.selector)
447	          .parent('.' + this.options.applyClass)
448	          .removeClass(this.options.applyClass);
449
450	        selector = this.selector
451	          + '[data-target="' + target + '"],'
452	          + this.selector + '[href="' + target + '"]';
453
454
455
456	        active = $(selector)
457	          .parent('li')
458	          .addClass(this.options.applyClass);
459
460	        if (active.parent('.sub-menu').length)  {
461	          active = active.closest('li.dropdown_ul_available').addClass(this.options.applyClass);
462	        }
463
464	        active.trigger('activate');
465	      }
466
467	  };
468
469
470	 /* AviaScrollSpy PLUGIN DEFINITION
471	  * =========================== */
472
473	  $.fn.avia_scrollspy = function (option) {
474	    return this.each(function () {
475	      var $this = $(this)
476	        , data = $this.data('scrollspy')
477	        , options = typeof option == 'object' && option;
478	      if (!data) $this.data('scrollspy', (data = new AviaScrollSpy(this, options)));
479	      if (typeof option == 'string') data[option]();
480	    });
481	  };
482
483	  $.fn.avia_scrollspy.Constructor = AviaScrollSpy;
484
485	  $.fn.avia_scrollspy.calc_offset = function()
486	  {
487		  var 	offset_1 = (parseInt($('.html_header_sticky #main').data('scroll-offset'), 10)) || 0,
488		  		offset_2 = ($(".html_header_sticky:not(.html_top_nav_header) #header_main_alternate").outerHeight()) || 0,
489		  		offset_3 = ($(".html_header_sticky.html_header_unstick_top_disabled #header_meta").outerHeight()) || 0,
490		  		offset_4 =  1,
491		  		offset_5 = parseInt($('html').css('margin-top'),10) || 0,
492		  		offset_6 = parseInt($('.av-frame-top ').outerHeight(),10) || 0;
493
494		  return offset_1 + offset_2 + offset_3 + offset_4 + offset_5 + offset_6;
495	  };
496
497	  $.fn.avia_scrollspy.defaults =
498	  {
499	    offset: $.fn.avia_scrollspy.calc_offset(),
500	    applyClass: 'current-menu-item'
501	  };
502
503
504    // -------------------------------------------------------------------------------------------
505    // detect browser and add class to body
506    // -------------------------------------------------------------------------------------------
507    function AviaBrowserDetection(outputClassElement)
508    {
509	    //code from the old jquery migrate plugin
510	    var current_browser = {},
511
512	    	uaMatch = function( ua )
513			{
514				ua = ua.toLowerCase();
515
516				var match = /(edge)\/([\w.]+)/.exec( ua ) ||
517				/(opr)[\/]([\w.]+)/.exec( ua ) ||
518				/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
519				/(iemobile)[\/]([\w.]+)/.exec( ua ) ||
520				/(version)(applewebkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
521				/(webkit)[ \/]([\w.]+).*(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
522				/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
523				/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
524				/(msie) ([\w.]+)/.exec( ua ) ||
525				ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
526				ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
527				[];
528
529				return {
530					  browser: match[ 5 ] || match[ 3 ] || match[ 1 ] || "",
531					  version: match[ 2 ] || match[ 4 ] || "0",
532					  versionNumber: match[ 4 ] || match[ 2 ] || "0"
533					};
534			};
535
536		var matched = uaMatch( navigator.userAgent );
537
538		if( matched.browser )
539		{
540			current_browser.browser = matched.browser;
541			current_browser[ matched.browser ] = true;
542			current_browser.version = matched.version;
543		}
544
545		// Chrome is Webkit, but Webkit is also Safari.
546		if ( current_browser.chrome ) {
547			current_browser.webkit = true;
548		} else if ( current_browser.webkit ) {
549			current_browser.safari = true;
550		}
551
552        if(typeof(current_browser) !== 'undefined')
553        {
554            var bodyclass = '',
555				version = current_browser.version ? parseInt(current_browser.version) : "";
556
557            if(current_browser.msie || current_browser.rv || current_browser.iemobile){
558                bodyclass += 'avia-msie';
559            }else if(current_browser.webkit){
560                bodyclass += 'avia-webkit';
561            }else if(current_browser.mozilla){
562                bodyclass += 'avia-mozilla';
563            }
564
565            if(current_browser.version) bodyclass += ' ' + bodyclass + '-' + version + ' ';
566            if(current_browser.browser) bodyclass += ' avia-' + current_browser.browser + ' avia-' +current_browser.browser +'-' + version + ' ';
567        }
568
569        if( outputClassElement )
570		{
571			$(outputClassElement).addClass( bodyclass );
572		}
573
574        return bodyclass;
575    }
576
577	/**
578	 * Detect device features and add a class to body
579	 */
580	function AviaDeviceDetection( outputClassElement )
581	{
582		var classes = [];
583
584		//	https://stackoverflow.com/questions/14439903/how-can-i-detect-device-touch-support-in-javascript
585		$.avia_utilities.isTouchDevice = 'ontouchstart' in window ||
586				window.DocumentTouch && document instanceof window.DocumentTouch ||
587				navigator.maxTouchPoints > 0 ||
588				window.navigator.msMaxTouchPoints > 0;
589
590		classes.push( $.avia_utilities.isTouchDevice ? 'touch-device' : 'no-touch-device' );
591
592		$.avia_utilities.pointerDevices = [];
593
594		//	https://stackdiary.com/detect-mobile-browser-javascript/
595		if( typeof window.matchMedia != 'function' )
596		{
597			$.avia_utilities.pointerDevices.push( 'undefined' );
598			classes.push( 'pointer-device-undefined' );
599		}
600		else
601		{
602			var pointer_fine = false;
603
604			if( window.matchMedia( '(any-pointer: fine)' ) )
605			{
606				classes.push( 'pointer-device-fine' );
607				$.avia_utilities.pointerDevices.push( 'fine' );
608				pointer_fine = true;
609			}
610
611			if( window.matchMedia( '(any-pointer: coarse)' ) )
612			{
613				classes.push( 'pointer-device-coarse' );
614				$.avia_utilities.pointerDevices.push( 'coarse' );
615
616				if( ! pointer_fine )
617				{
618					classes.push( 'pointer-device-coarse-only' );
619				}
620			}
621
622			if( ! $.avia_utilities.pointerDevices.length )
623			{
624				classes.push( 'pointer-device-none' );
625				$.avia_utilities.pointerDevices.push( 'none' );
626			}
627		}
628
629		if( 'undefined' == typeof $.avia_utilities.isMobile )
630		{
631			if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) && 'ontouchstart' in document.documentElement)
632			{
633				$.avia_utilities.isMobile = true;
634			}
635			else
636			{
637				$.avia_utilities.isMobile = false;
638			}
639		}
640
641		$( outputClassElement ).addClass( classes.join( ' ') );
642	}
643
644    // -------------------------------------------------------------------------------------------
645	// html 5 videos
646	// -------------------------------------------------------------------------------------------
647    $.fn.avia_html5_activation = function( options )
648	{
649		var defaults =
650		{
651			ratio: '16:9'
652		};
653
654		var options = $.extend( defaults, options );
655
656//			isMobile = $.avia_utilities.isMobile;
657//			if(isMobile) return;
658
659		this.each( function()
660		{
661			var fv = $(this),
662				id_to_apply = '#' + fv.attr('id'),
663				posterImg = fv.attr('poster'),
664				features = [ 'playpause', 'progress', 'current', 'duration', 'tracks', 'volume' ],
665				container = fv.closest( '.avia-video' );
666
667			if( container.length > 0 && container.hasClass( 'av-html5-fullscreen-btn' ) )
668			{
669				features.push( 'fullscreen' );
670			}
671
672			/*
673			 * Hide controls
674			 * https://kriesi.at/support/topic/video-not-appearing-properly-as-color-section-background/#post-1429866
675			 *
676			 * @since 5.6.10
677			 */
678			if( ! $(this).prop('controls') )
679			{
680				features = [];
681			}
682
683			fv.mediaelementplayer(
684			{
685				// if the <video width> is not specified, this is the default
686				defaultVideoWidth: 480,
687				// if the <video height> is not specified, this is the default
688				defaultVideoHeight: 270,
689				// if set, overrides <video width>
690				videoWidth: -1,
691				// if set, overrides <video height>
692				videoHeight: -1,
693				// width of audio player
694				audioWidth: 400,
695				// height of audio player
696				audioHeight: 30,
697				// initial volume when the player starts
698				startVolume: 0.8,
699				// useful for <audio> player loops
700				loop: false,
701				// enables Flash and Silverlight to resize to content size
702				enableAutosize: false,
703				// the order of controls you want on the control bar (and other plugins below)
704				features: features,
705				// Hide controls when playing and mouse is not over the video
706				alwaysShowControls: false,
707				// force iPad's native controls
708				iPadUseNativeControls: false,
709				// force iPhone's native controls
710				iPhoneUseNativeControls: false,
711				// force Android's native controls
712				AndroidUseNativeControls: false,
713				// forces the hour marker (##:00:00)
714				alwaysShowHours: false,
715				// show framecount in timecode (##:00:00:00)
716				showTimecodeFrameCount: false,
717				// used when showTimecodeFrameCount is set to true
718				framesPerSecond: 25,
719				// turns keyboard support on and off for this instance
720				enableKeyboard: true,
721				// when this player starts, it will pause other players
722				pauseOtherPlayers: false,
723				poster: posterImg,
724				success: function( mediaElement, domObject, instance )
725				{
726					//make the medialement instance accesible by storing it. usually not necessary but safari has problems since wp version 4.9
727					$.AviaVideoAPI.players[ fv.attr('id').replace( /_html5/,'' ) ] = instance;
728
729					setTimeout(function()
730					{
731						if( mediaElement.pluginType == 'flash' )
732						{
733							mediaElement.addEventListener('canplay', function() { fv.trigger('av-mediajs-loaded'); }, false);
734						}
735						else
736						{
737							fv.trigger('av-mediajs-loaded').addClass('av-mediajs-loaded');
738						}
739
740						mediaElement.addEventListener('ended', function() {  fv.trigger('av-mediajs-ended'); }, false);
741
742						var html5MediaElement = document.getElementById( $(mediaElement).attr('id') + '_html5' );
743						if( html5MediaElement && html5MediaElement !== mediaElement )
744						{
745							mediaElement.addEventListener( "ended", function()
746							{
747								$( html5MediaElement ).trigger( 'av-mediajs-ended' );
748							});
749						}
750					}, 10 );
751
752				},
753				// fires when a problem is detected
754				error: function()
755				{
756
757				},
758				// array of keyboard commands
759				keyActions: []
760			});
761		});
762	};
763
764 	// -------------------------------------------------------------------------------------------
765	// hover effect for images
766	// -------------------------------------------------------------------------------------------
767    function avia_hover_effect( container )
768    {
769    	//hover overlay for mobile device doesnt really make sense. in addition it often slows down the click event
770    	if( $.avia_utilities.isMobile )
771		{
772			return;
773		}
774
775		if( $('body').hasClass( 'av-disable-avia-hover-effect' ) )
776		{
777			return;
778		}
779
780		var overlay = "",
781			cssTrans = $.avia_utilities.supports('transition');
782
783		if(container == 'body')
784    	{
785    		var elements = $('#main a img').parents('a').not('.noLightbox, .noLightbox a, .avia-gallery-thumb a, .ls-wp-container a, .noHover, .noHover a, .av-logo-container .logo a').add('#main .avia-hover-fx');
786    	}
787    	else
788    	{
789    		var elements = $('a img', container).parents('a').not('.noLightbox, .noLightbox a, .avia-gallery-thumb a, .ls-wp-container a, .noHover, .noHover a, .av-logo-container .logo a').add('.avia-hover-fx', container);
790    	}
791
792	   elements.each( function(e)
793       {
794            var link = $(this),
795            	current = link.find('img').first();
796
797            if(current.hasClass('alignleft')) link.addClass('alignleft').css({float:'left', margin:0, padding:0});
798            if(current.hasClass('alignright')) link.addClass('alignright').css({float:'right', margin:0, padding:0});
799            if(current.hasClass('aligncenter')) link.addClass('aligncenter').css({float:'none','text-align':'center', margin:0, padding:0});
800
801            if(current.hasClass('alignnone'))
802            {
803               link.addClass('alignnone').css({margin:0, padding:0});;
804               if(!link.css('display') || link.css('display') == 'inline') { link.css({display:'inline-block'}); }
805            }
806
807            if(!link.css('position') || link.css('position') == 'static') { link.css({position:'relative', overflow:'hidden'}); }
808
809            var url		 	= link.attr('href'),
810				span_class	= "overlay-type-video",
811				opa			= link.data('opacity') || 0.7,
812				overlay_offset = 5,
813				overlay 	= link.find('.image-overlay');
814
815            	if(url)
816				{
817					if( url.match(/(jpg|gif|jpeg|png|tif)/) ) span_class = "overlay-type-image";
818					if(!url.match(/(jpg|gif|jpeg|png|\.tif|\.mov|\.swf|vimeo\.com|youtube\.com)/) ) span_class = "overlay-type-extern";
819				}
820
821				if(!overlay.length)
822				{
823					overlay = $("<span class='image-overlay "+span_class+"'><span class='image-overlay-inside'></span></span>
823").appendTo(link);
824				}
825
826            	link.on('mouseenter', function(e)
827				{
828					var current = link.find('img').first(),
829						_self	= current.get(0),
830						outerH 	= current.outerHeight(),
831						outerW 	= current.outerWidth(),
832						pos		= current.position(),
833						linkCss = link.css('display'),
834						overlay = link.find('.image-overlay');
835
836					if(outerH > 100)
837					{
838
839						if(!overlay.length)
840						{
841							overlay = $("<span class='image-overlay "+span_class+"'><span class='image-overlay-inside'></span></span>").appendTo(link);
842
843						}
844						//can be wrapped into if !overlay.length statement if chrome fixes fade in problem
845						if(link.height() == 0) { link.addClass(_self.className); _self.className = ""; }
846						if(!linkCss || linkCss == 'inline') { link.css({display:'block'}); }
847						//end wrap
848
849						overlay.css({left:(pos.left - overlay_offset) + parseInt(current.css("margin-left"),10), top:pos.top + parseInt(current.css("margin-top"),10)})
850							   .css({overflow:'hidden',display:'block','height':outerH,'width':(outerW + (2*overlay_offset))});
851
852						if(cssTrans === false ) overlay.stop().animate({opacity:opa}, 400);
853					}
854					else
855					{
856						overlay.css({display:"none"});
857					}
858
859				}).on('mouseleave', elements, function(){
860
861					if(overlay.length)
862					{
863						if(cssTrans === false ) overlay.stop().animate({opacity:0}
863, 400);
864					}
865				});
866        });
867    }
868
869
870// -------------------------------------------------------------------------------------------
871// Smooth scrooling when clicking on anchor links
872// todo: maybe use https://github.com/ryanburnette/scrollToBySpeed/blob/master/src/scrolltobyspeed.jquery.js in the future
873// -------------------------------------------------------------------------------------------
874
875	(function($)
876	{
877		$.fn.avia_smoothscroll = function( apply_to_container )
878		{
879			if( ! this.length )
880			{
881				return;
882			}
883
884			var the_win = $(window),
885				$header = $('#header'),
886				$main 	= $('.html_header_top.html_header_sticky #main').not('.page-template-template-blank-php #main'),
887				$meta 	= $('.html_header_top.html_header_unstick_top_disabled #header_meta'),
888				$alt  	= $('.html_header_top:not(.html_top_nav_header) #header_main_alternate'),
889				menu_above_logo = $('.html_header_top.html_top_nav_header'),
890				shrink	= $('.html_header_top.html_header_shrinking').length,
891				frame	= $('.av-frame-top'),
892				fixedMainPadding = 0,
893				isMobile = $.avia_utilities.isMobile,
894				sticky_sub = $('.sticky_placeholder').first(),
895				calc_main_padding = function()
896				{
897					if( $header.css('position') == "fixed" )
898					{
899						var tempPadding = parseInt($main.data('scroll-offset'),10) || 0,
900							non_shrinking = parseInt($meta.outerHeight(),10) || 0,
901							non_shrinking2 = parseInt($alt.outerHeight(),10) || 0;
902
903						if( tempPadding > 0 && shrink )
904						{
905							tempPadding = (tempPadding / 2 ) + non_shrinking + non_shrinking2;
906						}
907						else
908						{
909							tempPadding = tempPadding + non_shrinking + non_shrinking2;
910						}
911
912						tempPadding += parseInt($('html').css('margin-top'),10);
913						fixedMainPadding = tempPadding;
914					}
915					else
916					{
917						fixedMainPadding = parseInt($('html').css('margin-top'),10);
918					}
919
920					if( frame.length )
921					{
922						fixedMainPadding += frame.height();
923					}
924
925					if( menu_above_logo.length )
926					{
927						//if menu is above logo and we got a sticky height header
928						fixedMainPadding = $('.html_header_sticky #header_main_alternate').height() + parseInt($('html').css('margin-top'),10);
929					}
930
931					if( isMobile )
932					{
933						fixedMainPadding = 0;
934					}
935
936				};
937
938			if( isMobile )
939			{
940				shrink = false;
941			}
942
943			calc_main_padding();
944			the_win.on( "debouncedresize av-height-change", calc_main_padding );
945
946			var hash = window.location.hash.replace(/\//g, "");
947
948			//if a scroll event occurs at pageload and an anchor is set and a coresponding element exists apply the offset to the event
949			if( fixedMainPadding > 0 && hash && apply_to_container == 'body' && hash.charAt(1) != "!" && hash.indexOf("=") === -1 )
950			{
951				var scroll_to_el = $(hash), modifier = 0;
952
953				if( scroll_to_el.length )
954				{
955					the_win.on('scroll.avia_first_scroll', function()
956					{
957						setTimeout( function()		//small delay so other scripts can perform necessary resizing
958						{
959							if( sticky_sub.length && scroll_to_el.offset().top > sticky_sub.offset().top )
960							{
961								modifier = sticky_sub.outerHeight() - 3;
962							}
963
964							the_win.off( 'scroll.avia_first_scroll' ).scrollTop( scroll_to_el.offset().top - fixedMainPadding - modifier );
965						},10);
966				    });
967			    }
968			}
969
970			return this.each(function()
971			{
972				$(this).on('click', function(e)
973				{
974					var newHash = this.hash.replace(/\//g, ""),
975						clicked = $(this),
976						data = clicked.data(),
977						ignoreScroll = false,
978						noScrolInViewport = 'undefined' != typeof data.no_scroll_in_viewport && data.no_scroll_in_viewport == 1,
979						ignoreHash = 'undefined' != typeof data.ignore_hash && data.ignore_hash == 1;
980
981					if( newHash != '' && newHash != '#' && newHash != '#prev' && newHash != '#next' && !clicked.is('.comment-reply-link, #cancel-comment-reply-link, .no-scroll'))
982					{
983						var container = "",
984							originHash = "";
985
986						if( '#next-section' == newHash )
987						{
988							originHash = newHash;
989
990							//	@since 4.8.3 check to scroll to visible sections only (e.g. sections could be hidden on different devices
991							var next_containers = clicked.parents('.container_wrap').eq( 0 ).nextAll('.container_wrap');
992							next_containers.each( function()
993							{
994							   var cont = $( this );
995
996							   if( cont.css( 'display' ) == 'none' || cont.css( 'visibility' ) == 'hidden' )
997							   {
998								   return;
999							   }
1000
1001							   container = cont;
1002							   return false;
1003							});
1004
1005							if( 'object' == typeof container && container.length > 0 )
1006							{
1007								newHash = '#' + container.attr('id') ;
1008							}
1009						}
1010						else
1011						{
1012							 container = $( this.hash.replace(/\//g, "") );
1013						}
1014
1015						//	check if element is already in viewport
1016						if( container.length && noScrolInViewport )
1017						{
1018							const rect = container[0].getBoundingClientRect();
1019
1020							if( rect.top > fixedMainPadding && ( rect.top < (window.innerHeight || document.documentElement.clientHeight) ) )
1021							{
1022								ignoreScroll = true;
1023							}
1024						}
1025
1026						if( container.length && ! ignoreScroll )
1027						{
1028							var cur_offset = the_win.scrollTop(),
1029								container_offset = container.offset().top,
1030								target =  container_offset - fixedMainPadding,
1031								hash = window.location.hash,
1032								hash = hash.replace(/\//g, ""),
1033								oldLocation = window.location.href.replace(hash, ''),
1034								newLocation = this,
1035								duration = data.duration || 1200,
1036								easing = data.easing || 'easeInOutQuint';
1037
1038							if( sticky_sub.length && container_offset > sticky_sub.offset().top )
1039							{
1040								target -= sticky_sub.outerHeight() - 3;
1041							}
1042							if( 'undefined' != typeof data.scroll_top_offset && Number.isInteger( data.scroll_top_offset ) )
1043							{
1044								target -= data.scroll_top_offset;
1045							}
1046
1047							// make sure it's the same location
1048							if( oldLocation + newHash == newLocation || originHash )
1049							{
1050								if( cur_offset != target ) // if current pos and target are the same dont scroll
1051								{
1052									if( ! ( cur_offset == 0 && target <= 0 ) ) // if we are at the top dont try to scroll to top or above
1053									{
1054										the_win.trigger('avia_smooth_scroll_start');
1055
1056										// animate to target and set the hash to the window.location after the animation
1057										$('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function()
1058										{
1059											the_win.trigger('avia_smooth_scroll_end');
1060
1061											if( ! ignoreHash )
1062											{
1063												// add new hash to the browser location
1064												//window.location.href=newLocation;
1065												if( window.history.replaceState )
1066												{
1067													window.history.replaceState( "", "", newHash );
1068												}
1069											}
1070										});
1071									}
1072								}
1073
1074								// cancel default click action
1075								e.preventDefault();
1076							}
1077						}
1078					}
1079				});
1080			});
1081		};
1082	})(jQuery);
1083
1084
1085	// -------------------------------------------------------------------------------------------
1086	// iframe fix for firefox and ie so they get proper z index
1087	// -------------------------------------------------------------------------------------------
1088	function avia_iframe_fix(container)
1089	{
1090		var iframe 	= jQuery('iframe[src*="youtube.com"]:not(.av_youtube_frame)', container),
1091			youtubeEmbed = jQuery('iframe[src*="youtube.com"]:not(.av_youtube_frame) object, iframe[src*="youtube.com"]:not(.av_youtube_frame) embed', container).attr('wmode','opaque');
1092
1093			iframe.each(function()
1094			{
1095				var current = jQuery(this),
1096					src 	= current.attr('src');
1097
1098				if(src)
1099				{
1100					if(src.indexOf('?') !== -1)
1101					{
1102						src += "&wmode=opaque&rel=0";
1103					}
1104					else
1105					{
1106						src += "?wmode=opaque&rel=0";
1107					}
1108
1109					current.attr('src', src);
1110				}
1111			});
1112	}
1113
1114	// -------------------------------------------------------------------------------------------
1115	// small js fixes for pixel perfection :)
1116	// -------------------------------------------------------------------------------------------
1117	function avia_small_fixes(container)
1118	{
1119		if(!container) container = document;
1120
1121		//make sure that iframes do resize correctly. uses css padding bottom iframe trick
1122		var win		= jQuery(window),
1123			iframes = jQuery('.avia-iframe-wrap iframe:not(.avia-slideshow iframe):not( iframe.no_resize):not(.avia-video iframe)', container),
1124			adjust_iframes = function()
1125			{
1126				iframes.each(function(){
1127
1128					var iframe = jQuery(this), parent = iframe.parent(), proportions = 56.25;
1129
1130					if(this.width && this.height)
1131					{
1132						proportions = (100/ this.width) * this.height;
1133						parent.css({"padding-bottom":proportions+"%"});
1134					}
1135				});
1136			};
1137
1138			adjust_iframes();
1139
1140	}
1141
1142   function avia_scroll_top_fade()
1143   {
1144   		 var win = $(window),
1145   		 	 timeo = false,
1146   		 	 scroll_top = $('#scroll-top-link'),
1147   		 	 set_status = function()
1148             {
1149             	var st = win.scrollTop();
1150
1151             	if(st < 500)
1152             	{
1153             		scroll_top.removeClass('avia_pop_class');
1154             	}
1155             	else if(!scroll_top.is('.avia_pop_class'))
1156             	{
1157             		scroll_top.addClass('avia_pop_class');
1158             	}
1159             };
1160
1161   		 win.on( 'scroll',  function(){ window.requestAnimationFrame( set_status ); } );
1162         set_status();
1163	}
1164
1165	$.AviaAjaxSearch = function( options )
1166	{
1167		var defaults = {
1168			delay: 300,                //delay in ms until the user stops typing.
1169			minChars: 3,               //dont start searching before we got at least that much characters
1170			scope: 'body'
1171		};
1172
1173		this.options = $.extend({}, defaults, options);
1174		this.scope   = $(this.options.scope);
1175		this.timer   = false;
1176		this.lastVal = "";
1177
1178		this.bind_events();
1179	};
1180
1181	$.AviaAjaxSearch.prototype =
1182    {
1183        bind_events: function()
1184        {
1185            this.scope.on( 'keyup', '#s:not(".av_disable_ajax_search #s")', this.try_search.bind( this ) );
1186            this.scope.on( 'click', '#s.av-results-parked', this.reset.bind( this ) );
1187        },
1188
1189        try_search: function(e)
1190        {
1191            var form = $(e.currentTarget).parents('form').eq( 0 ),
1192                resultscontainer = form.find('.ajax_search_response');
1193
1194            clearTimeout(this.timer);
1195
1196			// clear on ESC
1197            if( e.keyCode === 27 )
1198			{
1199                this.reset(e);
1200				return;
1201			}
1202
1203            //only execute search if chars are at least "minChars" and search differs from last one
1204            if(e.currentTarget.value.length >= this.options.minChars && this.lastVal != e.currentTarget.value.trim() )
1205            {
1206                //wait at least "delay" milliseconds to execute ajax. if user types again during that time dont execute
1207                this.timer = setTimeout( this.do_search.bind( this, e ), this.options.delay );
1208            }
1209            //remove the results container if the input field has been emptied
1210            else if ( e.currentTarget.value.length == 0 )
1211			{
1212                this.timer = setTimeout( this.reset.bind( this, e ), this.options.delay );
1213			}
1214        },
1215
1216		reset: function(e)
1217		{
1218            var form = $(e.currentTarget).parents('form').eq( 0 ),
1219				resultscontainer = form.find('.ajax_search_response'),
1220				alternative_resultscontainer = $(form.attr('data-ajaxcontainer')).find('.ajax_search_response'),
1221				searchInput = $(e.currentTarget);
1222
1223            // bring back results that were hidden when user clicked outside the form element
1224            if ($(e.currentTarget).hasClass('av-results-parked')) {
1225                resultscontainer.show();
1226                alternative_resultscontainer.show();
1227
1228                // in case results container is attached to body
1229                $('body > .ajax_search_response').show();
1230			}
1231			else {
1232                // remove results and delete the input value
1233                resultscontainer.remove();
1234                alternative_resultscontainer.remove();
1235                searchInput.val('');
1236
1237                // in case results container is attached to body
1238                $('body > .ajax_search_response').remove();
1239			}
1240
1241
1242		},
1243
1244        do_search: function(e)
1245        {
1246            var obj = this,
1247                currentField = $(e.currentTarget).attr( "autocomplete", "off" ),
1248				currentFieldWrapper = $(e.currentTarget).parents('.av_searchform_wrapper').eq( 0 ),
1249                currentField_position = currentFieldWrapper.offset(),
1250                currentField_width = currentFieldWrapper.outerWidth(),
1251                currentField_height = currentFieldWrapper.outerHeight(),
1252				form = currentField.parents('form').eq( 0 ),
1253				submitbtn = form.find('#searchsubmit'),
1254                resultscontainer = form,
1255                results = resultscontainer.find('.ajax_search_response'),
1256                loading = $('<div class="ajax_load"><span class="ajax_load_inner"></span></div>'),
1257                action = form.attr('action'),
1258                values = form.serialize(),
1259				elementID = form.data('element_id'),
1260				custom_color = form.data('custom_color');
1261
1262			values += '&action=avia_ajax_search';
1263
1264
1265            // define results div if not found
1266            if( ! results.length )
1267			{
1268                results = $('<div class="ajax_search_response" style="display:none;"></div>');
1269            }
1270
1271			if( 'undefined' != typeof elementID )
1272			{
1273				results.addClass( elementID );
1274			}
1275
1276			if( 'undefined' != typeof custom_color && custom_color != '' )
1277			{
1278				results.addClass( 'av_has_custom_color' );
1279			}
1280
1281            // add class to differentiate betweeen search element and header search
1282			if( form.attr('id') == 'searchform_element')
1283			{
1284				results.addClass('av_searchform_element_results');
1285			}
1286
1287            //check if the form got get parameters applied and also apply them
1288           	if(action.indexOf('?') != -1)
1289           	{
1290           		action  = action.split('?');
1291           		values += "&" + action[1];
1292           	}
1293
1294           	//check if there is a results container defined
1295			if( form.attr('data-ajaxcontainer') )
1296			{
1297                var rescon = form.attr('data-ajaxcontainer');
1298
1299                // check if defined container exists
1300                if ($(rescon).length)
1301				{
1302                	// remove previous search results
1303					$(rescon).find('.ajax_search_response').remove();
1304
1305                    resultscontainer = $(rescon);
1306				}
1307			}
1308
1309			/*
1310			 * For the placement option: "Under the search form - overlay other content",
1311			 * we have to attach the results to the body in order to overlay the other content,
1312			 * and we calculate it's position using the search field
1313			 */
1314
1315            results_css = {};
1316
1317			if( form.hasClass('av_results_container_fixed') )
1318			{
1319				// remove previous search results
1320				$('body').find('.ajax_search_response').remove();
1321
1322				resultscontainer = $('body');
1323
1324				// add class and position to results if defined above
1325				var results_css = {
1326								top: currentField_position.top + currentField_height,
1327								left: currentField_position.left,
1328								width: currentField_width
1329							};
1330
1331				// make sure default stylesheet is applied
1332				results.addClass('main_color');
1333
1334				// remove results and reset if window is resized
1335				$( window ).resize( function()
1336				{
1337					results.remove();
1338					this.reset.bind( this );
1339					currentField.val('');
1340				});
1341			}
1342
1343            // add additional styles - for backwards comp. only. Attribute has been removed in 4.8.7 with header styles
1344            if ( form.attr('data-results_style') )
1345			{
1346                var results_style = JSON.parse(form.attr('data-results_style'));
1347                results_css = Object.assign(results_css, results_style);
1348
1349                // add class if font color is applied, so we can use color: inherit
1350                if( "color" in results_css )
1351				{
1352                    results.addClass('av_has_custom_color');
1353                }
1354            }
1355
1356            // apply inline styles
1357            results.css(results_css);
1358
1359            // add .container class if resultscontainer in a color section
1360			if( resultscontainer.hasClass('avia-section') )
1361			{
1362				results.addClass('container');
1363			}
1364
1365            // append results to defined container
1366            results.appendTo(resultscontainer);
1367
1368
1369			//return if we already hit a no result and user is still typing
1370			if(results.find('.ajax_not_found').length && e.currentTarget.value.indexOf(this.lastVal) != -1)
1371			{
1372				return;
1373			}
1374
1375			this.lastVal = e.currentTarget.value;
1376
1377			$.ajax({
1378				url: avia_framework_globals.ajaxurl,
1379				type: "POST",
1380				data:values,
1381				beforeSend: function()
1382				{
1383					// add loader after submit button
1384					loading.insertAfter(submitbtn);
1385					form.addClass('ajax_loading_now');
1386				},
1387				success: function(response)
1388				{
1389					if(response == 0)
1390					{
1391						response = "";
1392					}
1393
1394					results.html(response).show();
1395				},
1396				complete: function()
1397				{
1398					loading.remove();
1399					form.removeClass('ajax_loading_now');
1400				}
1401			});
1402
1403            // Hide search resuls if user clicks anywhere outside the form element
1404			$(document).on('click',function(e)
1405			{
1406				if(!$(e.target).closest(form).length)
1407				{
1408					if($(results).is(":visible"))
1409					{
1410						$(results).hide();
1411						currentField.addClass('av-results-parked');
1412					}
1413				}
1414			});
1415		}
1416	};
1417
1418
1419	$.AviaTooltip = function( options )
1420	{
1421	   var defaults = {
1422            delay: 1500,                //delay in ms until the tooltip appears
1423            delayOut: 300,             	//delay in ms when instant showing should stop
1424            delayHide: 0,             	//delay hiding of tooltip in ms
1425            "class": "avia-tooltip",   	//tooltip classname for css styling and alignment
1426            scope: "body",             	//area the tooltip should be applied to
1427            data:  "avia-tooltip",     	//data attribute that contains the tooltip text
1428            attach: "body",          	//either attach the tooltip to the "mouse" or to the "element" // todo: implement mouse, make sure that it doesnt overlap with screen borders
1429            event: 'mouseenter',       	//mousenter and leave or click and leave
1430            position: 'top',             //top or bottom
1431            extraClass: 'avia-tooltip-class', //extra class that is defined by a tooltip element data attribute
1432            permanent: false, 			// always display the tooltip?
1433            within_screen: false,		// if the tooltip is displayed outside the screen adjust its position
1434            close_keys: null			// string|[] of keyCodes to close the tooltip (there is no check for empty value !! )
1435        };
1436
1437        this.options = $.extend({}, defaults, options);
1438
1439		var close_keys = '';
1440		if( this.options.close_keys != null )
1441		{
1442			if( ! Array.isArray( this.options.close_keys ) )
1443			{
1444				this.options.close_keys = [ this.options.close_keys ];
1445			}
1446			close_keys = ' data-close-keys="' + this.options.close_keys.join( ',' ) + '" ';
1447		}
1448
1449        this.body    = $('body');
1450        this.scope   = $(this.options.scope);
1451		this.tooltip = $( '<div class="' + this.options['class'] + ' avia-tt"' + close_keys + '><span class="avia-arrow-wrap"><span class="avia-arrow"></span></span></div>' );
1452        this.inner   = $( '<div class="inner_tooltip"></div>').prependTo(this.tooltip);
1453        this.open    = false;
1454        this.timer   = false;
1455        this.active  = false;
1456
1457        this.bind_events();
1458	};
1459
1460	$.AviaTooltip.openTTs = [];
1461	$.AviaTooltip.openTT_Elements = [];
1462
1463    $.AviaTooltip.prototype =
1464    {
1465        bind_events: function()
1466        {
1467	        var perma_tooltips		= '.av-permanent-tooltip [data-'+this.options.data+']',
1468	        	default_tooltips	= '[data-'+this.options.data+']:not( .av-permanent-tooltip [data-'+this.options.data+'])';
1469
1470	        this.scope.on( 'av_permanent_show', perma_tooltips, this.display_tooltip.bind( this ) );
1471	        $(perma_tooltips).addClass('av-perma-tooltip').trigger('av_permanent_show');
1472
1473
1474			this.scope.on( this.options.event + ' mouseleave', default_tooltips, this.start_countdown.bind( this ) );
1475
1476            if(this.options.event != 'click')
1477            {
1478                this.scope.on( 'mouseleave', default_tooltips, this.hide_tooltip.bind( this ) );
1479				this.scope.on( 'click', default_tooltips, this.hide_on_click_tooltip.bind( this ) );
1480            }
1481            else
1482            {
1483                this.body.on( 'mousedown', this.hide_tooltip.bind( this ) );
1484            }
1485
1486			if( this.options.close_keys != null )
1487			{
1488				this.body.on( 'keyup', this.close_on_keyup.bind( this ) );
1489			}
1490        },
1491
1492        start_countdown: function(e)
1493        {
1494            clearTimeout(this.timer);
1495
1496			var target 		= this.options.event == "click" ? e.target : e.currentTarget,
1497            	element 	= $(target);
1498
1499            if( e.type == this.options.event )
1500            {
1501                var delay = this.options.event == 'click' ? 0 : this.open ? 0 : this.options.delay;
1502
1503                this.timer = setTimeout( this.display_tooltip.bind( this, e ), delay );
1504            }
1505            else if( e.type == 'mouseleave' )
1506            {
1507				if( ! element.hasClass( 'av-close-on-click-tooltip' ) )
1508				{
1509					this.timer = setTimeout( this.stop_instant_open.bind( this, e ), this.options.delayOut);
1510				}
1511            }
1512            e.preventDefault();
1513        },
1514
1515        reset_countdown: function(e)
1516        {
1517            clearTimeout( this.timer );
1518            this.timer = false;
1519        },
1520
1521        display_tooltip: function(e)
1522        {
1523            var _self		= this,
1524            	target 		= this.options.event == "click" ? e.target : e.currentTarget,
1525            	element 	= $(target),
1526                text    	= element.data(this.options.data),
1527                tip_index  	= element.data('avia-created-tooltip'),
1528            	extraClass 	= element.data('avia-tooltip-class'),
1529                attach  	= this.options.attach == 'element' ? element : this.body,
1530                offset  	= this.options.attach == 'element' ? element.position() : element.offset(),
1531                position	= element.data('avia-tooltip-position'),
1532                align		= element.data('avia-tooltip-alignment'),
1533                force_append= false,
1534				newTip		= false,
1535				is_new_tip	= false;
1536
1537            text = 'string' == typeof text ? text.trim() : '';
1538
1539            if(element.is('.av-perma-tooltip'))
1540            {
1541	            offset = {top:0, left:0 };
1542	        	attach = element;
1543				force_append = true;
1544            }
1545
1546			if( text == "" )
1547			{
1548				return;
1549			}
1550			if( position == "" || typeof position == 'undefined' )
1551			{
1552				position = this.options.position;
1553			}
1554			if( align == "" || typeof align == 'undefined' )
1555			{
1556				align = 'center';
1557			}
1558
1559			if( typeof tip_index != 'undefined' )
1560			{
1561				newTip = $.AviaTooltip.openTTs[tip_index];
1562			}
1563			else
1564			{
1565				this.inner.html(text);
1566				newTip = this.tooltip.clone();
1567				is_new_tip = true;
1568
1569				if( this.options.attach == 'element' && force_append !== true )
1570				{
1571					newTip.insertAfter(attach);
1572				}
1573				else
1574				{
1575					newTip.appendTo(attach);
1576				}
1577
1578                if(extraClass != "")
1579				{
1580					newTip.addClass(extraClass);
1581				}
1582			}
1583
1584			if( this.open && this.active == newTip )
1585			{
1586				return;
1587			}
1588
1589			if( element.hasClass( 'av-close-on-click-tooltip' ) )
1590			{
1591				this.hide_all_tooltips();
1592			}
1593
1594            this.open = true;
1595            this.active = newTip;
1596
1597            if( ( newTip.is(':animated:visible') && e.type == 'click' ) || element.is( '.' + this.options['class'] ) || element.parents( '.' + this.options['class'] ).length != 0 )
1598			{
1599				return;
1600			}
1601
1602            var animate1 = {},
1603				animate2 = {},
1604				pos1 = "",
1605				pos2 = "";
1606
1607			if( position == "top" || position == "bottom" )
1608			{
1609				switch(align)
1610				{
1611					case "left":
1612						pos2 = offset.left;
1613						break;
1614					case "right":
1615						pos2 = offset.left + element.outerWidth() - newTip.outerWidth();
1616						break;
1617					default:
1618						pos2 = ( offset.left + ( element.outerWidth() / 2 ) ) - ( newTip.outerWidth() / 2 );
1619						break;
1620				}
1621
1622				if(_self.options.within_screen) //used to keep search field inside screen
1623				{
1624					var boundary = element.offset().left + (element.outerWidth() / 2) - (newTip.outerWidth() / 2) + parseInt(newTip.css('margin-left'),10);
1625					if(boundary < 0)
1626					{
1627						pos2 = pos2 - boundary;
1628					}
1629				}
1630			}
1631			else
1632			{
1633				switch(align)
1634				{
1635					case "top":
1636						pos1 = offset.top;
1637						break;
1638					case "bottom":
1639						pos1 = offset.top + element.outerHeight() - newTip.outerHeight();
1640						break;
1641					default:
1642						pos1 = ( offset.top + (element.outerHeight() / 2 ) ) - ( newTip.outerHeight() / 2 );
1643						break;
1644				}
1645			}
1646
1647			switch(position)
1648			{
1649				case "top":
1650					pos1 = offset.top - newTip.outerHeight();
1651					animate1 = {top: pos1 - 10, left: pos2};
1652					animate2 = {top: pos1};
1653					break;
1654				case "bottom":
1655					pos1 = offset.top + element.outerHeight();
1656					animate1 = {top: pos1 + 10, left: pos2};
1657					animate2 = {top: pos1};
1658					break;
1659				case "left":
1660					pos2 = offset.left  - newTip.outerWidth();
1661					animate1 = {top: pos1, left: pos2 -10};
1662					animate2 = {left: pos2};
1663					break;
1664				case "right":
1665					pos2 = offset.left + element.outerWidth();
1666					animate1 = {top: pos1, left: pos2 + 10};
1667					animate2 = {left: pos2};
1668					break;
1669			}
1670
1671			animate1['display'] = "block";
1672			animate1['opacity'] = 0;
1673			animate2['opacity'] = 1;
1674
1675            newTip.css(animate1).stop().animate(animate2,200);
1676
1677            newTip.find('input, textarea').trigger('focus');
1678			if( is_new_tip )
1679			{
1680				$.AviaTooltip.openTTs.push(newTip);
1681				$.AviaTooltip.openTT_Elements.push(element);
1682				element.data('avia-created-tooltip', $.AviaTooltip.openTTs.length - 1);
1683			}
1684        },
1685
1686		hide_on_click_tooltip: function(e)
1687		{
1688			if( this.options.event == "click" )
1689			{
1690				return;
1691			}
1692
1693			var element = $( e.currentTarget );
1694
1695			if( ! element.hasClass('av-close-on-click-tooltip') )
1696			{
1697				return;
1698			}
1699
1700			if( ! element.find( 'a' ) )
1701			{
1702				e.preventDefault();
1703			}
1704
1705			//	Default behaviour when using mouse - click on active tooltip closes it (moving mouse to another tooltip close others automatically
1706			//	On mobile devices or when using touchscreen we show element on click (= old behaviour) and hide when same element
1707			var ttip_index = element.data('avia-created-tooltip');
1708
1709			if( 'undefined' != typeof ttip_index )
1710			{
1711				var current = $.AviaTooltip.openTTs[ttip_index];
1712				if( 'undefined' != typeof current && current == this.active )
1713				{
1714					this.hide_all_tooltips();
1715				}
1716			}
1717
1718		},
1719
1720		close_on_keyup: function( e )
1721		{
1722			if( this.options.close_keys == null )
1723			{
1724				return;
1725			}
1726
1727			if( $.inArray( e.keyCode, this.options.close_keys ) < 0 )
1728			{
1729				return;
1730			}
1731
1732			this.hide_all_tooltips( e.keyCode );
1733		},
1734
1735		hide_all_tooltips: function( keyCode )
1736		{
1737			var ttip,
1738				position,
1739				element,
1740				keyCodeCheck = 'undefined' != typeof keyCode ? keyCode + '' : null;
1741
1742			for( var index = 0; index < $.AviaTooltip.openTTs.length; ++index )
1743			{
1744				ttip = $.AviaTooltip.openTTs[index];
1745				element = $.AviaTooltip.openTT_Elements[index];
1746				position = element.data('avia-tooltip-position');
1747
1748				//	check if tooltip can be closed on keyup
1749				if( keyCodeCheck != null )
1750				{
1751					var keys = ttip.data( 'close-keys' );
1752					if( 'undefined' == typeof keys )
1753					{
1754						continue;
1755					}
1756
1757					keys = keys + '';
1758					keys = keys.split( ',' );
1759					if( $.inArray( keyCodeCheck, keys ) < 0 )
1760					{
1761						continue;
1762					}
1763				}
1764
1765				this.animate_hide_tooltip( ttip, position );
1766			}
1767
1768			this.open = false;
1769			this.active  = false;
1770		},
1771
1772        hide_tooltip: function(e)
1773        {
1774            var element 	= $(e.currentTarget) , newTip, animateTo,
1775            	position	= element.data('avia-tooltip-position'),
1776                align		= element.data('avia-tooltip-alignment'),
1777				newTip		= false;
1778
1779            if( position == "" || typeof position == 'undefined' )
1780			{
1781				position = this.options.position;
1782			}
1783
1784			if( align == "" || typeof align == 'undefined' )
1785			{
1786				align = 'center';
1787			}
1788
1789            if( this.options.event == 'click' )
1790            {
1791                element = $(e.target);
1792
1793                if( ! element.is( '.' + this.options['class'] ) && element.parents( '.' + this.options['class'] ).length == 0 )
1794                {
1795                    if( this.active.length )
1796					{
1797						newTip = this.active;
1798						this.active = false;
1799					}
1800                }
1801            }
1802            else
1803            {
1804				if( ! element.hasClass( 'av-close-on-click-tooltip' ) )
1805				{
1806					newTip = element.data('avia-created-tooltip');
1807					newTip = typeof newTip != 'undefined' ? $.AviaTooltip.openTTs[newTip] : false;
1808				}
1809            }
1810
1811            this.animate_hide_tooltip( newTip, position );
1812        },
1813
1814		animate_hide_tooltip: function( ttip, position )
1815		{
1816			if(ttip)
1817            {
1818            	var animate = {opacity:0};
1819
1820            	switch(position)
1821            	{
1822            		case "top":
1823						animate['top'] = parseInt(ttip.css('top'),10) - 10;
1824						break;
1825					case "bottom":
1826						animate['top'] = parseInt(ttip.css('top'),10) + 10;
1827						break;
1828					case "left":
1829						animate['left'] = parseInt(ttip.css('left'), 10) - 10;
1830						break;
1831					case "right":
1832						animate['left'] = parseInt(ttip.css('left'), 10) + 10;
1833						break;
1834            	}
1835
1836                ttip.animate( animate, 200, function()
1837                {
1838                    ttip.css({display:'none'});
1839                });
1840			}
1841		},
1842
1843        stop_instant_open: function(e)
1844        {
1845            this.open = false;
1846        }
1847    };
1848
1849})( jQuery );
1850
1851
1852(function($)
1853{
1854	"use strict";
1855
1856	$( function()
1857	{
1858		/**
1859		 * Performance fix to pass pagespeed test
1860		 *
1861		 * https://stackoverflow.com/questions/60357083/does-not-use-passive-listeners-to-improve-scrolling-performance-lighthouse-repo#62177358
1862		 * @since 5.4
1863		 */
1864		$.event.special.touchstart = {
1865							setup: function( _, ns, handle )
1866							{
1867								this.addEventListener( "touchstart", handle, { passive: !ns.includes("noPreventDefault") } );
1868							}
1869						};
1870
1871		$.event.special.touchmove = {
1872							setup: function( _, ns, handle )
1873							{
1874								this.addEventListener( "touchmove", handle, { passive: !ns.includes("noPreventDefault") } );
1875							}
1876						};
1877
1878		$.event.special.wheel = {
1879							setup: function( _, ns, handle )
1880							{
1881								this.addEventListener( "wheel", handle, { passive: true } );
1882							}
1883						};
1884
1885		$.event.special.mousewheel = {
1886							setup: function( _, ns, handle )
1887							{
1888								this.addEventListener( "mousewheel", handle, { passive: true } );
1889							}
1890						};
1891
1892	});
1893
1894})( jQuery );
1895
1896
1897/**
1898 * Waypoints - 4.0.2
1899 * Copyright © 2011-2016 Caleb Troughton (up to 4.0.1)
1900 * Licensed under the MIT license.
1901 * https://github.com/imakewebthings/waypoints/blob/master/licenses.txt
1902 *
1903 * @since 5.2   moved to own folder /waypoints
1904 */
1905
1906
1907// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ + http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
1908// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel. can be removed if IE9 is no longer supported or all parallax scripts are gone
1909// MIT license
1910(function(){var lastTime=0;var vendors=['ms','moz','webkit','o'];for(var x=0;x<vendors.length&&!window.requestAnimationFrame;++x){window.requestAnimationFrame=window[vendors[x]+'RequestAnimationFrame'];window.cancelAnimationFrame=window[vendors[x]+'CancelAnimationFrame']||window[vendors[x]+'CancelRequestAnimationFrame']}if(!window.requestAnimationFrame)window.requestAnimationFrame=function(callback,element){var currTime=new Date().getTime();var timeToCall=Math.max(0,16-(currTime-lastTime));var id=window.setTimeout(function(){callback(currTime+timeToCall)},timeToCall);lastTime=currTime+timeToCall;return id};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=function(id){clearTimeout(id)}}());
1911
1912jQuery.expr.pseudos.regex = function(elem, index, match)
1913{
1914    var matchParams = match[3].split(','),
1915        validLabels = /^(data|css):/,
1916        attr = {
1917            method: matchParams[0].match(validLabels) ? matchParams[0].split(':')[0] : 'attr',
1918            property: matchParams.shift().replace(validLabels,'')
1919        },
1920        regexFlags = 'ig',
1921        regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
1922
1923    return regex.test(jQuery(elem)[attr.method](attr.property));
1924};

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.