PageSourceSearch

https://banderitsch.de/wp-content/themes/enfold/framework/js/condi…/avia_google_maps_front.js?ver=5.6.8

js banderitsch.de collected 2026-10-07 04:36:14 UTC 4,572 bytes, 185 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			if( ! allow_continue )
102			{
103				$('.av_gmaps_main_wrap').addClass('av-maps-user-disabled');
104				return;
105			}
106
107			//	Check if our API already loaded
108			if( typeof $.AviaMapsAPI != 'undefined' )
109			{
110				this.AviaMapsScriptLoaded();
111				return;
112			}
113
114			$('body').on( 'avia-google-maps-api-script-loaded', this.AviaMapsScriptLoaded.bind( this ) );
115
116			this.script_loading = true;
117
118			var script 	= document.createElement('script');
119					script.id = 'avia-gmaps-api-script';
120					script.type = 'text/javascript';
121					script.src 	= this.script_source;
122
123      		document.body.appendChild(script);
124		},
125
126		AviaMapsScriptLoaded: function()
127		{
128			this.script_loading = false;
129			this.script_loaded = true;
130
131			var object = this;
132
133			// Now we bind maps with AviaMapsAPI via aviaMaps
134			this.maps.each(function( index ) {
135						var container = $(this);
136
137						if( container.hasClass('av_gmaps_show_page_only') )
138						{
139							return;
140						}
141
142						var mapid = container.data('mapid');
143
144						//	skip container if no map info found
145						if( 'undefined' == typeof window.av_google_map[mapid] )
146						{
147							console.log( 'Map cannot be displayed because no info: ' + mapid);
148							return;
149						}
150
151						if( container.hasClass('av_gmaps_show_unconditionally') )
152						{
153							container.aviaMaps();
154//							container.removeClass('av_gmaps_show_unconditionally');
155						}
156						else if( container.hasClass('av_gmaps_show_delayed') )
157						{
158							var wrap = container.closest('.av_gmaps_main_wrap');
159							var confirm = wrap.find('a.av_text_confirm_link');
160
161							confirm.on('click', object.AviaMapsLoadConfirmed );
162						}
163						else
164						{
165							console.log( 'Map cannot be displayed because missing display class: ' + mapid);
166						}
167					});
168		},
169
170		AviaMapsLoadConfirmed: function( event )
171		{
172			event.preventDefault();
173
174			var confirm = $(this);
175			var container = confirm.closest('.av_gmaps_main_wrap').find('.avia-google-map-container');
176			container.aviaMaps();
177		}
178	};
179
180	$(function()
181	{
182		new AviaGoogleMaps();
183 	});
184
185})(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.