PageSourceSearch

https://schoenmann.at/wp-content/themes/enfold/framework/js/conditional_load/avia_google_maps_front.js?ver=8.0

js schoenmann.at collected 2026-10-04 14:42:40 UTC 4,797 bytes, 191 lines download raw bytes

1/*
2 * This file holds javascript functions needed in frontend for the functionallity of the Google Maps widgets and shortcodes
3 * Handles conditional loading of Google API script.
4 *
5 * @author		Christian "Kriesi" Budschedl
6 * @copyright	Copyright ( c ) Christian Budschedl
7 * @link		http://kriesi.at
8 * @link		http://aviathemes.com
9 * @since		Version 1.0
10 * @package 	AviaFramework
11 *
12 */
13
14"use strict";
15
16/**
17 * Avia Google Maps in frontend
18 */
19(function($)
20{
21	var objAviaGoogleMaps = null;
22
23	var AviaGoogleMaps = function(){
24
25		if( 'undefined' == typeof window.av_google_map || 'undefined' == typeof avia_framework_globals )
26		{
27			return;
28		}
29
30		if( objAviaGoogleMaps != null )
31		{
32			return;
33		}
34
35		objAviaGoogleMaps = this;
36
37		this.document = $( document );
38		this.script_loading = false;
39		this.script_loaded = false;
40		this.script_source = avia_framework_globals.gmap_avia_api;
41		this.maps = {};
42		this.loading_icon_html = '<div class="ajax_load"><span class="ajax_load_inner"></span></div>';
43
44		this.LoadAviaMapsAPIScript();
45	};
46
47	AviaGoogleMaps.prototype = {
48
49		LoadAviaMapsAPIScript: function()
50		{
51			this.maps = $('body').find( '.avia-google-map-container' );
52			if( this.maps.length == 0 )
53			{
54				return;
55			}
56
57			//	Check if we need to load the api or we have only links to Google Maps page
58			var needToLoad = false;
59			this.maps.each(function( index ) {
60						var container = $(this);
61						if( container.hasClass('av_gmaps_show_unconditionally') || container.hasClass('av_gmaps_show_delayed') )
62						{
63							needToLoad = true;
64							return false;
65						}
66					});
67
68			if( ! needToLoad )
69			{
70				return;
71			}
72
73			/*	check if maps are disabled by user setting via cookie - or user must opt in.	*/
74			var cookie_check = $('html').hasClass('av-cookies-needs-opt-in') || $('html').hasClass('av-cookies-can-opt-out');
75			var allow_continue = true;
76			var silent_accept_cookie = $('html').hasClass('av-cookies-user-silent-accept');
77
78			if( cookie_check && ! silent_accept_cookie )
79			{
80				if( ! document.cookie.match(/aviaCookieConsent/) || $('html').hasClass('av-cookies-session-refused') )
81				{
82					allow_continue = false;
83				}
84				else
85				{
86					if( ! document.cookie.match(/aviaPrivacyRefuseCookiesHideBar/) )
87					{
88						allow_continue = false;
89					}
90					else if( ! document.cookie.match(/aviaPrivacyEssentialCookiesEnabled/) )
91					{
92						allow_continue = false;
93					}
94					else if( document.cookie.match(/aviaPrivacyGoogleMapsDisabled/) )
95					{
96						allow_continue = false;
97					}
98				}
99			}
100
101			//	allow 3-rd party plugins to hook (see enfold\config-cookiebot\cookiebot.js)
102			if( window['wp'] && wp.hooks )
103			{
104				allow_continue = wp.hooks.applyFilters( 'aviaCookieConsent_allow_continue', allow_continue );
105			}
106
107			if( ! allow_continue )
108			{
109				$('.av_gmaps_main_wrap').addClass('av-maps-user-disabled');
110				return;
111			}
112
113			//	Check if our API already loaded
114			if( typeof $.AviaMapsAPI != 'undefined' )
115			{
116				this.AviaMapsScriptLoaded();
117				return;
118			}
119
120			$('body').on( 'avia-google-maps-api-script-loaded', this.AviaMapsScriptLoaded.bind( this ) );
121
122			this.script_loading = true;
123
124			var script 	= document.createElement('script');
125					script.id = 'avia-gmaps-api-script';
126					script.type = 'text/javascript';
127					script.src 	= this.script_source;
128
129      		document.body.appendChild(script);
130		},
131
132		AviaMapsScriptLoaded: function()
133		{
134			this.script_loading = false;
135			this.script_loaded = true;
136
137			var object = this;
138
139			// Now we bind maps with AviaMapsAPI via aviaMaps
140			this.maps.each(function( index ) {
141						var container = $(this);
142
143						if( container.hasClass('av_gmaps_show_page_only') )
144						{
145							return;
146						}
147
148						var mapid = container.data('mapid');
149
150						//	skip container if no map info found
151						if( 'undefined' == typeof window.av_google_map[mapid] )
152						{
153							console.log( 'Map cannot be displayed because no info: ' + mapid);
154							return;
155						}
156
157						if( container.hasClass('av_gmaps_show_unconditionally') )
158						{
159							container.aviaMaps();
160//							container.removeClass('av_gmaps_show_unconditionally');
161						}
162						else if( container.hasClass('av_gmaps_show_delayed') )
163						{
164							var wrap = container.closest('.av_gmaps_main_wrap');
165							var confirm = wrap.find('a.av_text_confirm_link');
166
167							confirm.on('click', object.AviaMapsLoadConfirmed );
168						}
169						else
170						{
171							console.log( 'Map cannot be displayed because missing display class: ' + mapid);
172						}
173					});
174		},
175
176		AviaMapsLoadConfirmed: function( event )
177		{
178			event.preventDefault();
179
180			var confirm = $(this);
181			var container = confirm.closest('.av_gmaps_main_wrap').find('.avia-google-map-container');
182			container.aviaMaps();
183		}
184	};
185
186	$(function()
187	{
188		new AviaGoogleMaps();
189 	});
190
191})(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.