var componentVerifyCycle = 0; var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height(); var lang_page = cmsPageParams.lang; var siteApp = { 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.openSubMenu(); siteApp.scrollAnimation(); siteApp.fadeInHeader(jQuery('.barra-desktop')); siteApp.accordionTab(); //ottengo la tipologia di dispositivo siteApp.customizeForDevice(); jQuery( ".blu-txt" ).wrapInner( "
"); jQuery('.text').wrapInner( "" ); //sniff the UA of the client and show hidden div's for that device // Initialize Background Stretcher for homepage if(cmsPageParams.type == 3){ //controllo di essere solo in homepage switch(cms.variables.deviceType) { case "phone": // jQuery('#blk_42205').backstretch(siteApp.params.homepage.images_mobile, {duration: 3300, fade: 1250}); break; default: // jQuery('#blk_42205').backstretch(siteApp.params.homepage.images, {duration: 3300, fade: 1250}); } } /*sostituitsco il simbolo di tripadvisor del sistema con uno ottimizzato*/ var oldSrc = 'https://admin.abc.sm/img/social/feedback/tripadvisor.png'; var newSrc = '/source/tripadvisor.png'; jQuery('img[src="' + oldSrc + '"]').attr('src', newSrc); /*sostituitsco il simbolo di facebook del sistema con uno ottimizzato*/ var oldSrcF = 'https://admin.abc.sm/img/social/feedback/facebook.png'; var newSrcF = '/source/facebook.png'; jQuery('img[src="' + oldSrcF + '"]').attr('src', newSrcF); /*sostituitsco il simbolo di trivago del sistema con uno ottimizzato*/ var oldSrcTrivago = 'https://admin.abc.sm/img/social/feedback/trivago.png'; var newSrcTrivago = '/source/trivago.png'; jQuery('img[src="' + oldSrcTrivago + '"]').attr('src', newSrcTrivago); // GUIDE /* cms.onEvent('PostRenderForm', function() { var lang_page = cmsPageParams.lang; var lbl1 = dictionaryTranslate('[DIZIONARIO:testo_check_newsletter_form]', lang_page); jQuery('.newsletter_optin_text_wrapper').html(lbl1); jQuery( 'button.alpaca-form-button' ).click(function( event ) { event.preventDefault(); / if (jQuery('input[name="newsletter_optin"]').is(':checked')) { jQuery('input[name="newsletter_optin"]').val(1); } else { jQuery('input[name="newsletter_optin"]').val(0); } var newsletter_optin = jQuery('input[name="newsletter_optin"]').val(); console.log('newsletter_optin = ' + newsletter_optin); createCookie('newsletter_optin', newsletter_optin, 1); }); }); */ jQuery( ".TitankaCommonObjects form .bottone_alt" ).click( function(event) { event.preventDefault(); var newsletter_optin = jQuery('#newsletter_optin').val(); createCookie('newsletter_optin', newsletter_optin, 1); }); /*giochetto per la conversione dei caratteri speciali*/ jQuery('.bottone_email_min').attr('value', dictionaryTranslate('[DIZIONARIO:voglio_guida]', cmsPageParams.lang)); var mdiv = document.createElement("div"); mdiv.innerHTML = jQuery('.bottone_email_min').val(); jQuery('#button_email_min').val(mdiv.textContent); //pagina grazie - gestione se ho accettato la guida if (cmsPageParams.relation_code == 1516958100) { var news_opt = readCookie("newsletter_optin"); console.log('news_opt = '+news_opt); if (news_opt == 1) { console.log('news_opt checkata'); } else { jQuery('.blocco-txt-guida').css('display' , 'none'); jQuery('#contenuto_368788').css('display' , 'none'); jQuery('.blocco-due-guida').css('display' , 'none'); jQuery('#contenuto_368791').css('display' , 'none'); jQuery('.txt-grazie-top').css('display' , 'none'); jQuery('.testo-grazie').html(dictionaryTranslate('[DIZIONARIO:grazie_no_guida]', cmsPageParams.lang)); } } // FINE GUIDE /* jQuery('#whatsappShare').click(function(){ var url = window.location.href; jQuery('#whatsappShare').href= 'whatsapp://send?text=' + url; }); */ //jQuery('.seleziona-verifica a').click(function() { }) jQuery('form .seleziona-verifica a').on({ click: function (event) { event.preventDefault(); jQuery(this).closest('form').submit(); } }); /*****************************************************/ /**/ jQuery('.slider-hotel').slick({ dots: false, infinite: true, speed: 800, arrows:false, slidesToShow: 4, slidesToScroll: 1, autoplay: true, autoplaySpeed: 5000, responsive: [ { breakpoint: 991, settings: { slidesToShow: 3, slidesToScroll: 1, infinite: true, arrows:false } }, { breakpoint: 767, settings: { slidesToShow: 1, slidesToScroll: 1, arrows:false } }, ] }); jQuery('.slider-home').slick({ dots: false, infinite: true, speed: 800, arrows:false, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 2500, pauseOnHover:false, fade: true, cssEase: 'linear' }); jQuery('.offerta-evidenza').slick({ dots: false, infinite: true, speed: 800, arrows:false, slidesToShow: 1, slidesToScroll: 1, autoplay: true, autoplaySpeed: 2500, pauseOnHover:false, fade: true, cssEase: 'linear' }); jQuery('.slider-camere').slick({ dots: false, infinite: true, speed: 800, arrows:false, slidesToShow: 3, slidesToScroll: 1, autoplay: true, autoplaySpeed: 4000, responsive: [ { breakpoint: 991, settings: { slidesToShow: 2, slidesToScroll: 1, infinite: true } }, { breakpoint: 767, settings: { slidesToShow: 1, slidesToScroll: 1 } }, ] }); jQuery('.slider-camere-2').slick({ dots: false, infinite: true, speed: 800, arrows:false, slidesToShow: 2, slidesToScroll: 1, autoplay: true, autoplaySpeed: 4000, responsive: [ { breakpoint: 991, settings: { slidesToShow: 2, slidesToScroll: 1, infinite: true } }, { breakpoint: 767, settings: { slidesToShow: 1, slidesToScroll: 1 } }, ] }); jQuery('.next').click(function(){ jQuery("#blk_30857").slick('slickNext'); }) jQuery('.prev').click(function(){ jQuery("#blk_30857").slick('slickPrev'); }) //aggiungo una freccia a qualunque voce abbia un sottomenu jQuery(".level1 > li:has('.level2')").addClass('submenu'); // jQuery('#button_email_min').val('>'); // SLIDER OFFERTE // jQuery('.off-scorrevoli').slick({ infinite:true, arrows:true, slidesToShow: 4, slidesToScroll: 1, autoplay: true, autoplaySpeed: 7000, speed: 800, dots: false, responsive: [ { breakpoint: 1450, settings: { slidesToShow: 3, slidesToScroll: 1, arrows:false } }, { breakpoint: 1200, settings: { slidesToShow: 3, slidesToScroll: 1, arrows:false } }, { breakpoint: 991, settings: { slidesToShow: 2, slidesToScroll: 1, arrows:false } }, { breakpoint: 767, settings: { slidesToShow: 1, slidesToScroll: 1, arrows:false } }, { breakpoint: 480, settings: { slidesToShow: 1, arrows:false, slidesToScroll: 1 } }] }); /* gestione stile prezzo se non presente */ jQuery('.prezzo-bloc').each(function(){ var html = jQuery(this).html(); var prezzo = jQuery(html).find('[itemprop=price]').html(); if(typeof prezzo=='undefined'){ jQuery(prezzo).remove(); jQuery(this).parent('.condizioni').css('display','none'); } }); console.info('startApplication started!'); }, // FUNZIONI AD HOC SITO // // FINE ESEMPIO // customizeForDevice: function(){ console.log('customizeForDevice'); var ua = navigator.userAgent; var checker = { iphone: ua.match(/(iPhone|iPod|iPad)/), android: ua.match(/Android/), windows: ua.match(/Windows Phone/) }; if (checker.android){ console.log('android'); } else if (checker.iphone){ console.log('iphone'); } else if (checker.windows){ console.log('windows'); } else { console.log('altro device'); //nascondo il link che apre whatshapp e metto il link che chiama il numero jQuery('#whatsappContact').hide(); jQuery('#whatsappContactDesktop').show(); } }, // Create the element openMenuMobile: function(){ /* variabili menu */ var $id_menu = '#menu_2304'; var $menu = jQuery($id_menu); var $btn = jQuery('.op_block'); /**************************/ jQuery($btn).click(function() { jQuery($id_menu +' .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(jQuery(event.target).parents('.op_block').size()|(jQuery(event.target).hasClass('open'))|(jQuery(event.target).parents('ul#root_2304 li').size() ) ){ 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'); } }); }, // Effetto Superfish // openSubMenu: function(){ jQuery('#root_2304 ul.level2').css('margin-top','0px'); // setta la posizione verticale dei sottomenu rispetto alle voci principali jQuery('#root_2304 ul.level2').css('margin-left','0px'); // setta la posizione orizzontale dei sottomenu rispetto alle voci principali jQuery('#root_2304, .menu-bloc #root_2304').superfish({ delay: 800, // 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'); }); } }); }, /**************** tendina lingue ********************/ openLanguage: function(){ //APRO MENU LINGUE jQuery('.tendina-lingue').click(function() { var lingua = jQuery(this).next(); if( lingua.is(':hidden') ) { lingua.slideDown(); jQuery(this).children('.click').addClass('open'); }else{ lingua.slideUp(); jQuery(this).children('.click').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").fadeOut(250); jQuery('.tendina-lingue').children('.click').removeClass('open') } }); }, showMe: function(elem){ anim = jQuery(elem).attr('data-anim'); jQuery(elem).addClass('animated '+anim); }, scrollAnimation: function(){ jQuery(window).on('scroll load', function(){ setTimeout(function() { if(window.innerWidth > 991){ jQuery('.hideme.visible').each( function(i){ siteApp.showMe(this); }); } }, 150); }); }, fadeInHeader: function(element){ jQuery(window).scroll(function(){ if(window.innerWidth > 991){ var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); if(scrollpos > 200){ element.fadeIn(); } else{ element.fadeOut(); } } }); }, countAnimation: function(){ 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 - 50; jQuery(elem).css('height',win_h); } } window.addEventListener("load", function(){siteApp.init();}); /*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 goToByScroll(param){ jQuery('html, body').animate({scrollTop: jQuery(param).offset().top-100}, 2000, "easeInOutQuad"); } 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); } /* engagement myreply */ function startEngagement(){ jQuery().MyreplyEngagement(241); } function myReplyOnPostRender(options){ console.log('myReplyOnPostRender'); var lbl1 = dictionaryTranslate('[DIZIONARIO:testo_check_newsletter_form]', lang_page); jQuery('.newsletter_optin_text_wrapper').html(lbl1); jQuery( 'button.alpaca-form-button' ).click(function( event ) { //console.log( "Handler for .submit() called." ); event.preventDefault(); /* solo per form myreply */ if (jQuery('input[name="newsletter_optin"]').is(':checked')) { jQuery('input[name="newsletter_optin"]').val(1); } else { jQuery('input[name="newsletter_optin"]').val(0); } /******************************/ var newsletter_optin = jQuery('input[name="newsletter_optin"]').val(); console.log('newsletter_optin = ' + newsletter_optin); createCookie('newsletter_optin', newsletter_optin, 1); }); } /*************************/