PageSourceSearch

https://www.gitefuoriportainpiemonte.it/wp-content/themes/ziston/js/listing/listing.js?ver=6.7.5

js gitefuoriportainpiemonte.it collected 2026-09-25 09:30:59 UTC 18,938 bytes, 500 lines download raw bytes

1(function($) {
2
3  var markers = [], points =[], map, marker_center, lat_lng_list = [], bounds; 
4  var ZistonListing = {
5
6		init: function(){
7
8		  this.initMap();
9		  this.uiSlider();
10		  this.iniSelect2();
11		  this.heightMap();
12		  this.updateListings();
13		  this.sortingResults();
14		  this.initRegions();
15		  this.initMobile();
16		  this.other();
17		},
18
19		locationAutoComplete: function(L){
20		  var geocoder = new L.Control.Geocoder.Nominatim();
21		  var timeout = null;
22
23		  	$('.id_listing_location_text').on('keyup', function(e) {
24			 	e.preventDefault();
25			 	var text = $(this).val();
26			 	clearTimeout(timeout);
27			 	if( text) {
28					timeout = setTimeout(function() {
29						geocoder.geocode(text, function(data) {
30							var html = '';
31						  	for (var i = 0; i < data.length; i++) {
32							 	html += '<li class="location-item">';
33									html += '<a class="location-item-link" data-lat="' + data[i].center.lat + '" data-lng="' + data[i].center.lng + '" >';
34									  	html += '<i class="icon fa fa-map-marker"></i>';
35									  	html += '<span class="name">' + data[i].name + '</span>';
36									  	html += '<span class="information hidden">';
37										 	if(data[i].properties.address.state){
38												html += '<span class="country">State: ' + data[i].properties.address.state + '</span> - ';
39										 	}
40									 		if(data[i].properties.address.city){
41												html += '<span class="city">City: ' + data[i].properties.address.city + '</span> - ';
42									 		}
43									 		if(data[i].properties.address.country){
44												html += '<span class="country">Country: ' + data[i].properties.address.country + '</span>';
45									 		}
46											if(data[i].properties.address.country_code){
47												html += '<span class="country_code">(' + data[i].properties.address.country_code + ')</span>';
48									 		}
49								 		html +='</span>';
50									html + '</a>';
51							 	html += '</li>';
52						  	}
53						  	if ( html ) {
54							 	$('.places_list_autocomplete').html('<ul>' + html + '</ul>').css('display', 'block');
55						  	}
56						});
57					}, 600);
58			 	}else{
59					$(".places_list_autocomplete").html('').css('display', 'none');
60					$('input#lt_filter_location_value').val('').trigger('change');
61			 	}
62		  	});
63
64		  	$('.places_list_autocomplete').delegate('.location-item-link', 'click', function(){
65			 	var position = {lat: $(this).data('lat'), lng: $(this).data('lng')};
66		  	});
67
68		  	$('.places_list_autocomplete').delegate('.location-item-link', 'click', function(){
69			 	var position = {lat: $(this).data('lat'), lng: $(this).data('lng')};
70			 	$('.places_list_autocomplete').html('').css('display', 'none');
71			 	$('.id_listing_location_text').val($(this).find('.name').text())
72			 	$('input#lt_filter_location_value').val(position['lat'] + ',' + position['lng']).trigger('change'); 
73		  	});
74
75		},
76
77		getPoints: function(){
78
79		  	$('.job_listings .listing-block').each(function(){
80			 	var id = $(this).find('.data-id').text();
81			 	var lat = $(this).find('.data-lat').html();
82			 	var lon = $(this).find('.data-lon').html();
83			 	var html = $(this).find('.data-html').html();
84			 	var icon = '', cat_color = '';
85			 
86			 	$(this).find('.data-logo').each(function(){
87					if($(this).html()){
88				  		icon = $(this).html();
89					}
90			 	}); 
91
92			 	$(this).find('.data-category-color').each(function(){
93					if($(this).html()){
94				  		cat_color = $(this).html();
95					}
96			 	}); 
97			 	if(lat && lon){
98			 		var tmp = [id, lat, lon, html, icon, cat_color];
99			 		points.push(tmp); 
100			 	}	
101		  })
102		},
103
104		initMap: function(){
105
106			ZistonListing.locationAutoComplete(L);
107		  	var listing_map = $('#lt-listing--map');
108		  	if(listing_map.length == 0) return;
109
110		  	var map_options = {
111				latitude					: ziston_map_options.latitude,
112				longitude				: ziston_map_options.longitude,
113				map_zoom					: ziston_map_options.map_zoom,
114				map_source				: ziston_map_options.map_source,
115				mapbox_token			: ziston_map_options.mapbox_token,
116				mapbox_style			: ziston_map_options.mapbox_style,
117				google_map_style		: ziston_map_options.google_map_style,
118				mode						: ziston_map_options.mode
119			};
120		  
121			if(points[0]){
122			  	var location_0 = points[0];
123			  	latlng = L.latLng( location_0[0], location_0[1] );
124			}else{
125				if( map_options.latitude && map_options.longitude ){
126			  		latlng = L.latLng(map_options.latitude, map_options.longitude);
127				}else{
128			  		latlng = L.latLng('42.7247484', '-78.0127572');
129				}
130			}
131		
132			map = L.map('lt-listing--map',{
133				//zoomControl:false
134				//zoomSnap: 0.1,
135			}
135).setView(latlng, map_options.map_zoom);
136
137			//--Ctrl + mousewhell zoom
138      	map.scrollWheelZoom.disable();
139        $("#lt-listing--map").bind('mousewheel DOMMouseScroll', function (event) {
140          event.stopPropagation();
141          if (event.ctrlKey == true) {
142            event.preventDefault();
143            map.scrollWheelZoom.enable();
144            $('#lt-listing--map').removeClass('map-scroll');
145            setTimeout(function(){
146              map.scrollWheelZoom.disable();
147            }, 1000);
148          } else {
149            map.scrollWheelZoom.disable();
150            $('#lt-listing--map').addClass('map-scroll');
151          }
152        });
153
154        $(window).bind('mousewheel DOMMouseScroll', function (event) {
155          $('#lt-listing--map').removeClass('map-scroll');
156        })
157       //-- End zoom
158
159
160		  	if(map_options.map_source == 'mapbox'){
161			 	//--- Use map_source mapbox
162			 	//https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}{r}.png
163			 	//https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}
164			 	//https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
165			 	L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
166					attribution: '',
167					maxZoom: 18,
168					id: map_options.mapbox_style,
169					tileSize: 512,
170       			zoomOffset: -1,
171					accessToken: map_options.mapbox_token,
172			 	}).addTo(map)
173				//--- Use map_source mapbox
174		  	}
175
176		  	if(map_options.map_source == 'openstreetmap'){
177		  		L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
178					attribution: '',
179					maxZoom: 18,
180			 	}).addTo(map)
181		  	}
182
183		  	if(map_options.map_source == 'google'){
184		   	//--- Use map_source google map
185	         var styles_gray = [{ "featureType": "administrative", "elementType": "labels.text.fill", "stylers": [ { "color": "#444444" } ] }, { "featureType": "landscape", "elementType": "all", "stylers": [ { "color": "#f2f2f2" } ] }, { "featureType": "poi", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "road", "elementType": "all", "stylers": [ { "saturation": -100 }, { "lightness": 45 } ] }, { "featureType": "road.highway", "elementType": "all", "stylers": [ { "visibility": "simplified" } ] }, { "featureType": "road.arterial", "elementType": "labels.icon", "stylers": [ { "visibility": "off" } ] }, { "featureType": "transit", "elementType": "all", "stylers": [ { "visibility": "off" } ] }, { "featureType": "water", "elementType": "all", "stylers": [ { "color": "#cae5f0" }, { "visibility": "on" } ] }];
186	         
187	         var styles = [];
188	         if(map_options.google_map_style){
189	         	styles = JSON.parse(map_options.google_map_style);
190	         }
191	         var google_map = L.gridLayer.googleMutant({
192	          	type: 'roadmap',
193	          	maxZoom: 18,
194	          	gestureHandling: 'greedy',
195	          	styles: styles
196	        	}).addTo(map);
197
198	        //--- Use map_source google map
199		   }
200
201		   if(map_options.mode == 'single'){
202				var cat_color = 'red';
203			 	var icon_svg = '<svg version="1.1" id="listing-single-icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512.443 512.443" style="enable-background:new 0 0 512.443 512.443;" xml:space="preserve"><g><g><path d="M220.643,3.003c-71.68,12.8-128,71.68-140.8,143.36c-12.8,69.12,15.36,133.12,64,171.52c48.64,40.96,84.48,94.72,102.4,156.16l10.24,38.4l12.8-38.4c17.92-64,58.88-117.76,107.52-161.28c35.84-30.72,58.88-79.36,58.88-133.12C435.683,69.563,335.843-17.477,220.643,3.003z M256.483,282.043c-56.32,0-102.4-46.08-102.4-102.4s46.08-102.4,102.4-102.4s102.4,46.08,102.4,102.4S312.803,282.043,256.483,282.043z"/></g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g></svg>';
204
205				var icon = new L.DivIcon({
206				  	iconSize: [54, 54],
207				  	iconAnchor: [27, 54],
208				  	popupAnchor: [0, -26],
209				  	className: 'gva-icon-map color-' + cat_color,
210				  	html: '<span class="icon-map">' + icon_svg + '<span class="icon-cat"><i class=""></i></span></span>'
211				});
212			
213				var marker = L.marker(L.latLng( map_options.latitude, map_options.longitude ), { icon: icon } );
214				map.addLayer(marker);
215		   	return;
216		   }
217
218		  	// ---Reload Map after update results by ajax
219		  	markers = new L.markerClusterGroup();
220		  	$('.job_listings').on('updated_results', function(e, result) {
221
222			 	lat_lng_list = [];
223			 	points = [];
224			 	ZistonListing.getPoints();
225
226			 	//console.log('------- Points -------')
227			 	//console.log(points);
228
229			 	if(points.length == 0){
230			 		navigator.geolocation.getCurrentPosition(function(location) {
231					 	map.setView(L.latLng(location.coords.latitude, location.coords.longitude), 12);
232				 	});
233				 	return;
234			 	}
235
236			 	if(markers != 'undefined'){
237				  	map.removeLayer(markers);
238			 	}
239
240			 	//marker_center = L.marker(latlng);
241
242			 	//map.addLayer(marker_center);
243
244			 	markers = new L.markerClusterGroup();
245
246			 	var markerList = [];
247			 	var icon_svg = '';
248			 
249			 	for (var i = 0; i < points.length; i++) {
250					var point = points[i];
251					var popup = point[3];
252					var cat_color = point[5];
253					icon_svg = ZistonListing.svgPin(cat_color);
254					var icon = new L.DivIcon({
255					  	iconSize: [54, 54],
256					  	iconAnchor: [27, 54],
257					  	popupAnchor: [0, -26],
258					  	className: 'gva-logo-map',
259					  	html: '<span class="logo-map">' + icon_svg + '<span class="lt-logo">' + point[4] + '</span></span>'
260					});
261				
262					var marker = L.marker(L.latLng(point[1], point[2]), { icon: icon, post_id: point[0] }).bindPopup(popup, {'maxWidth': '500','className' : 'custom'});
263
264					markers.addLayer(marker);
265				
266					markerList.push(marker);
267
268			  		lat_lng_list.push([point[1], point[2]]);
269			 	}
270			
271
272			 	navigator.geolocation.getCurrentPosition(function(location) {
273				 	  var marker = L.marker(L.latLng(location.coords.latitude, location.coords.longitude));
274				 	  markers.addLayer(marker);
275				 	  markerList.push(marker);
276			 	});
277
278				map.addLayer(markers);
279				bounds = new L.LatLngBounds(lat_lng_list);
280				var fit_bounds = map.fitBounds(bounds, { 'padding': [150, 150] });	
281				if($(window).width() < 560){
282					map.setZoom(2);
283				}
284				// var fit_bounds = map.fitBounds(bounds, { 'padding': [10, 10] });	
285				
286				
287
288			}); // End update ajax event
289
290			$('a.gva-open-map').on('click', function(e){
291			  	e.preventDefault();
292			  	$(this).parents('.map-layout-wrapper').find('.main-map-wrapper').removeClass('d-none d-md-none d-sm-none');
293			  	$(this).parents('.map-layout-wrapper').find('.main-listing-wrapper').addClass('d-none d-md-none d-sm-none');
294			  	$(this).parent('.control-open-map-listtings').find('a.gva-open-map').addClass('d-none');
295			  	$(this).parent('.control-open-map-listtings').find('a.gva-open-listings').removeClass('d-none');
296			  	$(this).parents('.map-action-mobile').addClass('map-open');
297			  	map._onResize();
298			});
299
300			$('a.gva-open-listings').on('click', function(e){
301			  	e.preventDefault();
302			  	$(this).parents('.map-layout-wrapper').find('.main-map-wrapper').addClass('d-none d-md-none d-sm-none');
303			  	$(this).parents('.map-layout-wrapper').find('.main-listing-wrapper').removeClass('d-none d-md-none d-sm-none');
304			  	$(this).parent('.control-open-map-listtings').find('a.gva-open-listings').addClass('d-none');
305			  	$(this).parent('.control-open-map-listtings').find('a.gva-open-map').removeClass('d-none');
306			  	$(this).parents('.map-action-mobile').removeClass('map-open');
307			});
308
309		},
310
311		svgPin: function(color){
312			var icon_svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="54px" height="54px" viewBox="0 0 54 54" style="enable-background:new 0 0 54 54;" xml:space="preserve">';
313			 	icon_svg += '<path class="pin-st0" fill="' + color + '" d="M27,54C27,54,27,54,27,54c0.7,0,1.3-0.3,1.7-0.8C41.1,38,47,29.2,47,20.3C47,9.1,38,0,27,0S7,9.1,7,20.3c0,8.7,5.6,17.2,18.3,32.9C25.7,53.7,26.3,54,27,54z"></path>';
314			 	icon_svg += '<path class="pin-st1" fill="' + color + '" d="M27,1C16.5,1,8,9.6,8,20.1c0,8.2,5.4,16.2,17.4,31.1c0.4,0.5,1,0.8,1.6,0.8c0,0,0,0,0,0c0.6,0,1.2-0.3,1.6-0.8C40.4,36.9,46,28.6,46,20.1C46,9.6,37.5,1,27,1z M27,36c-8.8,0-16-7.2-16-16S18.2,4,27,4c8.8,0,16,7.2,16,16S35.8,36,27,36z"></path>';
315			 	icon_svg += '</svg>';
316			 	return icon_svg;
317		},
318
319		updateListings: function(){
320			$('.job_listings').on('updated_results', function(e, result) {
321				$('.lt_results-sorting .results-text .results-number').html(result.found);
322			});
323		},
324
325		initRegions: function(){
326			if($('#filter-listing-country').length == 0) return;
327		  	var cities_data = ziston_region_cities.region_cities;
328		  	var value = ziston_region_cities.default_value;
329		  	var select_country = $('#filter-listing-country');
330		  	var country = select_country.val();
331		  	ZistonListing.loadRegions(cities_data, country, value);
332		  
333		  //Load Cities when select Country
334		  	select_country.on('change', function(){
335			 	var country = $(this).val();
336			 	ZistonListing.loadRegions(cities_data, country, value);
337		  	});
338		},
339
340		loadRegions: function(cities_data, country, default_value){
341		  
342		  $('#filter-listing-city').addClass('loading');
343		  	var html_cities_option = '<option value="">' + ziston_region_cities.str_select_city + '</option>';
344		  	for(var i = 0; i< cities_data.length; i++){
345			 	if(cities_data[i]['parent'] == country){
346					var selected = '';
347					if(default_value == cities_data[i]['id']) selected = ' selected="selected"';
348					html_cities_option += '<option value="' + cities_data[i]['id'] + '"' + selected + '>' + cities_data[i]['name'] + '</option>';
349			 	}
350		  	}
351		  	$('#filter-listing-city').html(html_cities_option);
352		  	setTimeout(function() {
353			 	$('#filter-listing-city').removeClass('loading');
354		  	}, 500);
355
356		},
357
358		hasAnyClass: function(element, classes, prefix) {
359		  	for (var i = 0; i < classes.length; i++) {
360			 	if ( element.hasClass(prefix + classes[i]) ) {
361					return true;
362			 	}
363		  	}
364		  	return false;
365		},
366
367		uiSlider: function(){
368			if($('.lt-filter-slider').length == 0) return;
369			$('.lt-filter-slider').each(function(){
370				var _slider = $(this);
371          	var _input = _slider.parents('.lt-filter-distance-slider').find('input[name*=lt_filter_distance]');
372          	var _text = _slider.parents('.lt-filter-distance-slider').find('.value-text');
373          	var _value = _input.val();
374          	$(this).slider({
375              	range: "min",
376              	value: _value,
377              	min: 1,
378              	max: 120,
379              	slide: function( event, ui ) {
380                  _text.text(ui.value);
381              	},
382              	stop: function( event, ui ) {
383                  $('.lt-distance-slider-ui', _slider).attr( "data-value", ui.value );
384                  _input.val( ui.value ).trigger('change');
385              	}
386          	});
387      	});
388		},
389
390		iniSelect2: function(){
391			if($.fn.select2){
392			  	$('.option-select2-filter').each(function(){
393				 	var placeholder = $(this).attr('placeholder');
394				 	$(this).select2({
395						allowClear : true,
396						theme: 'default option-select2-filter',
397						placeholder: placeholder
398				 	}); 
399			  	});
400
401			  	$('.list_job_types').select2({
402			  		placeholder: (typeof ziston_lt_types !== 'undefined') ? ziston_lt_types.str_select_type : '',
403				 	allowClear : true,
404			  	});
405
406				$('.option-select2-filter, .list_job_types').on('select2:unselecting', function(e) {
407			  		$(this).on('select2:opening', function(e) {
408						e.preventDefault();
409			  		});
410				});
411				
412				$('.option-select2-filter, .list_job_types').on('select2:unselect', function(e) {
413			 		var sel = $(this);
414			 		setTimeout(function() {
415						sel.off('select2:opening');
416			 		}, 1);
417				});
418			}
419		},
420
421		heightMap: function(){
422
423			var listing_map = $('#lt-listing--map');
424		  	if(listing_map.length == 0) return;
425
426			var headerHeight = $('.header-builder-frontend').height();
427			var headerFixedHeight= $('.gv-sticky-wrapper').height();
428			listing_map.css('top', headerHeight);
429
430			if( $('.gv-sticky-menu').length > 0 ){
431				$(window).on('scroll', function () {
432					if($('body').hasClass('header-is-fixed')){
433						listing_map.css('top', headerFixedHeight);
434					}else{
435						listing_map.css('top', headerHeight);
436					}
437				});
438			}
439
440		},
441
442		sortingResults: function(){
443			var _sorting = $('.select_lt_results_sorting');
444			var _input = $('.lt_results_sorting');
445			_input.val(_sorting.val());
446			_sorting.on('change', function(){
447				_input.val($(this).val());
448				_input.trigger('change');
449			});
450		},
451
452		initMobile: function(){
453			$('.btn-show-map').on('click', function(e){
454				e.preventDefault();
455				$(this).parents('.lt--content-inner').addClass('show-map').removeClass('show-content');
456			});
457			$('.btn-show-content').on('click', function(e){
458				e.preventDefault();
459				$(this).parents('.lt--content-inner').addClass('show-content').removeClass('show-map');
460			});
461
462			$('.control-search-mobile').on('click', function(e){
463				e.preventDefault();
464				if( $(this).parent().hasClass('open') ){ 
465					$(this).parent().removeClass('open');
466				}else{
467					$(this).parent().addClass('open');
468				}
469			});
470		},
471
472		other: function(){
473			var element = $('.lt-filter-by-amenities .filter-by-amenities');
474			$('.lt-filter-by-amenities .title').on('click', function(){
475				if( !element.is(':visible') ) {
476					element.slideDown('normal');
477				}else{
478					element.slideUp('normal');
479				}
480			})
481
482			$('.lt-listing-search-form .lt-search-form-main .form-action .btn-action').on('click', function(e){
483				e.preventDefault();
484				var _form = $(this).parents('.lt-search-form-main');
485				sessionStorage.clear();
486				var url = _form.attr('action') + '?' + _form.serialize();
487				window.location.href = url;
488			});
489
490		}
491
492	}
493
494	$(document).ready(function(){
495		ZistonListing.init();
496
497	});
498
499
500})(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.