// load scripts for replaced elements var isExecuteLoad = false; document.addEventListener('swup:pageView', function(e) { $( document ).trigger('inizialize'); if (isExecuteLoad) { $( document ).trigger('executeReady'); $( window ).trigger('load'); } else { $('.transition-fade').addClass('finished'); } isExecuteLoad = true; }); document.addEventListener('swup:transitionStart', function(e) { $('.transition-fade').removeClass('finished'); $(document).trigger('removeEvent'); }); document.addEventListener("swup:transitionEnd", function(e){ $('.transition-fade').addClass('finished'); }); $.fn.isInViewport = function(offset) { var $el = $(this); if (offset === undefined) offset = 50; var elementTop = $el.offset().top; var elementBottom = elementTop + ($el.outerHeight() * offset / 100); var viewportHeight = $(window).height(); var viewportToll = 15; var viewportTop = $(window).scrollTop() - viewportToll; var viewportBottom = viewportTop + viewportHeight + (viewportToll * 2.0); if (offset < 0) return elementTop < viewportBottom && elementBottom < viewportBottom; else { return elementBottom >= viewportTop && elementTop < viewportBottom && elementBottom < viewportBottom; } }; var loadScript = function (path) { var result = $.Deferred(); var script = document.createElement("script"); script.async = "async"; script.type = "text/javascript"; script.src = path; script.onload = script.onreadystatechange = function(_, isAbort) { if (!script.readyState || /loaded|complete/.test(script.readyState)) { if (isAbort) result.reject(); else result.resolve(); } }; script.onerror = function () { result.reject(); }; $("head")[0].appendChild(script); return result.promise(); } function getCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie.replace(/\+/g, ' ')); var ca = decodedCookie.split(';'); for(var i = 0; i ') }); $('.clm-recaptcha').each(function( index ) { recaptcha_form = $(this).closest("form"); // recupera la callback success per il recaptcha di google del form, // se non esiste mette quella di default if (recaptcha_form.data('gcallback') === undefined) gcallback = onSuccessRecaptcha; else gcallback = window[recaptcha_form.data('gcallback')]; // render il recaptcha clmrecaptchaID[index] = this.id; clmrecaptchaFunc[index] = grecaptcha.render(this.id, { 'sitekey' : '6Leb3roZAAAAAEipyW5wXYerJIBoj5oQOn8Csafx', 'callback' : gcallback, 'error-callback' : onErrorRecaptcha, 'size' : 'invisible' }); }); }; $(window).on("load resize scroll", function() { if ($(".googlemaps").length > 0) { if ($(".googlemaps").isInViewport(0) && !isMapsLoaded) { isMapsLoaded = true; var lang = getCookie('lang'); loadScript("https://www.villafrancadiverona.org/js/gmap.js.php").then(function() { var googleMap = document.createElement("script"); googleMap.src = "//maps.googleapis.com/maps/api/js?key=AIzaSyBnxTD2nf7f0PUfKmWzP9bYhjJpVGvYxqY&callback=mapsCallback&language="+lang; googleMap.async = true; googleMap.defer = true; document.body.appendChild(googleMap); }); } } }); function adsBlocked(callback){ var testURL = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js' var myInit = { method: 'HEAD', mode: 'no-cors' }; try { var myRequest = new Request(testURL, myInit); fetch(myRequest).then(function(response) { return response; }).then(function(response) { callback(false) }).catch(function(e){ callback(true) }); } catch (e) { callback(false) }; } $(window).on("load", function() { var policyCookie = getCookie('policyCookie'); if (policyCookie == "0") { $('#cookie_third').hide(); } if (policyCookie == "") { $('.cookie-btn-erase').hide(); } var lang = getCookie('lang'); $('form input, form select, form textarea, form button').bind('focus.recaptcha', function() { loadScript("https://www.villafrancadiverona.org/js/recaptcha.js.php").then(function() { var googleRecaptcha = document.createElement("script"); googleRecaptcha.src = "https://www.google.com/recaptcha/api.js?hl="+lang+"&onload=onloadCallback&render=explicit"; googleRecaptcha.async = true; googleRecaptcha.defer = true; document.body.appendChild(googleRecaptcha); adsBlocked(function(blocked){ var exdate = new Date() var n = document.location.hostname.split("."); var e = n.slice(1).join("."); exdate.setDate(exdate.getDate() + 1) var value = 0; if (blocked) value = 1; document.cookie = "adblock=" + escape(value) + ";path=/;expires="+exdate.toGMTString(); }) }); $('form input, form select, form textarea, form button').unbind('focus.recaptcha'); }); }); lazyExecute = function(el) { $(el).lazy({ delay:-1, afterLoad: function(element) { $.event.trigger({ type: "lazyAfterLoad", time: new Date(), element : element }); $(window).trigger('resize'); }, onFinishedAll: function() { $.event.trigger({ type: "lazyComplete", time: new Date() }); $(window).trigger('resize'); } }); } $(window).on('load', function() { $('.lazy').each(function() { if ($(this).closest('.waitLazyLoad').length == 0) { lazyExecute(this); } }); }); // lunghezza calcolata al caricamento della pagina e ad ogni resize della schermata var actualWidth; $( document ).ready(function() { $(document).trigger('executeReady'); }); $( document ).on('executeReady', function() { $(document).on('change', '[type="radio"]', function() { var name = $(this).attr('name'); $('[name="'+name+'"]').removeAttr('required'); }); $("#bottom-to-top").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; }); $('[data-toggle="tooltip"]').tooltip(); $( ".table" ).each(function( index ) { if (!$(this).parent().hasClass("table-responsive")) { $(this).wrap( "
" ); } }); $('.carousel').carousel(); $('.modal').modal('hide'); $('.dropdown-submenu > a').on("click", function(e) { e.preventDefault(); var submenu = $(this); var isShow = submenu.next('.dropdown-menu').hasClass('show'); $('.dropdown-submenu .dropdown-menu').removeClass('show'); if (!isShow) { submenu.next('.dropdown-menu').addClass('show'); } e.stopPropagation(); }); $('.dropdown').on("hidden.bs.dropdown", function() { // hide any open menus when parent closes $('.dropdown-menu.show').removeClass('show'); }); //One Animated /* var is_iOS = ( /iPhone|iPad|iPod/i.test(navigator.userAgent) ); // le animazioni waypoint laterali estendono la pagina causando problemi di visualizzazione nei sistemi operativi IOS // le animazioni waypoint disabilitate if(is_iOS) { $('.animated').css("opacity", "1"); } else { */ $('.animated:not([data-delay],[data-order])').each(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); var offset = $element.data('offset'); if (typeof offset === 'undefined') offset = 80; var context = window; var horizontal = false; var data_context = $element.data('context'); if (data_context !== undefined) { context = document.getElementById(data_context) horizontal = true; } $(this).waypoint(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); var myAnimated = $element.data('animated'); var oneSomeAnimated = $element.data('oneanimated'); // animazione da eseguire una singola volta if (oneSomeAnimated == true) { // animazione non e' stata gia' eseguita in tal caso la esegue if (!($element.hasClass(myAnimated))) $element.toggleClass($element.data('animated')).css("opacity", "1"); // animazione da eseguire sempre } else $element.toggleClass($element.data('animated')); }, { offset: offset+'%', context: context, horizontal: horizontal, }); }); $('.animated[data-order="0"]').each(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); var offset = $element.data('offset'); if (typeof offset === 'undefined') offset = 80; var context = window; var horizontal = false; var data_context = $element.data('context'); if (data_context !== undefined) { context = document.getElementById(data_context) horizontal = true; } $(this).waypoint(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); if ($element.hasClass('execute')) return; var myAnimated = $element.data('animated'); var group = $element.data('group'); $element.addClass("execute").addClass($element.data('animated')).css("opacity", "1"); $('[data-group="'+group+'"]').each(function( index ) { var el = $(this); var delay = el.data('delay') * el.data('order'); setTimeout( function() { el.addClass("execute").addClass(el.data('animated')).css("opacity", "1"); }, delay, el); }); }, { offset: offset+'%', context: context, horizontal: horizontal, }); }); $('.animated[data-delay="0"]').each(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); var offset = $element.data('offset'); if (typeof offset === 'undefined') offset = 80; var context = window; var horizontal = false; var data_context = $element.data('context'); if (data_context !== undefined) { context = document.getElementById(data_context) horizontal = true; } $(this).waypoint(function() { var element = this.element; if (element === undefined) $element = $(this); else $element = $(element); if ($element.hasClass('execute')) return; var myAnimated = $element.data('animated'); var group = $element.data('group'); $element.addClass("execute").addClass($element.data('animated')).css("opacity", "1"); $('[data-group="'+group+'"]').each(function( index ) { var el = $(this); var delay = el.data('delay'); setTimeout( function() { el.addClass("execute").addClass(el.data('animated')).css("opacity", "1"); }, delay, el); }); }, { offset: offset+'%', context: context, horizontal: horizontal, }); }); /* } */ // Effect input $(document).on("blur", 'form input, form textarea, form select', function(){ if($(this).val().length !== 0) { $(this).addClass('filled'); } else { $(this).removeClass('filled'); } }); }); // Inizializza l'effetto input function init_form(form_id) { $.each($('input, textarea, select', '#'+form_id),function(e){ if($(this).val().length !== 0) { $(this).addClass('filled'); } else { $(this).removeClass('filled'); } }) } var isIE = /*@cc_on!@*/false || !!document.documentMode; if (!isIE) { var options = { LINK_SELECTOR: 'a[href^="https://www.villafrancadiverona.org/"]:not([data-no-swup]):not([class^="thumb"]), a[href^="#"]:not([data-no-swup]):not([class^="thumb"])', cache:false, skipPopStateHandling: function(event){ if (event.state === null) return false; if (event.state && event.state.source == "swup" && !window.photoswipe_open) { return false; } window.photoswipe_open = false; return true; } }; var swup = new Swup(options); swup.use(new SwupHeadPlugin()); swup.use(new SwupScrollPlugin({functionOffset: "functionOffset"})); swup.use(new SwupPreloadPlugin()); swup.use(new SwupBodyClassPlugin()); const bodyClassPlugin = new SwupBodyClassPlugin({ prefix: 'page-' }); } var sendVirtualEvent = function(eventForce, eventItem) { if (eventForce === undefined) eventForce = ""; if (eventItem === undefined) eventItem = null; $.post({ url: "https://www.villafrancadiverona.org/admin/includes/ajax/ajax_frontend.php", data: { "type": "sendVirtualEvent", "url" : window.location.href, "lang" : getCookie('lang'), "eventForce" : eventForce, "eventItem" : eventItem, } }) .done(function(data ) { datiJSON = JSON.parse(data); if (datiJSON.event != "") { window.dataLayer.push({ event: datiJSON.event, event_name: datiJSON.event_name, item: datiJSON.item, }); } }); } var supportsCssVariables = (window.CSS && window.CSS.supports && window.CSS.supports('--fake-var', 0)); function functionOffset() { var offsetH = $('#top_content').outerHeight(true); return offsetH; } function newsletter_positive_response(element, datiJSON, value_class_hide) { $('#form_newsletter_ajax')[0].reset(); // sistema la sidebar $('#modal_result_newsletter .modal-body').html(datiJSON.positive_response); $('#modal_result_newsletter').modal('show'); setTimeout(function() {$('#modal_result_newsletter').modal('hide');}, 3000); } $(window).on('load', function() { if ($('.pswp').length > 0) { loadScript("https://www.villafrancadiverona.org/js/jquery.photoswipe.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/js/simple-gallery.min.js").then(function() {}); }); } $('.btn-toggle').click(function() { var el = $(this); var toggle = $('#toggle'); var top_content = $('#top_content'); if (toggle.hasClass('active')) { toggle.removeClass('active') $('.overlay').removeClass('open'); top_content.removeClass('overlay-top'); } else { top_content.addClass('overlay-top'); var top_contentH = top_content.outerHeight(); $('#toggle').addClass('active'); var overlayName = el.data('overlay'); var overlay = $('#'+overlayName); overlay.css({'top':top_contentH+'px','height':'calc(100% - '+top_contentH+'px)'}).addClass('open'); } }); $(".overlay").each(function(){ var id = this.id; $("#"+id+" > .overlay-menu > ul > li").each(function(index){ var delay = 150*(index); if (supportsCssVariables) { this.style.setProperty('--delay', delay + 'ms'); } else { $(this).css({'-webkit-animation-delay' : delay+'ms', 'animation-delay' : delay+'ms'}); } }); $("#"+id+" .dropdown-menu").each(function(){ $(this).find('li').each(function(index) { var delay = 150*(index); if (supportsCssVariables) { this.style.setProperty('--delay', delay + 'ms'); } else { $(this).css({'-webkit-animation-delay' : delay+'ms', 'animation-delay' : delay+'ms'}); } }); }); }); /*SCROLL*/ var waypoints = $('body header').waypoint(function(direction) { if( direction === 'down' ) { $('header').addClass('sftop'); } else if( direction === 'up') { $('header').removeClass('sftop'); } }, { offset: function() { return ($('header').outerHeight() - ($('#top_content').outerHeight() / 3)); } }); $(document).on('mouseover', '.sharemail', function() { if ($(this).attr('data-focus') == '1') return; $(this).attr('data-focus','1'); var subject = $(this).data('subject'); var text = $(this).data('text'); var title = $(this).data('title'); if (title === undefined) title = $('h1').html(); var body = encodeURI(text) + "%0D%0A%0D%0A" + encodeURI(title) + "%0D%0A%0D%0ALink: " + encodeURI(window.location.href); $(this).attr("href", "mailto:?subject="+encodeURIComponent(subject)+"&body="+body); }); $(document).on('click', '.readmore-divisor', function() { $(this).addClass('d-none'); $(this).next().removeClass('d-none'); }); }); var windowWidth = $(window).width(); $( document ).on('inizialize', function() { windowWidth = $(window).width(); }); $(window).on('resize', function() { var newWindowWidth = $(window).width(); if (windowWidth != newWindowWidth) { var $top_content = $('#top_content'); var $main = $('main'); $main.css({'margin-top':$top_content.outerHeight()+'px'}); windowWidth = newWindowWidth; } }); var isGliderLoaded = false; var isCalendarLoaded = false; $( document ).on('inizialize', function() { isGliderLoaded = false; isCalendarLoaded = false; }); $(window).on("load resize scroll", function() { if ($(".glider").length > 0) { if ($(".glider").isInViewport(-10) && !isGliderLoaded) { $('', { rel: 'stylesheet', type: 'text/css', href: 'https://www.villafrancadiverona.org/css/glider.min.css' }).appendTo('head'); isGliderLoaded = true; loadScript("https://www.villafrancadiverona.org/js/glider.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/js/glider.clm.min.js.php").then(function() {}); }); } } if ($("#calendar").length > 0) { if ($("#calendar").isInViewport(-10) && !isCalendarLoaded) { isCalendarLoaded = true; loadScript("https://www.villafrancadiverona.org/js/zabuto_calendar.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/js/zabuto_calendar.clm.min.js.php").then(function() {}); }); } } });$(window).on('load', function(){ });$(window).on('load', function(){ if ($('.gallery-country').length > 0) { loadScript("https://www.villafrancadiverona.org/modules/country/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/country/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/country/js/masonry.clm.min.js.php").then(function() {}); }); }); } });$(window).on('load', function(){ if ($('.gallery-library').length > 0) { loadScript("https://www.villafrancadiverona.org/modules/library/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/library/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/library/js/masonry.clm.min.js.php").then(function() {}); }); }); } });$(window).on('load', function(){ if ($('.gallery-art_culture').length > 0) { loadScript("https://www.villafrancadiverona.org/modules/art_culture/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/art_culture/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/art_culture/js/masonry.clm.min.js.php").then(function() {}); }); }); } $(document).on('click', '.readmore', function() { $(this).parent().addClass('show'); }); });$(window).on('load', function(){ if ($('.gallery-parnon').length > 0) { loadScript("https://www.villafrancadiverona.org/modules/parnon/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/parnon/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/parnon/js/masonry.clm.min.js.php").then(function() {}); }); }); } });$(window).on('load', function(){ });$(window).on('load', function(){ if ($('.gallery-newspapers').length > 0) { loadScript("https://www.villafrancadiverona.org/modules/newspapers/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/newspapers/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/newspapers/js/masonry.clm.min.js.php").then(function() {}); }); }); } });$(window).on('load', function(){ });$(window).on('load', function(){ if ($('.gallery-association').length > 0) { loadScript("https://www.villafrancadiverona.org/modules/association/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/association/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/association/js/masonry.clm.min.js.php").then(function() {}); }); }); } });$(window).on('load', function(){ if ($('.gallery-economy').length > 0) { loadScript("https://www.villafrancadiverona.org/modules/economy/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/economy/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/economy/js/masonry.clm.min.js.php").then(function() {}); }); }); } });$(window).on('load', function(){ if ($('.gallery-newvilla').length > 0) { loadScript("https://www.villafrancadiverona.org/modules/newvilla/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/newvilla/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/newvilla/js/masonry.clm.min.js.php").then(function() {}); }); }); } });$(window).on('load', function(){ if ($('.gallery-event_culture').length > 0) { loadScript("https://www.villafrancadiverona.org/modules/event_culture/js/imagesloaded.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/event_culture/js/masonry.pkgd.min.js").then(function() { loadScript("https://www.villafrancadiverona.org/modules/event_culture/js/masonry.clm.min.js.php").then(function() {}); }); }); } });