var lingua_cur =cmsPageParams['lang']; var Site = { init: function(){ Site.ElencoProd.init(); Site.SchedaProd.init(jQuery('#schedaProd')); Site.Homepage.init(); Site.Menu.init(); //Site.Dovesiamo.init(); //Site.Menu.initSubmenuCat(jQuery('.menu-categorie')); //Box Ricerca jQuery('.btn-search').on('click', function(e){ e.preventDefault(); jQuery('html,body').animate({scrollTop: 0}, 'slow'); jQuery(".ricerca").slideToggle("slow"); }); jQuery('.elenco-prod').on('click', function(e){ e.preventDefault(); //jQuery('html,body').animate({scrollTop: 0}, 'slow'); jQuery(".prodotti-home").slideToggle("slow"); }); } }; Site.Responsive = { isXs: function(){ if(window.innerWidth < 768){ return true; } return false; }, isSm: function(){ if(window.innerWidth < 992 && window.innerWidth >= 768){ return true; } return false; }, isMd: function(){ if(window.innerWidth < 1200 && window.innerWidth >= 992){ return true; } return false; }, isLg: function(){ if(window.innerWidth >= 1200){ return true; } return false; } }; Site.ElencoProd = { init: function(){ Site.Functions.deleteClearfix(jQuery('#catElencoProdotti')); Site.Functions.addClearfix(jQuery('#catElencoProdotti .cat_riqProdotto'),1, 2, 2, 2); if( jQuery( ".riq-categoria" ).length > 0){ Site.Functions.deleteClearfix(jQuery('#contenuto_338853 #catWrapperOutput')); } Site.Functions.addClearfix(jQuery('.cat_riqCategoria'),1, 2, 2, 2); jQuery('.prodotto').each( function(){ var link = jQuery(this).find('.link a').attr('href'); if( link != null && link != undefined ){ jQuery(this).find('.foto').click(function() { window.location.href=link; }); } }); jQuery('.categoria').each( function(){ var link = jQuery(this).find('.nome a').attr('href'); if( link != null && link != undefined ){ jQuery(this).find('.foto').click(function() { window.location.href=link; }); } }); } }; Site.Functions = { addClearfix: function(elements, xs, sm, md, lg) { elements.each(function(i,e){ n = i+1; breakpoints = []; classes = []; if(n%xs === 0){ breakpoints.push('visible-xs'); classes.push('last-xs'); } if(n%sm === 0){ breakpoints.push('visible-sm'); classes.push('last-sm'); } if(n%md === 0){ breakpoints.push('visible-md'); classes.push('last-md'); } if(n%lg === 0){ breakpoints.push('visible-lg'); classes.push('last-lg'); } if(breakpoints.length>0){ clearfix = jQuery("
"); jQuery.each(breakpoints, function(ai, av){ clearfix.addClass(av); }); jQuery(e).after(clearfix); // aggiungo classe all'ultimo elemento classList = classes.join(' '); jQuery(e).addClass(classList); } }); }, categSubMenuShow: function(element, elementHover){ jQuery('.sub_menu_cat [id^="sub_"]').hide(); elementHover.children(element).stop().slideDown(200); }, categSubMenuHide: function(element, elementHover){ //hide its submenu //elementHover.children(element).stop().slideUp(200); elementHover.children(element).stop().hide(); }, deleteClearfix: function(elements){ elements.find( '.cb, .clearfix, .cat_clearRiga' ).remove(); } }; Site.Menu = { init: function(){ // SPCRIPT MENU MOBILE var pulsante = '.btn-open-menu'; var menuMobi = '.menu-mobile'; var pulsanteChiudi = '.btn-close-menu'; jQuery(pulsante).on('click',function(){ jQuery(menuMobi).addClass('open'); }); jQuery('.btn-close-menu').on('click',function(){ jQuery(menuMobi).removeClass('open'); }); // FINE SCRIPT MENU MOBILE }, initSubmenuCat: function(menu){ if (jQuery(window).width() < 992) { if( jQuery(menu).length>0){ var linkSubmenu = jQuery(menu).find('.livello_1').parent(); jQuery(menu).find('.livello_1').hide(); //jQuery('.livello_1 li *').live('click', function(event) { event.stopPropagation() }); linkSubmenu.click(function(e){ linkSubmenu.on('click',".livello_1 li",function(e){ e.stopPropagation(); }); jQuery(this).children('.livello_1').toggle('slow'); jQuery(this).toggleClass('chiuso'); }); linkSubmenu.addClass('sub-menu'); jQuery('.sub-menu > a').removeAttr('href'); linkSubmenu.find('> a[href=#]').click(function(e){ e.preventDefault(); return false; }); } } } }; Site.SchedaProd = { _isMobile: true, _slideScheda: null, init: function(el){ if(el.length>0){ el.find('.foto-grande a, .foto-piccole a').attr('rel', 'scheda'); el.find('.foto-grande a, .foto-piccole a').fancybox({ 'minHeight': 40 }); //Scheda prodotto a 1 colonna jQuery('#blk_49301').hide(); jQuery('#blk_49302').css('width','100%'); jQuery('#blk_49302').css('left','0'); jQuery('.titolo-interna').remove(); //jQuery('#contenuto_338852').empty(); jQuery('.cat-altrafoto-clear').hide(); //jQuery('#contenuto_291435').addClass('titolo-prodotto'); if( jQuery.trim( jQuery('.punti-forza .caratteristica').text() ).length < 1 ){ jQuery('.punti-forza').hide(); } /* el.find('.correlati').each(function(i,e){ Site.Functions.addClearfix(jQuery(this).find('.correlato'),1, 2, 4, 4); }); */ jQuery('.correlati').slick({ arrows: false, dots: false, autoplay: false, autoplaySpeed: 5000, speed: 1200, fade: false, slidesToShow: 4, slidesToScroll: 4, responsive: [ { breakpoint: 1200, settings: { slidesToShow: 4, slidesToScroll: 4 } }, { breakpoint: 991, settings: { slidesToShow: 2, slidesToScroll: 2 } }, { breakpoint: 767, settings: { slidesToShow: 1, slidesToScroll: 1 } } ] }); } }, }; Site.Dovesiamo = { init: function(){ var wrap = jQuery('#pgall.page_86420'); var wrapEng = jQuery('#pgall.page_86420'); if(wrap.length>0 || wrapEng.length>0){ //Site.Functions.deleteClearfix(jQuery('.pdi_wrapper_container')); //Site.Functions.addClearfix(jQuery('.pdi_wrapper_container .pdi_wrapper'),1, 2, 3, 3); } } }; Site.Homepage = { init: function(){ var wrap = jQuery('#pgall.page_86389'); var wrapEng = jQuery('#pgall.page_86389'); if(wrap.length>0 || wrapEng.length>0){ //var prima = jQuery('.slider-home div.slide-home:nth-child(1) img').attr('src'); //jQuery('#blk_49253').css('background-image', 'url("' + prima + '")'); Site.Homepage.visualizzaVideo(); if (window.innerWidth > 991) { jQuery( document ).ready(function() { jQuery('.image-container').addClass('visible'); Site.Homepage.mouseoverCategorie(); }); /* var distance = jQuery('.image-container').offset().top - 300; jQuery(window).scroll(function() { if ( jQuery(this).scrollTop() >= distance ) { //console.log('is in top'); jQuery('.image-container').addClass('visible'); Site.Homepage.mouseoverCategorie(); } }); */ } jQuery('.slick-categorie > div').slick({ arrows: false, dots: false, autoplay: false, autoplaySpeed: 5000, speed: 1200, fade: false, slidesToShow: 6, slidesToScroll: 6, responsive: [ { breakpoint: 1200, settings: { slidesToShow: 4, slidesToScroll: 4 } }, { breakpoint: 991, settings: { slidesToShow: 4, slidesToScroll: 4 } }, { breakpoint: 767, settings: { slidesToShow: 1, slidesToScroll: 1 } } ] }); //Link box categorie jQuery('.slick-categorie .categoria-home').each( function(){ var link = jQuery(this).find('.link a').attr('href'); jQuery(this).click(function() { window.location.href=link; }); } ); } else { jQuery('#pgall').addClass('pag-interna'); } }, mouseoverCategorie:function(){ //Switch sfondo categorie //Tovagliato jQuery( ".categoria-home.visible.tovagliato" ).mouseover(function() { Site.Homepage.eliminaVideo(); var urlImg = jQuery('.slider-home > div:nth-child(1) > img').attr('src'); //var link = jQuery.trim( jQuery('.slider-home > div:nth-child(1) > .link').text() ); var testo = jQuery.trim( jQuery('.slider-home > div:nth-child(1) > .testo').text() ); if( urlImg != null && urlImg != undefined ){ jQuery('.slider-sf').css('background-image', 'url(' + urlImg + ')'); } if( testo != null && testo != undefined && testo.length > 0 ){ jQuery('.titolo-home h1').text( testo ); } }); //Lenzuola jQuery( ".categoria-home.visible.lenzuola" ).mouseover(function() { Site.Homepage.eliminaVideo(); var urlImg = jQuery('.slider-home > div:nth-child(2) > img').attr('src'); var testo = jQuery.trim( jQuery('.slider-home > div:nth-child(2) > .testo').text() ); if( urlImg != null && urlImg != undefined ) jQuery('.slider-sf').css('background-image', 'url(' + urlImg + ')'); /* jQuery('.slider-sf').fadeTo('slow', 0.1, function(){ jQuery(this).css('background-image', 'url(' + urlImg + ')'); }).fadeTo('slow', 1); */ if( testo != null && testo != undefined && testo.length > 0 ){ jQuery('.titolo-home h1').text( testo ); } }); //Spugne jQuery( ".categoria-home.visible.spugne" ).mouseover(function() { Site.Homepage.eliminaVideo(); var urlImg = jQuery('.slider-home > div:nth-child(3) > img').attr('src'); var testo = jQuery.trim( jQuery('.slider-home > div:nth-child(3) > .testo').text() ); if( urlImg != null && urlImg != undefined ) jQuery('.slider-sf').css('background-image', 'url(' + urlImg + ')'); if( testo != null && testo != undefined && testo.length > 0 ){ jQuery('.titolo-home h1').text( testo ); } }); //Sanitario jQuery( ".categoria-home.visible.sanitario" ).mouseover(function() { Site.Homepage.eliminaVideo(); var urlImg = jQuery('.slider-home > div:nth-child(4) > img').attr('src'); var testo = jQuery.trim( jQuery('.slider-home > div:nth-child(4) > .testo').text() ); //if( testo.length < 1 ) testo = " "; if( urlImg != null && urlImg != undefined ) jQuery('.slider-sf').css('background-image', 'url(' + urlImg + ')'); if( testo != null && testo != undefined && testo.length > 0 ){ jQuery('.titolo-home h1').text( testo ); } }); //Accessori jQuery( ".categoria-home.visible.accessori" ).mouseover(function() { Site.Homepage.eliminaVideo(); var urlImg = jQuery('.slider-home > div:nth-child(5) > img').attr('src'); var testo = jQuery.trim( jQuery('.slider-home > div:nth-child(5) > .testo').text() ); if( urlImg != null && urlImg != undefined ) jQuery('.slider-sf').css('background-image', 'url(' + urlImg + ')'); if( testo != null && testo != undefined && testo.length > 0 ){ jQuery('.titolo-home h1').text( testo ); } }); //Sanitario jQuery( ".categoria-home.visible.mondo" ).mouseover(function() { Site.Homepage.eliminaVideo(); var urlImg = jQuery('.slider-home > div:nth-child(6) > img').attr('src'); var testo = jQuery.trim( jQuery('.slider-home > div:nth-child(6) > .testo').text() ); if( urlImg != null && urlImg != undefined ) jQuery('.slider-sf').css('background-image', 'url(' + urlImg + ')'); if( testo != null && testo != undefined && testo.length > 0 ){ jQuery('.titolo-home h1').text( testo ); } }); //MOUSEOUT jQuery( ".categoria-home" ).mouseout(function() { var urlImg = jQuery('.slider-home > div:nth-child(1) > img').attr('src'); var testo = jQuery.trim( jQuery('.slider-home > div:nth-child(1) > .testo').text() ); if( urlImg != null && urlImg != undefined ) jQuery('.slider-sf').css('background-image', 'url(' + urlImg + ')'); if( testo != null && testo != undefined ) jQuery('.titolo-home h1').text( testo ); Site.Homepage.visualizzaVideo(); }); }, eliminaVideo:function(){ jQuery( "video#bgvid" ).hide(); }, visualizzaVideo:function(){ jQuery( "video#bgvid" ).show(); jQuery('.slider-sf').css('background-image', 'none'); } }; function goToByScroll(param){ jQuery('html, body').animate({scrollTop: jQuery(param).offset().top-75}, 2000, "easeInOutQuad"); } function callback_sortProducts(){ Site.ElencoProd.init(); } function openTab(evt, tab) { // Declare all variables var i, tabcontent, tablinks; // Get all elements with class="tabcontent" and hide them tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } // Get all elements with class="tablinks" and remove the class "active" tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } // Show the current tab, and add an "active" class to the link that opened the tab document.getElementById(tab).style.display = "block"; evt.currentTarget.className += " active"; } jQuery( document ).ready(function() { Site.init(); //var invia = dictionary.txt_invia_newsletter[cmsPageParams['lang']]; //jQuery('.bottone_email_min').val(invia); jQuery(".field_email_min, .field_button_min").wrapAll(''); jQuery(".input-newsletter").append(''); //jQuery('.button_email_min').attr('value','invia'); //console.log('value:'+jQuery('.button_email_min').value()); /*** TESTO CENTRATO **/ jQuery(function(){ /* contenuto testo centrato */ jQuery('.centrato').wrapInner( "" ); }); /*** BARRA BLOCCATA ************************************************/ jQuery(window).scroll(function(){ var limit = 300; var contenitoremenu = '.barra-bloccata'; if (jQuery(this).scrollTop() > limit) { //Slick MENU jQuery( contenitoremenu ).css( "position", "fixed" ); jQuery( contenitoremenu ).css( "top", 0 ); jQuery( contenitoremenu ).fadeIn(500); } else if( jQuery(this).scrollTop() < 100 ) { jQuery( contenitoremenu ).css( "position", "absolute" ); jQuery( contenitoremenu ).css( "top", "unset" ); jQuery( contenitoremenu ).fadeOut(); } }); /*** FINE BARRA BLOCCATA ************************************************/ //menu con la classe menu-mobile-container jQuery('.btn-open-menu').on('click', function(e){ e.preventDefault(); jQuery('.menu-mobile-container').addClass('open'); }); jQuery('.btn-close-menu').on('click',function(){ jQuery('.menu-mobile-container').removeClass('open'); }); //Prodoti vetrina cancellazione in xs jQuery('#_privacy').addClass('highslide'); });