PageSourceSearch

https://bresaolavaltellina.it/wp-content/cache/min/1/wp-content/th…/js/percorsi-map.js?ver=1788860156

js bresaolavaltellina.it collected 2026-10-02 10:50:08 UTC 5,658 bytes, 25 lines download raw bytes

1(function($){let map,markers=[],infoWindows=[];let originalGridHtml=null;let currentPage=1,maxPages=1;const perPage=percorsiMapData.perPage||12;$(document).ready(function(){const $grid=$('#percorsi-grid');if($grid.length)originalGridHtml=$grid.html();initMap();initCollapsibleFilters();initCheckboxListeners();initClearFilters();initLoadMore();fetchData(!0)});function initMap(){const el=document.getElementById('percorsi-map');if(!el)return;map=new google.maps.Map(el,{center:{lat:45.9,lng:10.8},zoom:6.5,maxZoom:15,minZoom:5,styles:[],streetViewControl:!1,mapTypeControl:!1,restriction:{latLngBounds:{north:47.5,south:44,west:6.5,east:18.5},strictBounds:!0}});drawMarkers(percorsiMapData.markers);recenterMap();updateFilterState(percorsiMapData.markers)}
2function drawMarkers(data){clearMarkers();const counts={};data.forEach(o=>{counts[`${o.latitude},${o.longitude}`]=(counts[`${o.latitude},${o.longitude}`]||0)+1});const idxMap={};data.forEach(o=>{const key=`${o.latitude},${o.longitude}`;if(counts[key]>1){idxMap[key]=(idxMap[key]||0)+1;o.__dupIndex=idxMap[key]-1;o.__dupTotal=counts[key]}});data.forEach(createMarker)}
3function clearMarkers(){markers.forEach(m=>m.setMap(null));markers=[];infoWindows.forEach(iw=>iw.close());infoWindows=[]}
4function createMarker(o){let lat=+o.latitude,lng=+o.longitude;if(o.__dupTotal>1){const zoom=map.getZoom(),offset=0.0005*(12/zoom),angle=2*Math.PI*(o.__dupIndex/o.__dupTotal);lat+=Math.sin(angle)*offset;lng+=Math.cos(angle)*offset}
5const icon=o.pin_icon?{url:o.pin_icon,scaledSize:new google.maps.Size(40,40),anchor:new google.maps.Point(20,40)}:{url:'data:image/svg+xml;charset=UTF-8,'+encodeURIComponent(`
6            <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80">
7              <circle cx="40" cy="40" r="15" fill="#80A7DD" stroke="#80A7DD" stroke-width="25" stroke-opacity="0.3"/>
8              <path d="M45.5,41h-4.4v4.3h-2v-4.3h-4.4v-1.9h4.4v-4.3h2v4.3h4.4v1.9Z"/>
9            </svg>
10          `),scaledSize:new google.maps.Size(40,40),anchor:new google.maps.Point(20,40)};const marker=new google.maps.Marker({map,position:{lat,lng},title:o.title,icon});const iw=new google.maps.InfoWindow({content:`
11          <a href="${o.permalink}" target="_blank">
12            ${o.featured_img_url?`<img src="${o.featured_img_url}"/>`:''}
13            <div class="iw_occhiello">${o.acf_occhiello}</div>
14            <h3>${o.acf_titolo}</h3>
15          </a>`});marker.addListener('click',()=>{infoWindows.forEach(w=>w.close());iw.open({anchor:marker,map,shouldFocus:!1})});markers.push(marker);infoWindows.push(iw)}
16function recenterMap(){if(!markers.length){map.fitBounds(new google.maps.LatLngBounds({lat:44,lng:6.5},{lat:47.5,lng:18.5}))}else if(markers.length===1){map.setCenter(markers[0].getPosition());map.setZoom(12)}else{const b=new google.maps.LatLngBounds();markers.forEach(m=>b.extend(m.getPosition()));map.fitBounds(b)}}
17function initCollapsibleFilters(){$('.percorsi-filter-group .filter-header').on('click',function(){const $g=$(this).closest('.percorsi-filter-group');$('.percorsi-filter-group .filter-content').not($g.find('.filter-content')).slideUp(200);$('.percorsi-filter-group .filter-header').not(this).removeClass('active');$g.find('.filter-content').slideToggle(200);$(this).toggleClass('active')})}
18function initCheckboxListeners(){$(document).on('change','.percorsi-filters input[type="checkbox"]',function(){currentPage=1;fetchData(!0)})}
19function updateFilterState(data){const tipSet=new Set(),locSet=new Set();data.forEach(o=>{(o.categories||[]).forEach(c=>tipSet.add(c));(o.locations||[]).forEach(l=>locSet.add(l))});$('input[name="tipologie[]"]').each(function(){const ok=tipSet.has(this.value);$(this).prop('disabled',!ok).closest('label').toggleClass('disabled',!ok);if(!ok)$(this).prop('checked',!1)});$('input[name="locations[]"]').each(function(){const ok=locSet.has(this.value);$(this).prop('disabled',!ok).closest('label').toggleClass('disabled',!ok);if(!ok)$(this).prop('checked',!1)})}
20function initClearFilters(){const label=percorsiMapData.clearFiltersText||'Elimina Filtri';$('<button id="clear-filters">'+label+'</button>').appendTo('.percorsi-filters').on('click',function(){$('.percorsi-filters input[type="checkbox"]').prop('checked',!1).prop('disabled',!1).closest('label').removeClass('disabled');drawMarkers(percorsiMapData.markers);updateFilterState(percorsiMapData.markers);recenterMap();currentPage=1;$('#percorsi-grid').html(originalGridHtml);resetLoadMore()})}
21function initLoadMore(){$('#load-more-percorsi').on('click',function(){currentPage++;const $btn=$(this).prop('disabled',!0).text('Loading...');fetchData(!1)})}
22function resetLoadMore(){$('#load-more-percorsi').data('page',1).show().prop('disabled',!1).text('Load More')}
23function fetchData(replaceGrid){const tips=$('input[name="tipologie[]"]:checked').map((i,el)=>el.value).get();const locs=$('input[name="locations[]"]:checked').map((i,el)=>el.value).get();$.post(percorsiMapData.ajaxUrl,{action:'percorsi_filter',tipologie:tips,locations:locs,page:currentPage,per_page:perPage},function(res){if(!res.success)return;const d=res.data;maxPages=d.max_pages||1;if(replaceGrid){drawMarkers(d.markers);updateFilterState(d.markers);recenterMap()}
24if(replaceGrid){$('#percorsi-grid').html(d.grid_html)}else{const $tmp=$('<div>').append(d.grid_html);$('#percorsi-grid .related_items').append($tmp.find('.related_items').html())}
25const $btn=$('#load-more-percorsi');if(currentPage<maxPages){$btn.show().prop('disabled',!1).text('Load More')}else{$btn.hide().prop('disabled',!1).text('Load More')}}).fail(function(){$('#load-more-percorsi').prop('disabled',!1).text('Errore, riprova')})}})(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.