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/css?family=Trirong:400,700&display=swap"); siteApp.openMenuMobile(); if(window.innerWidth > 991){ siteApp.fadeInHeader(jQuery('.barra-desktop')); } siteApp.scrollAnimation(); siteApp.accordionTab(); siteApp.openClickBooking(); jQuery(".comments_clear").remove(); jQuery('.testo.table-box').wrapInner("
"); jQuery("li.submenu-container > a").removeAttr("href"); siteApp.openSecondLevel(); setTimeout(function() { siteApp.hresize('.elenco-offerte .bordered'); }, 2000); switch (lang_page) { case "it": break; default: } /* switch (cmsPageParams.relation_code) { case "1584606815": var galleries = ['.foto-1 a.so_image_lightbox', '.foto-2 a.so_image_lightbox', '.foto-3 a.so_image_lightbox', '.foto-4 a.so_image_lightbox', '.foto-5 a.so_image_lightbox', '.foto-6 a.so_image_lightbox', '.foto-7 a.so_image_lightbox', '.foto-8 a.so_image_lightbox', '.foto-9 a.so_image_lightbox','.foto-10 a.so_image_lightbox','.foto-11 a.so_image_lightbox','.foto-12 a.so_image_lightbox','.foto-13 a.so_image_lightbox','.foto-14 a.so_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: soImageLightboxStart(); }*/ jQuery('.offerte-scorrevoli').slick({ arrows: false, dots: false, speed: 600, slidesToShow: 3, autoplay: true, autoplaySpeed: 6000, accessibility: false, infinite: true, responsive: [ { breakpoint: 1200, settings: { slidesToShow: 2 } }, { breakpoint: 768, settings: { slidesToShow: 1 } }] }); jQuery('.offerte-scorrevoli').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.slider-servizi').slick({ dots:false, infinite: true, speed: 900, arrows: true, slidesToShow: 6, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, accessibility:false, slide:'.cont-servizio', responsive: [{ breakpoint: 1600, settings: { slidesToShow: 5 } }, { breakpoint: 1200, settings: { slidesToShow: 4 } }, { breakpoint: 992, settings: { slidesToShow: 3 } }, { breakpoint: 768, settings: { slidesToShow: 2 } }] }); jQuery('.slider-home').slick({ arrows:false, dots: false, speed: 600, slidesToShow: 1, autoplay: true, autoplaySpeed: 6000, accessibility:false, infinite:true, slide:'.home-img', fade: true, cssEase: 'linear' }); jQuery('.slider-home').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }) jQuery('.slider-img > div').slick({ arrows:true, dots: false, infinite: false, speed: 800, slidesToShow: 3, autoplay: true, autoplaySpeed: 3500, responsive: [{ breakpoint: 992, settings: { slidesToShow: 3 } }, { breakpoint: 768, settings: { slidesToShow: 1 } }] }); jQuery('.slider-img > div').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); if (jQuery('.slider-img > div .slick-slide').length <= 1) { jQuery('.slider-img > div .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'); } }); 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); }); } }); /*calendari*/ cms.onEvent('DatePickerSelected', function(data){ //console.log(data.Tdata.date.getDay()); //console.log(data.Tdata); //alert(data.Tdata.monthNumber+' '+data.Tdata.monthText); var id =data.Tdata.element[0].id; switch (id) { case 'data_arrivo': //console.log(data.Tdata.dayTextShort); jQuery('.day_formatted').html(data.Tdata.day); jQuery('.ArriveMonth').html(data.Tdata.monthText); /* jQuery('.day_text_arr').html(days[data.Tdata.date.getDay()]); */ jQuery('.day_text_arr').html(data.Tdata.dayTextShort); var data_arrivo = jQuery('.booking #data_arrivo').val(); createCookie('data_arrivo', data_arrivo, 1); console.log("arrivo data sel "+data_arrivo); break; case 'data_partenza': // console.log(data.Tdata); jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText); // jQuery('.day_text_dep').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_dep').html(data.Tdata.dayTextShort); var data_partenza = jQuery('.booking #data_partenza').val(); createCookie('data_partenza', data_partenza, 1); console.log("partenza data sel "+data_partenza); break; } }) cms.onEvent('DatePickerStarted', function(data){ var id =data.Tdata.element[0].id; //alert(data.Tdata.dayText); //console.log(data) //alert(data.Tdata.monthNumber+' '+data.Tdata.monthText); switch (id) { case 'data_arrivo': console.log("data arrivo start"); console.log(data.Tdata.dayText); jQuery('.day_formatted').html(data.Tdata.day); jQuery('.ArriveMonth').html(data.Tdata.monthText); //jQuery('.day_text_arr').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_arr').html(data.Tdata.dayTextShort); break; case 'data_partenza': // console.log(data.Tdata); jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText); // jQuery('.day_text_dep').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_dep').html(data.Tdata.dayTextShort); break; } }) cms.onEvent('DatePickerAutoSelectedDeparture', function(data){ var id =data.Tdata.element[0].id; // console.log(data.Tdata); jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText); // jQuery('.day_text_dep').html(days[data.Tdata.date.getDay()]); jQuery('.day_text_dep').html(data.Tdata.dayTextShort); }) bLazy = new Blazy({ offset: 2000, 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()) { 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){ jQuery(window).scroll(function(){ var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); var h_w = jQuery(window).height(); if(scrollpos > 300){ element.fadeIn(); } else { element.fadeOut(); } }); }, viewCheck: function () { if (window.innerWidth > 991) { jQuery('.moveUp,.moveRight,.moveDown, .moveLeft, .moveLine, .hideme, .image-container, .highlight').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').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); }, openClickBooking: function () { jQuery("#frm").submit(function(e){ e.preventDefault(); }); jQuery('#btn_submit').click(function (e) { e.preventDefault(); /* disaable click 'a' event */ /* 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)); */ console.log('btn_preventivo click'); var data_arrivo = jQuery('.booking #data_arrivo').val(); createCookie('data_arrivo', data_arrivo, 1); //console.log('data_arrivo '+ data_arrivo); var data_partenza = jQuery('.booking #data_partenza').val(); createCookie('data_partenza', data_partenza, 1); // console.log('data_arrivo '+ (readCookie("data_arrivo"))); /* jQuery("#alpaca6").val(readCookie("data_arrivo")); jQuery("#alpaca7").val(readCookie("data_partenza"));*/ jQuery("input[name='arrivo']").val(readCookie("data_arrivo")); jQuery("input[name='partenza']").val(readCookie("data_partenza")); goToByScroll("#ContContatti"); }) }, 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(); } } window.addEventListener("load", function () { siteApp.init(); siteApp.viewCheck(); siteApp.scrollAnimation(); }); 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 goToByScroll(param) { bLazy.revalidate(); try { jQuery('html, body').animate({ scrollTop: jQuery(param).offset().top - 270 }, 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); }