// 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' : '6LdIcRgUAAAAAPqxP2-P1h1HaFM2hVJvcGWHO0hs', '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.postavecia.com/js/gmap.js.php").then(function() { var googleMap = document.createElement("script"); googleMap.src = "//maps.googleapis.com/maps/api/js?key=AIzaSyAVDj1nC3NKv25DKhfxa688a_EqloD94ZM&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.postavecia.com/js/recaptcha.js.php").then(function() { }); $('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 sendVirtualEvent = function(eventForce, eventItem) { if (eventForce === undefined) eventForce = ""; if (eventItem === undefined) eventItem = null; $.post({ url: "https://www.postavecia.com/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, }); } }); } // immagini adattative all'interno del riquadro $( ".img-adapter-in-4-3" ).imgadapter(".img-adapter-in-4-3", { w_prop : 4, h_prop : 3, outer_div : false }); $( ".img-adapter-in-1-1" ).imgadapter(".img-adapter-in-1-1", { w_prop : 1, h_prop : 1, outer_div : false }); // immagini adattative all'esterno del riquadro $( ".img-adapter-16-9" ).imgadapter(".img-adapter-16-9", { w_prop : 16, h_prop : 9 }); $( ".img-adapter-4-3" ).imgadapter(".img-adapter-4-3", { w_prop : 4, h_prop : 3 }); $( ".img-adapter-3-2" ).imgadapter(".img-adapter-3-2", { w_prop : 3, h_prop : 2 }); $( ".img-adapter-2-3" ).imgadapter(".img-adapter-2-3", { w_prop : 2, h_prop : 3 }); $( ".img-adapter-1-1" ).imgadapter(".img-adapter-1-1"); var isParallaxLoaded = false; $( document ).on('inizialize', function() { isParallaxLoaded = false; }); $( window ).on('load resize scroll',function() { if($("#modalAvviso").length > 0) { setTimeout(function() { $("#modalAvviso").modal("show"); },200); } if ($(".parallax-window").length > 0) { if ($(".parallax-window").isInViewport(-20) && !isParallaxLoaded) { isParallaxLoaded = true; loadScript("https://www.postavecia.com/js/parallax.min.js").then(function() { loadScript("https://www.postavecia.com/js/parallax.clm.min.js.php").then(function() {}); }); } } customWaypoint(); setTimeout(function() { $(window).trigger('resize'); }, 50); mainTopHandler(); }); $(window).on('load', function() { if ($('.pswp').length > 0) { loadScript("https://www.postavecia.com/js/jquery.photoswipe.min.js").then(function() { loadScript("https://www.postavecia.com/js/simple-gallery.min.js").then(function() {}); }); } $(".navbar-toggle.collapsed").click(function() { setTimeout(function() { customWaypoint(); }, 200); }); if ($('.cmsdate').length > 0) { var lang = getCookie('lang'); $('', { rel: 'stylesheet', type: 'text/css', href: 'https://www.postavecia.com/css/bootstrap-datepicker.min.css' }).appendTo('head'); loadScript("https://www.postavecia.com/js/bootstrap-datepicker.min.js").then(function() { loadScript("https://www.postavecia.com/js/bootstrap-datepicker."+lang+".min.js").then(function() { loadScript("https://www.postavecia.com/js/cmsdate.min.js.php").then(function() {}); }); }); } }); function mainTopHandler() { if($(".noslide").length > 0) { setTimeout(function() { var menu = $("#top_content"); var main = $("main"); var menuH = menu.innerHeight(); main.css({"padding-top" : menuH + "px"}); },500); } } function customWaypoint() { var menu = $("#top_content"); var menuH = menu.innerHeight(); var isMenuOpen = $("#navbarNav.navbar-collapse").hasClass("show"); if(!isMenuOpen) { if(menu.offset().top > menuH) { menu.addClass("bg-visible"); } else { menu.removeClass("bg-visible"); } } } $(window).on('load', function(){ /** ESEMPIO PER L'UTILIZZO DELLA GALLERY CON SLIDE $( "#slide-gallery" ).slide_gallery("#slide-gallery", { element : '.gallery-item', w_prop : 4, // proporzione per la lunghezza h_prop : 3, // proporzione per l'altezza outer_div : true, // true: non è richiusa all'interno del wrapper, false è rinchiusa all'interno del wrapper breakpoint : [ // >risoluzione minima // | numero di items // | | numero di righe // | | | margin px // | | | | [ 1199, 3, 1, 10], [ 480, 2, 1, 10], [ 0, 1, 1, 10], ] }); **/ $( "#slide-gallery" ).slide_gallery("#slide-gallery", { element : '.gallery-item', w_prop : 4, // proporzione per la lunghezza h_prop : 3, // proporzione per l'altezza outer_div : true, // true: non è richiusa all'interno del wrapper, false è rinchiusa all'interno del wrapper breakpoint : [ // >risoluzione minima // | numero di items // | | numero di righe // | | | margin px // | | | | [ 1199, 3, 1, 10], [ 480, 2, 1, 10], [ 0, 1, 1, 10], ] }); // margine applicato 15px $( ".simple-gallery-no-slide" ).gallery(".simple-gallery-no-slide", { w_prop : 4, // proporzione per la lunghezza h_prop : 3, // proporzione per l'altezza outer_div : true, // true: non è richiusa all'interno del wrapper, false è rinchiusa all'interno del wrapper breakpoint : [ // percentuali da applicare in base alla larghezza minima della pagina // >min-width // | width % // | | margin px // | | | [ 768, 33, 5], [ 480, 50, 15], [ 0, 100, 15] ] }); $( "#camere-page .simple-gallery-no-slide" ).gallery("#camere-page .simple-gallery-no-slide", { w_prop : 4, // proporzione per la lunghezza h_prop : 3, // proporzione per l'altezza outer_div : true, // true: non è richiusa all'interno del wrapper, false è rinchiusa all'interno del wrapper breakpoint : [ // percentuali da applicare in base alla larghezza minima della pagina // >min-width // | width % // | | margin px // | | | [ 768, 33, 5], [ 480, 50, 5], [ 0, 100, 5] ] }); });$(window).on('load', function(){ });