var componentVerifyCycle = 0; var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height(); var lang_page = cmsPageParams.lang; var bLazy; var siteApp = { params: { homepage: { images: [], images_mobile: [] }, }, init: function () { if (siteApp.allComponentIsLoaded()) { siteApp.startApplication(); } else { componentVerifyCycle++; if (componentVerifyCycle < 200) { setTimeout(function () { siteApp.init(); }, 100); } else { console.warn('Init Application Error! waiting for: ' + siteApp.params.tmp); return false; } } }, allComponentIsLoaded: function () { var loaded = true; var msg = ''; if (typeof jQuery == 'undefined') { loaded = false; msg += '-jQuery'; } if (typeof hs == 'undefined') { loaded = false; msg += '-hs'; } if (typeof jQuery().slick == 'undefined') { loaded = false; msg += '-slick'; } if (typeof jQuery().imageLightbox == 'undefined') { loaded = false; msg += '-imagelightbox'; } if (typeof cms == 'undefined') { loaded = false; msg += 'cms'; } if (!loaded) { siteApp.params.tmp = msg; return false; } else { return true; } }, startApplication: function () { siteApp.loadGoogleFont("https://fonts.googleapis.com/css2?family=Permanent+Marker&family=Raleway:ital,wght@0,300;0,400;0,700;1,300;1,400;1,700&display=swap"); siteApp.openMenuMobile(); siteApp.fadeInHeader(jQuery('.barra-desktop')); siteApp.scrollAnimation(); siteApp.accordionTab(); jQuery(".comments_clear").remove(); jQuery('.testo.table-box').wrapInner("
"); jQuery("li.submenu-container > a").removeAttr("href"); siteApp.openSecondLevel(); setTimeout(function() { if (window.innerWidth>991) { siteApp.hresize('.cnt-percorsi'); } }, 2000); switch (lang_page) { case "it": break; default: } switch (cmsPageParams.relation_code) { case "1582042607": var galleries = ['.foto-1 a.image_lightbox', '.foto-2 a.image_lightbox', '.foto-3 a.image_lightbox', '.foto-4 a.image_lightbox', '.foto-5 a.image_lightbox', '.foto-6 a.image_lightbox', '.foto-7 a.image_lightbox', '.foto-8 a.image_lightbox', '.foto-9 a.image_lightbox','.foto-10 a.image_lightbox','.foto-11 a.image_lightbox','.foto-12 a.image_lightbox','.foto-13 a.image_lightbox','.foto-14 a.image_lightbox']; var instance = []; jQuery.each(galleries, function (i) { var selector = galleries[i]; instance[i] = jQuery(selector).imageLightbox({ onStart: function () { overlayOn(); arrowsOn(instance[i], selector); closeButtonOn(instance[i]); }, onEnd: function () { overlayOff(); closeButtonOff(); arrowsOff(); activityIndicatorOff(); }, onLoadStart: function () { activityIndicatorOn(); }, onLoadEnd: function () { jQuery('.imagelightbox-arrow').css('display', 'block'); activityIndicatorOff(); } }); }); break; default: startImageLightBox(); } switch (cmsPageParams.relation_code) { case "1584626227": /* HOME */ jQuery(window).on('scroll', function () { if(jQuery('#video').hasClass('visible')){ //console.log('classe'); jQuery('#video').get(0).play(); } }) jQuery('.slider-img-giallo > div').slick({ arrows:false, dots: true, infinite: false, speed: 800, slidesToShow: 4, autoplay: true, autoplaySpeed: 3500, responsive: [ { breakpoint: 1200, settings: { slidesToShow: 3 } }, { breakpoint: 992, settings: { slidesToShow: 2 } }, { breakpoint: 768, settings: { slidesToShow: 1 } } ] }); jQuery('.slider-img-giallo > div').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); break; default: } /* gestione thank you page */ if (cmsPageParams.relation_code == 1588413521) { var news_opt = readCookie("newsletter_optin"); console.log('news_opt = ' + news_opt); if (news_opt == 1) { console.log('news_opt checkata'); } else { console.log('news_opt NON checkata'); jQuery('.blocco-txt-guida, .txt-grazie-top, #containerBox_728a7930b4e4, .blocco-due-guida').css('display', 'none'); } } if (cmsPageParams.type == 3) { }; jQuery('.news-scorrevoli').slick({ arrows: false, dots: false, speed: 600, slidesToShow: 1, autoplay: true, autoplaySpeed: 6000, accessibility: false, infinite: true, slide:'.blk-offerte', responsive: [ { breakpoint: 1200, settings: { slidesToShow: 1, dots: true, } }, { breakpoint: 992, settings: { slidesToShow: 1, dots: true, } }] }); jQuery('.news-scorrevoli').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.slider-commenti').slick({ dots: true, infinite: true, speed: 900, arrows: false, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, accessibility: false, slide:'.wrapper_comments', }); jQuery('.slider-commenti ').on('afterChange', function(event, slick, currentSlide, nextSlide) { bLazy.revalidate(); }); jQuery('.slider-home').slick({ arrows:false, dots: false, speed: 800, slidesToShow: 1, autoplay: true, autoplaySpeed: 6000, accessibility:false, infinite:true, fade: true, cssEase: 'linear' }); jQuery('.slider-home').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }) jQuery('.slider-gallery > div').slick({ arrows:false, dots: false, infinite: false, speed: 800, slidesToShow: 5, autoplay: true, autoplaySpeed: 3500, responsive: [ { breakpoint: 1200, settings: { dots: true, slidesToShow: 3, } }, { breakpoint: 992, settings: { dots: true, slidesToShow: 2, } }, { breakpoint: 767, settings: { dots: true, slidesToShow: 1, } }] }); jQuery('.slider-gallery > div').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.slider-img > div').slick({ arrows:false, dots: true, infinite: false, speed: 800, slidesToShow: 3, autoplay: true, autoplaySpeed: 3500, responsive: [ { breakpoint: 992, settings: { slidesToShow: 2, } }, { breakpoint: 767, settings: { slidesToShow: 1, } }] }); jQuery('.slider-img > div').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); /* if (jQuery('.slider-img > div').children('.slick-slide').length <= 1) { jQuery('.slider-img > div').children('.slick-dots').hide(); } if (jQuery('.slider-img > div .slick-active').attr('data-slick-index') == '0') { jQuery('.slider-img > div').find('.slick-prev').addClass('freccia-none'); } else { jQuery('.slider-img > div').find('.slick-next').removeClass('freccia-none'); } jQuery('.slider-img > div').on('afterChange', function (event, slick, currentSlide, nextSlide) { bLazy.revalidate(); if (jQuery(this).find('.slick-slide:last-child').hasClass('slick-active')) { jQuery(this).find('.slick-next').addClass('freccia-none'); } else { jQuery(this).find('.slick-next').removeClass('freccia-none'); } if (jQuery(this).find('.slick-active').attr('data-slick-index') == '0') { jQuery(this).find('.slick-prev').addClass('freccia-none'); } else { jQuery(this).find('.slick-prev').removeClass('freccia-none'); } }); */ jQuery('.slick-slider').each(function(){ jQuery(this).children('.slick-dots').each(function() { if(jQuery(this).children('li').length <= 1){ jQuery(this).hide(); }; }); }); var pathname = window.location.href; var pathname = pathname.split('?id='); var parametro = pathname[1]; if (parametro) { goToByScrollParametro('#' + parametro); } jQuery('.cont-tabs input').click(function () { jQuery('.tab-content').hide(); var element = jQuery(this).attr('id'); jQuery(this).parent('.cont-tabs').siblings(jQuery('.' + element + '').show()); }); jQuery(window).on('scroll', function () { siteApp.viewCheck(); siteApp.scrollAnimation(); }); jQuery('.image-container').each(function () { var h_image = jQuery(this).find('img.foto').height(); jQuery(this).height(h_image); }); jQuery(window).on('resize', function () { if (window.innerWidth > 991) { jQuery('.image-container').each(function () { var h_image = jQuery(this).find('img.foto').height(); jQuery(this).height(h_image); }); } }); // video desk if (window.innerWidth > 991) { jQuery('.video-home').YTPlayer({ fitToBackground: true, videoId: 'EUhwks2SLcA', playerVars: { modestbranding: 0, autoplay: 1, controls: 1, showinfo: 0, branding: 0, rel: 0, autohide: 0, start: 0 } }); }; // video mobile if (window.innerWidth < 992) { jQuery('.video-home').YTPlayer({ fitToBackground: true, videoId: 'EUhwks2SLcA', playerVars: { modestbranding: 0, autoplay: 1, controls: 1, showinfo: 0, branding: 0, rel: 0, autohide: 0, start: 0 } }); }; bLazy = new Blazy({ offset: 3000, loadInvisible: false, selector: '.b-lazy', breakpoints: [{ width: 767, src: 'data-src-small' }, { width: 2000, src: 'data-src' }] }); }, openMenuMobile: function () { var $id_menu = '.level1'; var $menu = jQuery($id_menu); var $btn = jQuery('.op_block'); jQuery($btn).click(function () { jQuery('.vedi-menu').toggleClass('slide-menu'); $btn.find('.click').toggleClass('open'); $btn.toggleClass('open'); if (jQuery($id_menu + ' .level2').hasClass('slide-menu')) { jQuery($id_menu + ' .level2').removeClass('slide-menu') } }); jQuery(document).bind("click touchstart", function (event) { if (jQuery(event.target).parents('.op_block').size() | (jQuery(event.target).hasClass('open')) | (jQuery(event.target).parents('ul.level1 li').size()) | jQuery(event.target).is('.tendina-lingue') | jQuery(event.target).parents(".blocco-lingue").size() | jQuery(event.target).parents(".lingue-mobi").size()) { return; } jQuery(".op_block").removeClass('open'); $btn.find('.click').removeClass('open'); if (jQuery('.vedi-menu').hasClass('slide-menu')) { jQuery(".vedi-menu").removeClass('slide-menu'); } if (jQuery(".level2").hasClass('slide-menu')) { jQuery(".level2").removeClass('slide-menu'); } }); }, countAnimation: function(){ if(window.innerWidth > 991){ jQuery(window).on('scroll', function(){ jQuery('.numero').each(function () { var bottom_of_object = jQuery(this).offset().top + jQuery(this).height(); var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height(); if( bottom_of_window > bottom_of_object ){ if(!jQuery(this).hasClass('fatto')){ jQuery(this).prop('Counter',0).animate({ Counter: jQuery(this).text() }, { duration: 4000, easing: 'swing', step: function (now) { if (jQuery(this).hasClass('decimal')) { jQuery(this).text(Math.ceil10(now, -1)); } else { jQuery(this).text(Math.ceil(now)); } } }); jQuery(this).addClass('fatto'); } } }); }); } }, openBook: function (param) { jQuery(param).toggleClass('open'); jQuery(param + ' .chiudi').click(function(){ jQuery(param).removeClass('open'); }); }, openSecondLevel: function () { jQuery('.submenu-container > a').click(function (e) { e.preventDefault(); jQuery(this).parents('li').children('.level2').addClass('slide-menu'); }) jQuery('.level2 li:first-child a').click(function (e) { e.preventDefault(); jQuery(this).parents('li').parents('.level2').removeClass('slide-menu'); }) }, accordionTab: function (param) { jQuery('.slider-titolo').click(function () { if (!jQuery(this).hasClass('opened')) { jQuery('.slider-titolo.opened').removeClass('opened'); jQuery(this).addClass('opened'); jQuery('.slider-corpo.opened').slideUp('fast', function () { jQuery(this).removeClass('opened'); }) jQuery(this).next().slideDown('fast', function () { jQuery(this).addClass('opened'); }); } else { jQuery(this).removeClass('opened'); jQuery('.slider-corpo.opened').slideUp('fast', function () { jQuery(this).removeClass('opened'); }); } }); }, hresize: function (param, padding) { var hm = ''; var maxh = ''; var arrH = []; var sost = 0; if (padding) { sost = padding; } jQuery(param).each(function () { hm = jQuery(this).height() + sost; arrH.push(hm); }); maxh = Math.max.apply(Math, arrH); jQuery(param).height(maxh) }, fadeInHeader: function(element){ if(window.innerWidth > 991){ jQuery(window).scroll(function(){ var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); var h_w = jQuery(window).height(); if(scrollpos > 300){ element.fadeIn() jQuery('.vedi-menu').addClass('top'); } else{ element.fadeOut() jQuery('.vedi-menu').removeClass('top'); } }); }else{ jQuery(window).scroll(function(){ var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); var h_w = jQuery(window).height(); if(scrollpos > 10){ jQuery(".barra-mobile,.vedi-menu, .level2").addClass("scrolling"); }else{ jQuery(".barra-mobile,.vedi-menu, .level2").removeClass("scrolling"); } }); } }, viewCheck: function () { if (window.innerWidth > 991) { jQuery('.moveUp,.moveRight,.moveDown, .moveLeft, .moveLine, .hideme, .image-container, .highlight, .box-rosso, #video').viewportChecker({ classToAdd: 'visible', // Class to add to the elements when they are visible, classToAddForFullView: 'full-visible', // Class to add when an item is completely visible in the viewport repeat: false // Add the possibility to remove the class if the elements are not visible }); } else { jQuery('.highlight, #video').viewportChecker({ classToAdd: 'visible', // Class to add to the elements when they are visible, classToAddForFullView: 'full-visible', // Class to add when an item is completely visible in the viewport repeat: false // Add the possibility to remove the class if the elements are not visible }); } }, showMe: function (elem) { anim = jQuery(elem).attr('data-anim'); jQuery(elem).addClass('animated ' + anim); jQuery(elem).animate({ opacity: 1 }, 300, function () {}) }, scrollAnimation: function () { setTimeout(function () { if (window.innerWidth > 991) { jQuery('.hideme.visible').each(function (i) { siteApp.showMe(this); }); } }, 150); }, loadGoogleFont: function (url) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var css = xhr.responseText; css = css.replace(/}/g, 'font-display: swap; }'); var head = document.getElementsByTagName('head')[0]; var style = document.createElement('style'); style.appendChild(document.createTextNode(css)); head.appendChild(style); } }; xhr.send(); }, goToByScroll: function(param) { bLazy.revalidate(); try { jQuery('html, body').animate({ scrollTop: jQuery(param).offset().top - 170 }, 2000, "easeInOutQuad"); } catch (err) {} } } window.addEventListener("load", function () { siteApp.init(); siteApp.viewCheck(); siteApp.scrollAnimation(); if(jQuery('.box-giallo').length) { siteApp.goToByScroll('.box-giallo'); } }); jQuery(window).on('load resize', function () { if (window.innerWidth > 991) { jQuery('.adattHeight').each(function () { $height = jQuery(this).next().height(); if ($height) { jQuery(this).height($height); } else if (!$height) { $height = jQuery(this).next().height(); jQuery(this).height($height); } }); } }) function frmcheck(frm) { jQuery('#booking_gg').val(jQuery('#data_arrivo').val().substring(0, 2)); jQuery('#booking_mm').val(jQuery('#data_arrivo').val().substring(3, 5)); jQuery('#booking_aa').val(jQuery('#data_arrivo').val().substring(6, 10)); jQuery('#booking_ggf').val(jQuery('#data_partenza').val().substring(0, 2)); jQuery('#booking_mmf').val(jQuery('#data_partenza').val().substring(3, 5)); jQuery('#booking_aaf').val(jQuery('#data_partenza').val().substring(6, 10)); } function goToByScroll(param) { bLazy.revalidate(); try { jQuery('html, body').animate({ scrollTop: jQuery(param).offset().top - 170 }, 2000, "easeInOutQuad"); } catch (err) {} } function createCookie(name, value, days) { console.log('createCookie'); if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } else { var expires = ""; } document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { console.log('readCookie'); var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } function eraseCookie(name) { createCookie(name, '', -1); } function myReplyOnPostRender(options){ console.log('myReplyOnPostRender'); var lbl1 = dictionaryTranslate('[DIZIONARIO:testo_check_newsletter_form]', lang_page); console.log('lbl1 = '+lbl1); jQuery('.newsletter_optin_text_wrapper').html(lbl1); //jQuery('.field_label_privacy_policy').html(lbl1); jQuery( 'button.alpaca-form-button' ).click(function( event ) { console.log( "Handler for .submit() called." ); event.preventDefault(); console.log("esiste newsletter optin = " + jQuery('input[name="newsletter_optin"]').lenght); /* solo per form myreply */ if (jQuery('input[name="newsletter_optin"]').is(':checked')) { //console.log( "voglio ricevere la guida" ); jQuery('input[name="newsletter_optin"]').val(1); } else { //console.log( "Non voglio ricevere la guida" ); jQuery('input[name="newsletter_optin"]').val(0); } /******************************/ var newsletter_optin = jQuery('input[name="newsletter_optin"]').val(); createCookie('newsletter_optin', newsletter_optin, 1); }); }