var componentVerifyCycle = 0; var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height(); 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 () { console.info('startApplication...'); startImageLightBox(); siteApp.openMenuMobile(); siteApp.openLanguage(); siteApp.countAnimation(); siteApp.scrollAnimation(); //siteApp.fadeInHeader(jQuery('#contenuto_223862')); siteApp.accordionTab(); /* contenuto testo centrato */ jQuery('.centrato').wrapInner("
"); // Initialize Background Stretcher for homepage if (cmsPageParams.type == 3) { //controllo di essere solo in homepage if (window.innerWidth > 991) { siteApp.adatta('#blk_53309'); jQuery(window).on('resize', function(){ siteApp.adatta('#blk_53309'); }) } } //jQuery('#button_email_min').val(''); //jQuery('.bottone_alt').val(''); var pathname = window.location.href; var pathname = pathname.split('?id='); var parametro = pathname[1]; if (parametro) { //console.log('passo') goToByScroll('#' + parametro); } /*****************************************************/ /* slider home uno */ jQuery('.slider-alloggi').slick({ dots: false, infinite: true, speed: 800, arrows: true, slidesToShow: 3, slidesToScroll: 1, autoplay: true, slide: 'a', autoplaySpeed: 5000, responsive: [{ breakpoint: 1700, settings: { slidesToShow: 3, infinite: true } }, { breakpoint: 991, settings: { slidesToShow: 2, infinite: true } }, { breakpoint: 767, settings: { slidesToShow: 1, arrows: true } }, { breakpoint: 480, settings: { slidesToShow: 1, centerMode: false } } ] }); jQuery('.slider-news').slick({ dots: false, infinite: true, speed: 800, arrows: true, slidesToShow: 1, slidesToScroll: 1, autoplay: false, autoplaySpeed: 5000 }); jQuery('.slider-loghi .bo_gallery_photoswipe').slick({ dots: false, infinite: true, speed: 800, arrows: true, slidesToShow: 5, slidesToScroll: 1, autoplay: false, autoplaySpeed: 5000, slide:'figure', responsive: [{ breakpoint: 991, settings: { slidesToShow: 4, } }, { breakpoint: 767, settings: { slidesToShow: 3, } }, { breakpoint: 480, settings: { slidesToShow: 2, } } ] }); jQuery('.slider-home').slick({ dots: false, infinite: true, speed: 800, arrows: true, slidesToShow: 3, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, responsive: [{ breakpoint: 991, settings: { slidesToShow: 2, infinite: true } }, { breakpoint: 767, settings: { slidesToShow: 1, arrows: true } }, { breakpoint: 480, settings: { slidesToShow: 1, centerMode: false } } ] }); /*click che apre il popup del video*/ jQuery('.guarda-video').click(function(){ var elem = jQuery('.video-passepartout'); var attrElement = jQuery('.video-passepartout').attr('data-url'); siteApp.loadiFrameYoutube(elem,attrElement); }); /* gestione tab */ jQuery('.cont-tabs input').click(function () { jQuery('.tab-content').hide(); var element = jQuery(this).attr('id'); console.log(element); jQuery(this).parent('.cont-tabs').siblings(jQuery('.' + element + '').show()); // jQuery('.slider-img').resize(); }) /************************/ jQuery(window).on('scroll', function () { siteApp.viewCheck(); siteApp.scrollAnimation(); }); jQuery('.bo_gallery_photoswipe figure a').click(function (e) { e.stopPropagation(); e.preventDefault(); console.log('.bo_gallery_photoswipe figure a'); }); jQuery('.bo_gallery_photoswipe figure a img').click(function (e) { e.stopPropagation(); e.preventDefault(); console.log('.bo_gallery_photoswipe figure a img'); }); jQuery('.bo_gallery_photoswipe figcaption').click(function (e) { e.stopPropagation(); e.preventDefault(); console.log('.bo_gallery_photoswipe figcaption'); }); console.info('startApplication started!'); }, // FUNZIONI AD HOC SITO // // FINE ESEMPIO // // Create the element loadiFrameYoutube: function(el,url){ jQuery(el).attr('src',url); }, viewCheck: function () { if (window.innerWidth > 991) { //console.log('ok') jQuery('.moveUp,.moveRight,.moveDown, .moveLeft,.hideme, .image-container').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 }); } }, openMenuMobile: function () { /* variabili menu */ /* gestione menù classico*/ var $id_menu = '#menu_2549'; $menu = jQuery($id_menu); $btn = jQuery('.op_block'); jQuery($btn).click(function () { jQuery($id_menu + ' .level1').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_2549 li').size())) return; jQuery(".op_block").removeClass('open'); $btn.find('.click').removeClass('open'); if (jQuery('.level1').hasClass('slide-menu')) jQuery('.level1').removeClass('slide-menu'); if (jQuery(".level2").hasClass('slide-menu')) jQuery(".level2").removeClass('slide-menu'); }); }, // 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'); }); } }); }, /**************** tendina lingue ********************/ openLanguage: function () { //APRO MENU LINGUE jQuery('.tendina-lingue').click(function () { var lingua = jQuery(this).next(); if (lingua.is(':hidden')) { lingua.slideDown(); } else { lingua.slideUp(); } }); jQuery("#select_lingue").click(function () { jQuery(this).slideUp(); }); /* 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").fadeOut(250); } }); }, 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); }, fadeInHeader: function (element) { if (window.innerWidth > 991) { jQuery(window).scroll(function () { var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); if (scrollpos > 250) { element.fadeIn() } else { element.fadeOut() } }); } }, hresize:function(param){ /* FUNZIONE PER CALCOLARE L'ALTEZZA MAX TRA DIV AFFIANCATI */ var hm = ''; var maxh = ''; var arrH = []; jQuery(param).each(function(){ hm = jQuery(this).height(); arrH.push(hm); }) //console.log(arrH) //maxh = Math.max(...arrH); maxh = Math.max.apply(null, arrH); //console.log(maxh) jQuery(param).height(maxh) }, 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: 1000, 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); } } window.addEventListener("load", function () { siteApp.init(); siteApp.viewCheck(); siteApp.scrollAnimation(); }); jQuery(window).on('load resize', function () { if (window.innerWidth > 767) { jQuery('.adattHeight').each(function () { $height = jQuery(this).prev().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 add_slide_menu(item) { jQuery('li' + item + ' .level2').toggleClass('slide-menu'); //console.log(item) } function back_menu(item) { jQuery('li' + item + ' .level2').toggleClass('slide-menu'); //console.log('vado') } function show_menu(elem) { if (window.innerWidth < 992) { //console.log('passo'); jQuery(elem).children('.sottomenu').toggleClass('slide-menu'); } } function hide_sottomenu(elem) { if (window.innerWidth < 992) { //console.log('passo'); jQuery(elem).closest('.sottomenu').removeClass('slide-menu'); } } function goToByScroll(param) { jQuery('html, body').animate({ scrollTop: jQuery(param).offset().top - 80 }, 2000, "easeInOutQuad"); } function frmcheck(frm) { jQuery('#booking .booking_gg').val(jQuery('#booking .data_arrivo').val().substring(0, 2)); jQuery('#booking .booking_mm').val(jQuery('#booking .data_arrivo').val().substring(3, 5)); jQuery('#booking .booking_aa').val(jQuery('#booking .data_arrivo').val().substring(6, 10)); jQuery('#booking .booking_ggf').val(jQuery('#booking .data_partenza').val().substring(0, 2)); jQuery('#booking .booking_mmf').val(jQuery('#booking .data_partenza').val().substring(3, 5)); jQuery('#booking .booking_aaf').val(jQuery('#booking .data_partenza').val().substring(6, 10)); console.log(jQuery('#booking .data_partenza').val()) }