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) { //console.info('waiting for: '+msg); siteApp.params.tmp = msg; return false; } else { return true; } }, startApplication: function () { siteApp.openMenuMobile(); siteApp.openLanguage(); siteApp.openSubMenu(); siteApp.countAnimation(); siteApp.fadeInHeader(jQuery('.barra-desktop')); siteApp.scrollAnimation(); siteApp.accordionTab(); siteApp.openDetails(); siteApp.higlightForm(); siteApp.loadGoogleFont("https://fonts.googleapis.com/css?family=Fredoka+One|Lato:300,300i,400,400i,700,700i|Pacifico&display=swap"); jQuery(".comments_clear").remove(); jQuery('.testo.table-box').wrapInner("
"); jQuery(".level1 li ul.level2").parent("li").addClass('submenu'); jQuery("li.submenu > a").removeAttr("href"); siteApp.openSecondLevel(); switch (lang_page) { case "it": break; default: } if (cmsPageParams.type == 3) { }; switch (cmsPageParams.relation_code) { case "1582126002": 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 "1581668099": case "1581670183": case "1580823611": jQuery('#blk_81816').addClass('flex-content'); break; case "1582126002": break; } cms.onEvent('DatePickerSelected', function(data){ var id =data.Tdata.element[0].id; switch (id) { case 'Arrivo': jQuery('.day_formatted').html(data.Tdata.day); jQuery('.ArriveMonth').html(data.Tdata.monthText); break; case 'Partenza': jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText); break; } }); cms.onEvent('DatePickerStarted', function(data){ var id =data.Tdata.element[0].id; switch (id) { case 'Arrivo': jQuery('.day_formatted').html(data.Tdata.day); jQuery('.ArriveMonth').html(data.Tdata.monthText); break; case 'Partenza': jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText); break; } }) cms.onEvent('DatePickerAutoSelectedDeparture', function(data){ var id =data.Tdata.element[0].id; jQuery('.departday_formatted').html(data.Tdata.day); jQuery('.DepartMonth').html(data.Tdata.monthText); }) jQuery('.offerte-scorrevoli').slick({ arrows: false, dots: false, speed: 600, slidesToShow: 4, autoplay: true, autoplaySpeed: 5000, accessibility: false, infinite: true, responsive: [{ breakpoint: 1500, settings: { slidesToShow: 3, } }, { breakpoint: 1200, settings: { slidesToShow: 2, } }, { breakpoint: 768, settings: { slidesToShow: 1, } }] }); jQuery('.offerte-scorrevoli').on('afterChange', function (event, slick, currentSlide, nextSlide) { bLazy.revalidate(); }); jQuery('.arrows-offer .next').click(function(){ jQuery('.offerte-scorrevoli').slick('slickNext'); }); jQuery('.arrows-offer .prev').click(function(){ jQuery('.offerte-scorrevoli').slick('slickPrev'); }); jQuery('.slider-top-index').slick({ arrows: false, dots: false, speed: 700, slidesToShow: 1, autoplay: true, autoplaySpeed: 5000, accessibility: false, infinite: true, fade:true, cssEase: 'linear', pauseOnHover:false, }); jQuery('.slider-top-index').on('afterChange', function (event, slick, currentSlide, nextSlide) { bLazy.revalidate(); }) jQuery('.prezzo').each(function () { var html = jQuery(this).html(); var prezzo = jQuery(html).find('[itemprop=price]'); if (typeof prezzo == ' ') { jQuery(".cont-condizioni").remove(); } }); jQuery('.slider-image').slick({ arrows:false, dots: false, speed: 800, slidesToShow: 1, autoplay: true, slide:'a', autoplaySpeed: 6000, pauseOnHover:false, infinite:false, }); jQuery('.slider-image').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.slider-image-double').slick({ arrows:false, dots: false, speed: 800, slidesToShow: 2, autoplay: true, slide:'a', autoplaySpeed: 6000, pauseOnHover:false, infinite:false, responsive: [{ breakpoint: 768, settings: { slidesToShow: 1, } }] }); jQuery('.slider-image').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.slider-gruppo-footer').slick({ arrows:false, dots: false, speed: 800, slidesToShow: 1, autoplay: true, autoplaySpeed: 4000, pauseOnHover:false, infinite:false, }); jQuery('.slider-gruppo-footer').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.slider-commenti').slick({ arrows:true, dots: false, speed: 800, slidesToShow: 1, autoplay: true, slide:'.slide-commenti', autoplaySpeed: 6000, pauseOnHover:false, infinite:true, }); jQuery('.slider-commenti').on('afterChange', function(event, slick, currentSlide, nextSlide){ bLazy.revalidate(); }); jQuery('.arrows-commenti .next').click(function(){ jQuery('.slider-commenti').slick('slickNext'); }) jQuery('.arrows-commenti .prev').click(function(){ jQuery('.slider-commenti').slick('slickPrev'); }) jQuery('.slick-dots ').each(function(){ if(jQuery(this).children('li').length <= 1){ console.log('asda'); jQuery(this).hide(); }; }); var pathname = window.location.href; var pathname = pathname.split('?id='); var parametro = pathname[1]; if (parametro) { //console.log('passo') goToByScroll('.' + parametro); } /* gestione tab prodotti */ 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); }); } }); bLazy = new Blazy({ offset: 5000, loadInvisible: false, selector: '.b-lazy', // all images breakpoints: [{ width: 767 // max-width , src: 'data-src-small' }, { width: 2000 // max-width , src: 'data-src' }] }); }, openMenuMobile: function () { /* variabili menu */ var $id_menu = '#menu_3564'; 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 per chiudere la tendina del menu al click esterno alla tendina */ 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#root_3564 li').size()) | jQuery(event.target).is('.tendina-lingue') | jQuery(event.target).parents(".blocco-lingue").size()) { return; } // if(window.innerWidth > 991){ // jQuery('.menu-fix').fadeOut(); //} 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'); } }); }, openDetails: function () { jQuery('.dettagli-link').click(function (e) { e.preventDefault(); jQuery('.dettagli.open').slideUp(); jQuery(this).parent().parent().siblings('.dettagli').slideToggle().addClass('open'); jQuery(this).find('.vedi-dettagli').toggleClass('nascosto'); jQuery(this).find('.mostra-meno').toggleClass('visibile'); console.log('passo'); }) }, openBook: function (param) { jQuery(param).toggleClass('open'); jQuery(param + ' .chiudi').click(function(){ jQuery(param).removeClass('open'); }); }, openSecondLevel: function () { jQuery('.submenu > a').click(function (e) { e.preventDefault(); /* disaable click 'a' event */ jQuery(this).parents('li').children('.level2').addClass('slide-menu') /* rendo visibile il level2 */ }) jQuery('.level2 li:first-child a').click(function (e) { e.preventDefault(); jQuery(this).parents('li').parents('.level2').removeClass('slide-menu') /* nascondo il level2 */ }) }, // Effetto Superfish // openSubMenu: function () { jQuery('#root_3564, .menu-fix').superfish({ delay: 0, // the delay in milliseconds that the mouse can remain outside a submenu without it closing speed: 'normal' // fast, normal }); }, // fine effetto // /* ***************gestione tab a fisarmonica*********** */ 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) { /* FUNZIONE PER CALCOLARE L'ALTEZZA MAX TRA DIV AFFIANCATI */ 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); }) //console.log(arrH) maxh = Math.max.apply(Math, arrH); //console.log(maxh) jQuery(param).height(maxh) }, /**************** tendina lingue ********************/ openLanguage: function () { //APRO MENU LINGUE jQuery('.tendina-lingue').click(function () { var lingua = jQuery(this).children('#select_lingue'); if (lingua.is(':hidden')) { lingua.slideDown(); jQuery(this).addClass('open'); } else { lingua.slideUp(); jQuery(this).removeClass('open'); } }); jQuery("#select_lingue").click(function () { jQuery(this).slideUp(); jQuery('.tendina-lingue').children('.click').removeClass('open') }); /* jquery per chiudere la tendina delle lingue al click esterno alla tendina */ jQuery(document).click(function (event) { if (jQuery(event.target).parents('.tendina-lingue').size() | (jQuery(event.target).hasClass('tendina-lingue'))) { return; } if (!jQuery("#select_lingue").is(':hidden')) { jQuery("#select_lingue").slideUp(); jQuery('.tendina-lingue').removeClass('open') } }); }, higlightForm: function() { jQuery('#blk_74776').viewportChecker({ classToAdd: 'background-color-form', // 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: true // Add the possibility to remove the class if the elements are not visible }); }, fadeInHeader: function(element){ jQuery(window).scroll(function(){ var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); var h_w = jQuery(window).height(); if(scrollpos > 450){ element.fadeIn() } else{ element.fadeOut() } if(window.innerWidth < 992){ 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) { //console.log('ok') jQuery('.moveUp,.moveRight,.moveDown, .moveLeft, .moveLine, .hideme, .image-container, .highlight, .slider-camere-home .img_0, .slider-camere-home .img_1,.slider-camere-home .img_2, .slider-camere-home .img_3').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); // console.log('vado'); }); } }, 150); }, countAnimation: function(){ if(window.innerWidth > 991){ jQuery(window).on('scroll', function(){ jQuery('.count').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) { jQuery(this).text(Math.ceil(now)); } }); jQuery(this).addClass('fatto'); } } }); }); } }, adatta: function (elem) { var win_h = window.innerHeight; jQuery(elem).css('height', win_h - 90); }, loadGoogleFont: function (url) { // the 'fetch' equivalent has caching issues 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(); // console.log($height) if ($height) { jQuery(this).height($height); } else if (!$height) { $height = jQuery(this).next().height(); jQuery(this).height($height); } }); } }) /*gestione di funzioni es. onclick="gotobyscroll('.classe')"*/ function goToByScroll(param) { bLazy.revalidate(); //console.log("goToByScroll"); try { jQuery('html, body').animate({ scrollTop: jQuery(param).offset().top - 250 }, 2000, "easeInOutQuad"); jQuery('.vedi-menu').removeClass('slide-menu'); jQuery('.click').removeClass('open'); //bLazy.destroy(); } catch (err) {} } /* funzioni dei cookie */ function createCookie(name, value, days) { console.log('createCookie'); if (days) { var date = new Date(); // Now get the current Time (in milliseconds) and add the required number of days (in milliseconds). Set the Time of the date to this new value, so that it now contains the date in milliseconds that the cookie should expire. date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); // Set the variable expires to this date in the UTC/GMT format required by cookies. var expires = "; expires=" + date.toGMTString(); } else { // If 0 is passed to the function, expires is not set and the cookie expires when the user closes his browser.. var expires = ""; } // Finally write the new cookie into document.cookie in the correct syntax. document.cookie = name + "=" + value + expires + "; path=/"; } function readCookie(name) { console.log('readCookie'); var nameEQ = name + "="; // Then split document.cookie on semicolons. ca becomes an array containing all cookies that are set for this domain and path. var ca = document.cookie.split(';'); // Then we go through the array (so through all cookies): for (var i = 0; i < ca.length; i++) { // Set c to the cookie to be checked. var c = ca[i]; // If the first character is a space, remove it by using the substring() method. Continue doing this until the first character is not a space. while (c.charAt(0) == ' ') c = c.substring(1, c.length); // Now string c begins with the name of the current cookie. If this is the name of the desired cookie // we've found what we were looking for. We now only need to return the value of the cookie, which is the part of c that comes after nameEQ. By returning this value we also end the function: mission accomplished. if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } // If, after having gone through all cookies, we haven't found the name we're looking for, the cookie is not present. We return null. return null; } function eraseCookie(name) { createCookie(name, '', -1); } function frmcheck(frm) { jQuery('#gg').val(jQuery('#data_arrivo').val().substring(0, 2)); jQuery('#mm').val(jQuery('#data_arrivo').val().substring(3, 5)); jQuery('#aa').val(jQuery('#data_arrivo').val().substring(6, 10)); jQuery('#ggf').val(jQuery('#data_partenza').val().substring(0, 2)); jQuery('#mmf').val(jQuery('#data_partenza').val().substring(3, 5)); jQuery('#aaf').val(jQuery('#data_partenza').val().substring(6, 10)); }