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...'); //siteApp.applyWebfont(); startImageLightBox(); siteApp.openMenuMobile(); siteApp.openLanguage(); siteApp.openSubMenu(); //siteApp.countAnimation(); siteApp.scrollAnimation(); siteApp.fadeInHeader(jQuery('.barra-desktop')); siteApp.accordionTab(); siteApp.booking(); jQuery('.testo.table-box').wrapInner( "
" ); jQuery('.slider-dintorni').slick({ dots: false, infinite: true, speed: 900, arrows: false, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, pauseOnHover:false, fade: true, cssEase: 'linear' }); jQuery('a.link-dintorni[data-slide]').click(function(e) { e.preventDefault(); var slideno = jQuery(this).data('slide'); jQuery('.slider-dintorni').slick('slickGoTo', slideno - 1); }); // On before slide change jQuery('.slider-dintorni').on('afterChange', function(event, slick, currentSlide, nextSlide){ var index = jQuery(".dintorni.slick-active .image_item").attr("image_index"); console.log("afterChange index = " + index); jQuery('.link-dintorni').each(function(){ jQuery(this).removeClass('active'); }) jQuery("#dintorni-"+index).addClass("active"); }); //aggiungo una freccia a qualunque voce abbia un sottomenu jQuery(".level1 li ul.level2").parent("li").addClass('submenu'); jQuery("li.submenu > a").removeAttr("href") jQuery(".icona").removeAttr("title") jQuery(".comments_clear").remove(); // apertura sottomenu mobile // siteApp.openSecondLevel(); /* verifico lingua della pagina */ var lang_page = cmsPageParams.lang /* ************************ */ switch(lang_page) { case "it": jQuery('#button_email_min').val('INVIA'); break; case "fr": jQuery('#button_email_min').val('ENVOI'); break; default: } var pathname = window.location.href; var pathname = pathname.split('?id='); var parametro = pathname[1]; if(parametro){ //console.log('passo') goToByScroll('#'+parametro); } if(window.innerWidth > 767){ siteApp.hresize('.elenco-offerte .boxOff h3.titolo'); } /*slider icone index*/ if(window.innerWidth < 768){ jQuery('.slider-icone').slick({ arrows:false, dots: true, speed: 600, slidesToShow: 1, autoplay: true, autoplaySpeed: 6000, accessibility:false, infinite:true }); } /* slider offerte */ jQuery('.offerte-scorrevoli').slick({ arrows:false, dots: true, speed: 600, slidesToShow: 1, autoplay: true, autoplaySpeed: 6000, accessibility:false, infinite:true }); jQuery('.slider-commenti').slick({ dots: false, infinite: true, speed: 900, arrows: false, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, pauseOnHover:false, slide:'.block-commenti' }); jQuery('.slider-4').slick({ dots: false, infinite: true, speed: 900, arrows: true, slidesToShow: 4, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, pauseOnHover:false, slide:'.icona', responsive: [ { breakpoint: 1400, settings: { slidesToShow: 3, } }, { breakpoint: 1100, settings: { slidesToShow: 2, } }, { breakpoint: 768, settings: { slidesToShow: 1, } } ] }); /* gestione tab prodotti */ 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(); }) /************************/ /* gestione stile prezzo se non presente */ jQuery('.cont-prezzo').each(function(){ var html = jQuery(this).html(); var prezzo = jQuery(html).find('[itemprop=price]').html(); if(typeof prezzo=='undefined'){ jQuery(this).remove(); } }) jQuery(window).on('scroll', function(){ siteApp.viewCheck(); siteApp.scrollAnimation(); siteApp.countAnimation(); }) 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); }) } }) console.info('startApplication started!'); }, // FUNZIONI AD HOC SITO // // FINE ESEMPIO // // Create the element booking:function(){ var lang_book = cmsPageParams.lang; if((lang_book)=="it") { jQuery('.bookingForm').BookingEngine({ hotel: '5584', control_code: '15590535', orientation:'horizontal', language:'IT', rooms:'1', open_type:'0', button_text:'PRENOTA ORA' }); }; if((lang_book)=="en") { jQuery('.bookingForm').BookingEngine({ hotel: '5584', control_code: '15590535', orientation:'horizontal', language:'GB', rooms:'1', open_type:'0', button_text:'BOOK NOW' }); }; if((lang_book)=="fr") { jQuery('.bookingForm').BookingEngine({ hotel: '5584', control_code: '15590535', orientation:'horizontal', language:'FR', rooms:'1', open_type:'0', button_text:'RESERVE' }); }; //Booking }, openMenuMobile: function(){ /* variabili menu */ var $id_menu = '#menu_2720'; var $menu = jQuery($id_menu); var $btn = jQuery('.op_block'); /**************************/ jQuery($btn).click(function() { jQuery('.level1').toggleClass('slide-menu'); //if(window.innerWidth > 991){ // jQuery('.menu-fix').fadeToggle(); //} $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(window.innerWidth > 991){ jQuery(".level2").fadeOut(); } if(jQuery(event.target).parents('.op_block').size()|(jQuery(event.target).hasClass('open'))|(jQuery(event.target).parents('ul#root_2720 li').size())|jQuery(event.target).is('.tendina-lingue')){ return; } // if(window.innerWidth > 991){ // jQuery('.menu-fix').fadeOut(); //} 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'); } }); }, 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('.menu-fix #root_2720, #root_2720').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'); }); } }); }, enableMixItUp:function(){ jQuery('.cont-prodotti').mixItUp({ animation: { enable: false }, callbacks: { onMixLoad: function(){ //console.log('onMixLoad: ',arguments) jQuery(this).mixItUp('setOptions', { animation: { enable: true }, }); }, onMixFail: function(state){ console.log('No elements found matching '+state.activeFilter); }, onMixStart: function(obj_provenienza,obj_current){ //jQuery('div.element_mixitup').css('display','inline-block'); var array_titoli = new Array(); }, onMixEnd: function(obj_provenienza,obj_current){ //console.log('onMixEnd',obj_current._activeFilter, arguments); } } }); }, 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.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') } if(!jQuery(".select-offerte").is(':hidden')){ jQuery(".select-offerte").slideUp(); jQuery('.tendina-offerte').removeClass('open') } }); }, applyWebfont:function(){ console.info('waiting loading webfont'); WebFont.load({ google: { families: ['Roboto:300,400,500,700'] } }); console.info('webfont loaded!'); }, 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 }); } }, 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); var h_w = jQuery(window).height(); if(scrollpos > 300){ element.fadeIn() } else{ element.fadeOut() } if(scrollpos > h_w/2){ jQuery('.link-fixed').addClass('transform'); } else{ jQuery('.link-fixed').removeClass('transform'); } }); } }, countAnimation: function(){ if(window.innerWidth > 991){ jQuery('.count').each(function () { if(jQuery(this).hasClass('visible')){ // console.log('xxx') if(!jQuery(this).hasClass('fatto')){ jQuery(this).fadeIn(); 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); } } 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 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){ try { jQuery('html, body').animate({scrollTop: jQuery(param).offset().top-180}, 2000, "easeInOutQuad"); } catch(err) { } }