HEX
Server: LiteSpeed
System: Linux linux31.centraldnserver.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: salamatk (1501)
PHP: 8.1.33
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open
Upload Files
File: /home/salamatk/takarzan.ir/wp-content/themes/xts-luman/js/scripts/googleMapElement.js
/* global xts_settings */
(function($) {
	XTSThemeModule.xtsElementorAddAction('frontend/element_ready/xts_google_map.default', function() {
		XTSThemeModule.googleMapInit();
		XTSThemeModule.googleMapCloseContent();
	});

	XTSThemeModule.googleMapInit = function() {
		if ( typeof google === 'undefined' ) {
			return;
		}

		$('.xts-map').each(function() {
			var $map = $(this);
			var data = $map.data('map-args');

			var config = {
				locations: [
					{
						lat: data.latitude,
						lon: data.longitude,
						icon: data.marker_icon,
						animation: google.maps.Animation.DROP,
					},
				],
				controls_on_map: false,
				map_div: '#' + data.selector,
				start: 1,
				map_options: {
					zoom: parseInt(data.zoom),
					scrollwheel: 'yes' === data.mouse_zoom,
					disableDefaultUI: data.default_ui,
				},
			};

			if (data.json_style) {
				config.styles = {};
				config.styles[xts_settings.google_map_style_text] = JSON.parse(atob(data.json_style));
			}

			if ('yes' === data.marker_text_needed) {
				config.locations[0].html = data.marker_text;
			}

			if ('button' === data.lazy_type) {
				$map.find('.xts-map-button').on('click', function(e) {
					e.preventDefault();

					if ($map.hasClass('xts-loaded')) {
						return;
					}

					$map.addClass('xts-loaded');
					new Maplace(config).Load();
				});
			} else if ('scroll' === data.lazy_type) {
				XTSThemeModule.$window.on('scroll', function() {
					if ((window.innerHeight + XTSThemeModule.$window.scrollTop() + 100) > $map.offset().top) {
						if ($map.hasClass('xts-loaded')) {
							return;
						}

						$map.addClass('xts-loaded');
						new Maplace(config).Load();
					}
				});

				XTSThemeModule.$window.scroll();
			} else {
				new Maplace(config).Load();
			}
		});
	};

	XTSThemeModule.googleMapCloseContent = function() {
		var $map = $('.xts-map-close');

		if ( $map.hasClass('xts-inited') ) {
			return;
		}

		$map.addClass('xts-inited');

		$map.on('click', function(e) {
			e.preventDefault();
			$(this).parent().toggleClass('xts-opened');
		});
	};

	$(document).ready(function() {
		XTSThemeModule.googleMapInit();
		XTSThemeModule.googleMapCloseContent();
	});
})(jQuery);