PageSourceSearch

https://franciacorta.wine/wp-content/themes/franciacorta-theme/assets/scripts/index.js

js franciacorta.wine collected 2026-10-02 06:06:37 UTC 15,397 bytes, 507 lines download raw bytes

1(function ($) {
2
3  if ($("body").hasClass("single-interesse") || $("body").hasClass("single-cantine")) {
4    var pathname = window.location.pathname;
5    if (pathname.includes("/qrcode/")) {
6      const elements = document.getElementsByClassName('wpml-ls-link');
7      for (const element of elements) {
8        element.href = element.href + 'qrcode/';
9      }
10    }
11  }
12
13  // enable glider on disciplinare
14  //if ($("body").hasClass("single-istituzionali")) {
15  if ($("body").hasClass("disciplinare") ||
16    $("body").hasClass("regulations") ||
17    $("body").hasClass("spezifikation")
18  ) {
19
20    window.addEventListener('load', function () {
21
22      // if (window.innerWidth >= 768) {
23      //   var glide = new Glider(document.querySelector('.glider-disciplinare'), {
24      //     slidesToShow: 'auto',
25      //     slidesToScroll: 'auto',
26      //     itemWidth: 150,
27      //     exactWidth: true,
28      //     draggable: true,
29      //     scrollLock: false
30      //   });
31      // }
32
33      // const parent = document.querySelector(".glider-disciplinare");
34      // const childrens = document.querySelectorAll(".glider-slide");
35      // const child = document.querySelector(".glider-slide a");
36
37      // Array.prototype.forEach.call(document.querySelectorAll(".glider-slide"), function (element) {
38      //   element.onclick = addActive;
39      // });
40
41      // function addActive(element) {
42      //   childrens.forEach(function (elem) {
43      //     elem.classList.remove("active");
44      //   });
45      //   element = this;
46      //   if (element.classList.contains("active")) {
47      //     element.classList.remove("active");
48      //   } else {
49      //     element.classList.add("active");
50      //   }
51      // }
52    });
53  }
54
55  const queryString = window.location.search;
56  const urlParams = new URLSearchParams(queryString);
57  
58  if ($("body").hasClass("single-esperienze") || $("body").hasClass("page-id-6463") || ($("body").hasClass("visite-eventi-territorio") && !urlParams.has('l'))) {  // dove degustare pagina da eliminare
59
60    window.addEventListener('load', function () {
61      window.FC_GLIDER = new Glider(document.querySelector('.glider-random'), {
62        slidesToShow: 'auto',
63        slidesToScroll: 'auto',
64        itemWidth: 260,
65        exactWidth: true,
66        draggable: false,
67        scrollLock: false,
68        scrollLockDelay: 100,
69        duration: 1,
70        responsive: [
71          {
72            // screens greater than >= 576px
73            breakpoint: 576,
74            settings: {
75              itemWidth: 300,
76              draggable: true,
77              scrollLock: true,
78            }
79          }
80        ]
81      });
82
83    });
84  }
85
86  function initMap($el) {
87    var $markers = $el.find('.marker');
88    var mapArgs = {
89      zoom: $el.data('zoom') || 16,
90      mapTypeId: google.maps.MapTypeId.ROADMAP,
91    };
92    var map = new google.maps.Map($el[0], mapArgs);
93    map.markers = [];
94    $markers.each(function () {
95      initMarker($(this), map);
96    });
97    centerMap(map);
98    return map;
99  }
100  function initMarker($marker, map) {
101    var lat = $marker.data('lat');
102    var lng = $marker.data('lng');
103    var latLng = {
104      lat: parseFloat(lat),
105      lng: parseFloat(lng),
106    };
107    var marker = new google.maps.Marker({
108      position: latLng,
109      map: map,
110    });
111    map.markers.push(marker);
112    if ($marker.html()) {
113      var infowindow = new google.maps.InfoWindow({
114        content: $marker.html(),
115      });
116      google.maps.event.addListener(marker, 'click', function () {
117        infowindow.open(map, marker);
118      });
119    }
120  }
121  function centerMap(map) {
122    var bounds = new google.maps.LatLngBounds();
123    map.markers.forEach(function (marker) {
124      bounds.extend({
125        lat: marker.position.lat(),
126        lng: marker.position.lng(),
127      });
128    });
129    if (map.markers.length == 1) {
130      map.setCenter(bounds.getCenter());
131    } else {
132      map.fitBounds(bounds);
133    }
134  }
135
136  $('.acf-map').each(function () {
137    var map = initMap($(this));
138  });
139
140   $('p:empty').not('[role="status"]').remove();
141
142  $(window).scroll(function () {
143    var scroll = $(window).scrollTop();
144
145    //if($("html").hasClass('mobile-menu-open')) $ ('#masthead').addClass ('shrink');
146
147    if (scroll >= 250) {
148      $('#masthead').addClass('shrink');
149    } else {
150      $('#masthead').removeClass('shrink');
151    }
152  });
153
154  const target = document.querySelector('#masthead');
155
156  document.addEventListener('click', (event) => {
157    const withinBoundaries = event.composedPath().includes(target)
158    if (!withinBoundaries && $("html").hasClass('mobile-menu-open')) {
159      $("html").removeClass('mobile-menu-open');
160      $("#mobile-menu-control-wrapper").removeClass('toggled');
161      $("#site-navigation").removeClass('toggled');
162    }
163  })
164
165  const followUsHeaderOverlayToggle = document.getElementById(
166    'openCloseHeaderFollowUsOverlay'
167  );
168
169  const followUsHeaderOverlay = document.getElementById(
170    'header-follow-us-overlay'
171  );
172
173  let isHeaderOverlayOpen = false;
174
175  followUsHeaderOverlayToggle.addEventListener('click', () => {
176    if (isHeaderOverlayOpen === false) {
177      followUsHeaderOverlay.classList.add('open');
178      followUsHeaderOverlayToggle.classList.add('active');
179      isHeaderOverlayOpen = true;
180
181      if (isHeaderOverlayOpen2 == true) {
182        languageHeaderOverlay.classList.remove('open');
183        languageHeaderOverlayToggle.classList.remove('active');
184        isHeaderOverlayOpen2 = false;
185      }
186
187    } else {
188      followUsHeaderOverlay.classList.remove('open');
189      followUsHeaderOverlayToggle.classList.remove('active');
190      isHeaderOverlayOpen = false;
191
192    }
193  });
194
195  const languageHeaderOverlayToggle = document.getElementById(
196    'openCloseHeaderLanguageOverlay'
197  );
198  const languageHeaderOverlay = document.getElementById(
199    'header-language-overlay'
200  );
201
202  let isHeaderOverlayOpen2 = false;
203
204  languageHeaderOverlayToggle.addEventListener('click', () => {
205    if (isHeaderOverlayOpen2 === false) {
206
207      languageHeaderOverlay.classList.add('open');
208      languageHeaderOverlayToggle.classList.add('active');
209      isHeaderOverlayOpen2 = true;
210
211      if (isHeaderOverlayOpen == true) {
212        followUsHeaderOverlay.classList.remove('open');
213        followUsHeaderOverlayToggle.classList.remove('active');
214        isHeaderOverlayOpen = false;
215      }
216
217    } else {
218      languageHeaderOverlay.classList.remove('open');
219      languageHeaderOverlayToggle.classList.remove('active');
220      isHeaderOverlayOpen2 = false;
221    }
222  });
223
224  let infoToggleStatus = false;
225  const infoToggle = document.querySelector('.intestazione-servizi');
226  const infoElement = document.querySelector('ul.servizi');
227
228  let infoToggleStatus2 = false;
229  const infoToggle2 = document.querySelector('.intestazione-lingue');
230  const infoElement2 = document.querySelector('ul.lingue');
231
232  let infoToggleStatus3 = false;
233  const infoToggle3 = document.querySelector('.intestazione-riconoscimenti-premi');
234  const infoElement3 = document.querySelector('div.acf-riconoscimenti-premi p');
235
236  let infoToggleStatus4 = false;
237  const infoToggle4 = document.querySelector('.intestazione-prodotti_tipici');
238  const infoElement4 = document.querySelector('div.acf-prodotti_tipici p');
239
240  let infoToggleStatus5 = false;
241  const infoToggle5 = document.querySelector('.intestazione-numero-posti');
242  const infoElement5 = document.querySelector('div.acf-numero-posti');
243
244  const informazioniToggle = (status, toggle, element) => {
245    if (toggle) {
246      toggle.addEventListener('click', () => {
247        if (status === false) {
248          toggle.classList.add('active');
249          element.classList.add('active');
250          status = true;
251        }
252        else {
253          toggle.classList.remove('active');
254          element.classList.remove('active');
255          status = false;
256        }
257      })
258    }
259  }
260
261  informazioniToggle(infoToggleStatus, infoToggle, infoElement);
262  informazioniToggle(infoToggleStatus2, infoToggle2, infoElement2);
263  informazioniToggle(infoToggleStatus3, infoToggle3, infoElement3);
264  informazioniToggle(infoToggleStatus4, infoToggle4, infoElement4);
265  informazioniToggle(infoToggleStatus5, infoToggle5, infoElement5);
266
267  const mostra_elenco = document.getElementById(
268    'mostra-elenco'
269  );
270  const nascondi_elenco = document.getElementById(
271    'nascondi-elenco'
272  );
273
274  const risultati_gate = document.getElementById(
275    'risultati-gate'
276  );
277
278  const click_checkboxes = document.getElementById(
279    'click-checkboxes'
280  );
281
282  const checkboxes_row = document.querySelector('.checkboxes-row');
283
284  if (click_checkboxes) {
285    click_checkboxes.addEventListener('click', (elem) => {
286
287      checkboxes_row.classList.toggle('elemento-visibile');
288      checkboxes_row.classList.toggle('elemento-nascosto');
289
290      document.getElementById('fc-icon-checkboxes').classList.toggle('icon-checkboxes-close');
291      document.getElementById('fc-icon-checkboxes').classList.toggle('icon-checkboxes-open');
292
293    });
294  }
295
296
297
298
299  if (mostra_elenco) {
300    mostra_elenco.addEventListener('click', (elem) => {
301
302      elem.target.classList.toggle('elemento-nascosto');
303      elem.target.classList.toggle('elemento-visibile');
304
305      nascondi_elenco.classList.toggle('elemento-nascosto');
306      nascondi_elenco.classList.toggle('elemento-visibile');
307
308      risultati_gate.classList.toggle('elemento-nascosto');
309      risultati_gate.classList.toggle('elemento-visibile');
310    });
311  }
312
313
314  if (nascondi_elenco) {
315    nascondi_elenco.addEventListener('click', (elem) => {
316
317      elem.target.classList.toggle('elemento-nascosto');
318      elem.target.classList.toggle('elemento-visibile');
319
320      mostra_elenco.classList.toggle('elemento-nascosto');
321      mostra_elenco.classList.toggle('elemento-visibile');
322
323      risultati_gate.classList.toggle('elemento-nascosto');
324      risultati_gate.classList.toggle('elemento-visibile');
325    });
326  }
327
328
329  document.querySelector('[data-nav="site-navigation"]').addEventListener('click', (elem) => {
330
331    if ($("html").hasClass('mobile-menu-open')) $("html").addClass('fc-menu-open');
332    else $("html").removeClass('fc-menu-open');
333
334  });
335
336  let vh = window.innerHeight * 0.01;
337  document.documentElement.style.setProperty('--vh', `${vh}px`);
338
339  /*$('#visualizza-da-nascondere').click(function () {
340    if ($(this).text() === 'Visualizza Note') {
341      $(this).text('Nascondi Note');
342    } else $(this).text('Visualizza Note');
343
344    $(".da-nascondere").slideToggle("slow");
345  })
346
347  console.log($(".da-nascondere").length);
348
349  if ($(".da-nascondere").length) {
350    $(".da-nascondere").slideToggle("slow");
351  } else {
352    $('.da-nascondere').hide();
353    $('#visualizza-da-nascondere').hide();
354
355  }*/
356
357  $('#condividi-toggle').click(function () {
358
359    $(".div-condividi-condividi").slideToggle();
360    if ($("#fc-icon-condividi").hasClass('icon-condividi')) {
361      $("#fc-icon-condividi").removeClass("icon-condividi").addClass('icon-close');
362    } else {
363      $("#fc-icon-condividi").removeClass("icon-close").addClass('icon-condividi');
364    }
365  })
366  $(".div-condividi-condividi").hide();
367  $("#fc-icon-condividi").removeClass("icon-close");
368
369
370  $('#box').click(function () {
371
372    $(".div-condividi-box").slideToggle();
373    if ($("#box").hasClass('active')) {
374      $("#box").removeClass("active");
375    } else {
376      $("#box").addClass('active');
377    }
378  })
379  $(".div-condividi-box").hide();
380  $("#box").removeClass("active");
381
382
383  $('#condividi').click(function () {
384
385    $(".div-condividi-condividi").slideToggle();
386    $("#fc-icon-condividi").addClass("icon-close");
387  })
388  $(".div-condividi-condividi").hide();
389  $("#fc-icon-condividi").removeClass("icon-close");
390
391
392
393  $(window).on('scroll', function () {
394    $('.categoria-number').each(function (index, value) {
395      if ($(this).hasClass("element-visible")) {
396        // do nothing
397      } else {
398        triggerpoint = $(window).height() * .999 + $(window).scrollTop(); // Call point in Viewport: viewport height * decimal(%) + pixels to top of window
399        counterElement = $(this).offset().top;
400        if (counterElement < triggerpoint) {
401          $(this).addClass("element-visible");
402          $(this).prop('Counter', 0).animate({
403            Counter: $(this).text()
404          }, {
405            duration: 3000,
406            easing: 'swing',
407            step: function (now) {
408              $(this).text(dotSeparateNumber(Math.ceil(now)));
409            }
410          });
411        }
412      }
413    });
414  });
415
416
417  function dotSeparateNumber(val) {
418    while (/(\d+)(\d{3})/.test(val.toString())) {
419      val = val.toString().replace(/(\d+)(\d{3})/, '$1' + '.' + '$2');
420    }
421    return val;
422  }
423
424
425  if ($(window).width() < 769) {
426    $(".left-logo").insertBefore("#searchform");
427  }
428
429  $(window).on("resize", function () {
430    if ($(window).width() < 769) {
431      $(".left-logo").insertBefore("#searchform");
432    } else {
433      $(".left-logo").insertBefore(".site-logo");
434    }
435  }).resize();
436
437
438  /* ---- FIX 2023 ---- */
439
440  // const _html = document.querySelector('html');
441  // const _body = document.querySelector('body');
442  // const fixOverflowBodyClasses = [
443  //   'associazione-strada-franciacorta',
444  //   'storia'
445  // ];
446
447  // fixOverflowBodyClasses.forEach(bodyClass => {
448  //   console.log(_body.classList.contains(bodyClass))
449  //   _html.style.overflowY = _body.classList.contains(bodyClass) && 'scroll';
450  // });
451
452  const addDyamicActiveFocus = (
453    containers,
454    links,
455    offset,
456    isCalcTopOnly,
457    isSlicedContainerId,
458    isAnchorParent) => {
459
460    if (containers) {
461
462      let current = "";
463
464      containers.forEach((container) => {
465        const containerTop = !isCalcTopOnly ? container.getBoundingClientRect().top + window.pageYOffset : container.offsetTop;
466        if (
467          !isCalcTopOnly ?
468            window.pageYOffset >= containerTop - offset && window.pageYOffset <= containerTop + container.offsetHeight
469            : window.pageYOffset >= containerTop - offset) {
470          current = !isSlicedContainerId ? container.getAttribute("id")
471            : container.getAttribute("id").slice(-1);
472        }
473      });
474
475      links.forEach((a) => {
476        const aIndex = a.href.slice(-1);
477        !isAnchorParent ? a.classList.toggle("active", aIndex === current)
478          : a.parentNode.classList.toggle("active", aIndex === current);
479      });
480    }
481  }
482
483  window.onscroll = () => {
484
485    const metodoFasiContainers = document.querySelectorAll('.gb-container-e4de7e84 .fc-metodo_fase_cont');
486    const metodoFasiNavLinks = document.querySelectorAll(".fc-metodo_fase-nav .cont-nav a");
487    const disciplinareContainer = document.querySelectorAll('.label-disciplinare');
488    const discpilinareLinks = document.querySelectorAll('.glider-disciplinare div a');
489
490    addDyamicActiveFocus(metodoFasiContainers, metodoFasiNavLinks, 62.5, false, false, false);
491    addDyamicActiveFocus(disciplinareContainer, discpilinareLinks, 62.5, true, true, true);
492
493  };
494
495  // const gliderOffsetWidth = () => {
496  //   let viewportWidth = window.innerWidth;
497  //   const containerWidth = document.getElementById('primary').offsetWidth;
498  //   let offsetResult = ((viewportWidth - containerWidth) / 2);
499  //   document.documentElement.style.setProperty('--glider-offset', offsetResult + 'px');
500  // }
501
502  // window.addEventListener('resize', () => {
503  //   gliderOffsetWidth();
504  // })
505  //  gliderOffsetWidth();
506
507})(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.