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 jQuery().videoBG == 'undefined') { loaded = false; msg += '-videoBG'; } 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.openLanguage(); siteApp.scrollAnimation(); siteApp.applyWebfont(); siteApp.fadeInHeader(jQuery('#contenuto_368620')); siteApp.accordionTab(); /* contenuto testo centrato */ jQuery('.centrato').wrapInner("
"); // Initialize Background Stretcher for homepage if (cmsPageParams.type == 3) { //controllo di essere solo in homepage switch(cms.variables.deviceType) { case "phone": break; default: siteApp.videoHome(); /* if (window.innerWidth > 991) { siteApp.adatta('#blk_51836'); jQuery('#blk_51836').videoBG({ mp4:'/source/video-index.mp4', webm:'/source/video-index.webm', poster:'/source/sf-index.jpg', scale:true, loop:true, position:'absolute', zIndex:-1, width:'100%', height:'805px', fullscreen:true, }) } */ } } //aggiungo una freccia a qualunque voce abbia un sottomenu jQuery(".level1 > li:has('.level2')").addClass('submenu'); // apertura sottomenu mobile di prova // //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); } /*****************************************************/ jQuery('.slider-offerte').slick({ dots: false, infinite: true, speed: 800, arrows: false, slidesToShow: 3, slidesToScroll: 1, autoplay: true, autoplaySpeed: 4000, responsive: [ { breakpoint: 1200, settings: { slidesToShow: 2, } }, { breakpoint: 992, settings: { slidesToShow: 2, } }, { breakpoint: 767, settings: { slidesToShow: 1, } } ] }); /* 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 load', function(){ siteApp.viewCheck(); }) console.info('startApplication started!'); }, // FUNZIONI AD HOC SITO // // FINE ESEMPIO // // Create the element applyWebfont: function () { console.info('waiting loading webfont'); setTimeout(function () { WebFont.load({ google: { families: ['Lato:300,400,700' , 'Playfair+Display:400,700'] } }); console.info('webfont loaded!'); }, 0); }, viewCheck:function(){ if (window.innerWidth > 991) { //console.log('ok') jQuery('.moveUp,.moveRight,.moveDown, .moveLeft,.hideme').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 }); } }, 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 }, 700, function () {}) }, scrollAnimation: function () { jQuery(window).on('scroll load', function () { setTimeout(function () { if (window.innerWidth > 991) { jQuery('.hideme, .shakeme').each(function (i) { var bottom_of_object = jQuery(this).offset().top - 180 + jQuery(this).height(); var bottom_of_window = jQuery(window).scrollTop() + jQuery(window).height(); if (bottom_of_window > bottom_of_object) { siteApp.showMe(this); } }); } }, 300); }); }, fadeInHeader: function (element) { if (window.innerWidth > 767) { jQuery(window).scroll(function () { var scrollpos = (document.documentElement.scrollTop || document.body.scrollTop); if (scrollpos > 650) { element.fadeIn() } else { element.fadeOut() } }); } }, videoHome: function(){ if (window.innerWidth > 991) { /*siteApp.adatta('#blk_54952');*/ /*siteApp.adatta('#blk_54948');*/ /*jQuery('#blk_54952').videoBG({ mp4:'/source/video-index.mp4', webm:'/source/video-index.webm', poster:'/source/sf-index-2.jpg', scale:true, loop:true, position:'absolute', zIndex:-1, width:'100%', height:'100%', fullscreen:true });*/ /*jQuery('video').attr('playsinline', ''); //jQuery('video').attr('autoplay', ''); jQuery('video').attr('loop', ''); jQuery('video').attr('muted', '');*/ } }, adatta: function (elem) { var win_h = window.innerHeight; jQuery(elem).css('height', win_h); } } window.addEventListener("load", function () { siteApp.init(); }); 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 goToByScroll(param) { jQuery('html, body').animate({ scrollTop: jQuery(param).offset().top - 210 }, 2000, "easeInOutQuad"); }