var lingua_cur =cmsPageParams['lang'];
var Site = {
init: function(){
this.ElencoProd.init();
this.SchedaProd.init(jQuery('#schedaProd'));
this.Homepage.init();
this.Menu.init();
this.RegUser.init();
this.Carrello.init();
jQuery('.slider-brand').slick({
arrows: true,
dots: false,
autoplay: false,
autoplaySpeed: 5000,
speed: 1200,
fade: false,
slidesToShow: 6,
slidesToScroll: 6,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 6,
slidesToScroll: 6
}
},
{
breakpoint: 991,
settings: {
slidesToShow: 4,
slidesToScroll: 4
}
},
{
breakpoint: 767,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
}
]
});
jQuery('.slick-news').slick({
arrows: false,
dots: false,
autoplay: true,
autoplaySpeed: 5000,
speed: 1200,
fade: false,
slidesToShow: 2,
slidesToScroll: 2,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 2,
slidesToScroll: 2
}
},
{
breakpoint: 991,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
},
{
breakpoint: 767,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
if( jQuery('.banner-natale').length ){
jQuery('.barra-mobile').addClass('natale');
jQuery('.barra-mobile-divisore').addClass('natale');
var link = jQuery('.banner-natale a[data-link=1]').attr('href');
if( link != null ){
jQuery('.banner-natale .link').attr("href", link);
}
}
/*
jQuery('.punti-forza div.row').slick({
arrows: false,
dots: false,
autoplay: true,
autoplaySpeed: 5000,
speed: 1200,
fade: false,
slidesToShow: 3,
slidesToScroll: 3,
responsive: [
{
breakpoint: 1200,
settings: {
slidesToShow: 3,
slidesToScroll: 3
}
},
{
breakpoint: 991,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
},
{
breakpoint: 767,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
*/
jQuery(".field_email_min, .field_button_min").wrapAll('
');
jQuery('.input-newsletter').next().hide();
//Scroll TOP
if( jQuery('.scroll-top').length ){
jQuery('.scroll-top').click(function() {
jQuery('html, body').animate({
scrollTop: jQuery("#pgall").offset().top
}, 1500);
});
}
}
};
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(){
//jQuery('.cat_wrapper_ultimi_arrivi .cat_riqProdotto').wrapAll('');
//Site.Functions.deleteClearfix(jQuery('.elenco-prodotti'));
//jQuery('#catElencoProdotti .cat_clearRiga').hide();
//Site.Functions.addClearfix(jQuery('.elenco-prodotti .cat_riqProdotto'),2, 2, 3, 4);
Site.Functions.deleteClearfix(jQuery('#catElencoProdotti'));
Site.Functions.addClearfix(jQuery('#catElencoProdotti .cat_riqProdotto'),2, 2, 4, 4);
Site.Functions.deleteClearfix(jQuery('.elenco-categorie'));
//Site.Functions.deleteClearfix(jQuery('#contenuto_328796 .cat_wrapper_output'));
Site.Functions.addClearfix(jQuery('.cat_riqCategoria'),1, 2, 2, 4);
}
};
Site.Carrello = {
init: function() {
Catalog.Event.on('updateCartBox', () => {Site.Carrello.update()});
},
update: function(){
var el = document.querySelector('.checkout-carrello');
if (el === null){
return;
}
fetch('/ws.php?' + new URLSearchParams({
action: 'msg-carrello',
sigla_lingua: sigla_lingua,
}))
.then((response) => response.json())
.then((data) => {
const box = el.querySelector('.checkout .riga-totale');
if (data.sconti.length>0) {
const sconti = document.createElement('div');
sconti.classList.add('alert', 'alert-success', 'my-1');
sconti.innerHTML = data.sconti;
box.after(sconti)
}
if (data.msg.length>0) {
const msg = document.createElement('div');
msg.classList.add('alert', 'alert-warning', 'bold', 'my-1');
msg.innerHTML = data.msg;
box.after(msg)
}
});
}
};
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(){
var menuOutlet = jQuery('');
jQuery('#contenuto_585720 li[data-id-categoria="10054"] .livello_1 > li').each(function(i, e){
var $e = jQuery(e);
var li = jQuery('');
li.append($e.clone());
menuOutlet.append(li);
});
jQuery('.top-menu li.voce_menu_26463').append(menuOutlet);
var menu = jQuery('');
jQuery('#contenuto_585720 .livello_0 > li > div a').each(function(i, e){
var $e = jQuery(e);
if ($e.data('id-categoria') == 10054) {
return;
}
var li = jQuery('');
li.append($e.clone());
menu.append(li);
});
jQuery('.top-menu li.voce_menu_26462').append(menu);
// 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
}
};
Site.SchedaProd = {
_isMobile: true,
_slideScheda: null,
init: function(el){
if(el.length>0){
//elimina Ultimi Arrivi
jQuery('#blk_46924').hide();
//Scheda prodotto a 1 colonna
jQuery('#blk_40805').hide();
jQuery('#blk_40806').css('width','100%');
jQuery('#contenuto_291435').addClass('titolo-prodotto');
el.find('.foto-prodotto a').attr('rel', 'scheda');
el.find('.foto-prodotto a').fancybox({
'minHeight': 40
});
var btnCarrello = jQuery('.cat-form-addcart .btn_add_cart').clone();
var btnWishlist = jQuery('.pulsanti .btn_add_wishlist').clone();
jQuery('.cat-form-addcart .cat_add_cart_wrap').html('');
jQuery('.pulsanti .btn_add_wishlist').remove();
jQuery(btnCarrello).appendTo('.cat_add_cart_wrap');
jQuery(btnWishlist).appendTo('.cat_add_cart_wrap');
//Toggle
if( jQuery('.informazioni').length ){
jQuery('.informazioni .titolo-toggle').click(function(){
jQuery(this).toggleClass('tab-closed');
jQuery(this).next().toggle('slow');
});
jQuery( ".informazioni h3" ).each(function( index ) {
if( jQuery( this ).next().html().trim().length < 1){
jQuery( this ).hide();
jQuery( this ).next().hide();
}
});
jQuery('.informazioni > div:nth-child(2)').show();
}
el.find('.correlati').each(function(i,e){
Site.Functions.addClearfix(jQuery(this).find('.correlato'),2, 3, 4, 6);
});
Catalog.Event.on('combinazioneChange', function(e, data){
//console.log(data);
});
}
},
};
Site.Homepage = {
init: function(){
var wrap = jQuery('#pgall.page_81963');
if(wrap.length>0){
Site.Functions.deleteClearfix(jQuery('.prodotti-home'));
Site.Functions.addClearfix(jQuery('.prodotti-home .cat_riqProdottoBox'),1, 2, 4, 6);
jQuery('.slick-categorie-home > div').slick({
arrows: false,
dots: false,
autoplay: true,
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
}
}
]
});
/*********** scrolling categorie **********
jQuery(function(){
var width = 0;
jQuery('.scrolling-categorie > div > div').each(function() {
width += jQuery(this).outerWidth( true );
});
jQuery('.scrolling-categorie > div').css('width', width + "px");
});
/******************************************/
//Calcolo width del box
var contaCat = jQuery('.slide-cat').length;
var widthCat = contaCat*400;
jQuery('.wrap-categorie').css('width',widthCat+'px');
jQuery(".scrolling-categorie").customScrollbar({
skin: "custom-skin",
hScroll: true,
updateOnWindowResize: true
});
jQuery( ".custom-skin .scroll-bar .thumb" ).mouseover(function() {
jQuery( '.custom-skin .scroll-bar .thumb').animate({
width: "+=20px",
marginLeft: "+=10px",
opacity: 0.8,
}, 100 );
jQuery( '.custom-skin .scroll-bar .thumb').animate({
width: "-=20px",
marginLeft: "-=10px",
opacity: 1,
}, 1000 );
});
} else {
jQuery('#pgall').addClass('pag-interna');
}
}
};
Site.RegUser = {
init: function(){
var form = jQuery('#FormRegUser');
if(form.length===0){
return;
}
var pec = form.find('input[name=email_pec]');
if(pec.length>0){
pec.closest('.rowForm').append('*'+dictionary.INFO_FATTURA_ELETTRONICA[sigla_lingua]+'');
}
}
};
function goToByScroll(param){
jQuery('html, body').animate({scrollTop: jQuery(param).offset().top-75}, 2000, "easeInOutQuad");
}
function callback_sortProducts(){
Site.ElencoProd.init();
}
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('.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');
var x,y,top,left,down;
jQuery(".scrolling-categorie").mousedown(function(e){
e.preventDefault();
down=true;
x=e.pageX;
y=e.pageY;
top=jQuery(this).scrollTop();
left=jQuery(this).scrollLeft();
});
jQuery("body").mousemove(function(e){
if(down){
var newX=e.pageX;
var newY=e.pageY;
//console.log(y+", "+newY+", "+top+", "+(top+(newY-y)));
jQuery(".scrolling-categorie").scrollTop(top-newY+y);
jQuery(".scrolling-categorie").scrollLeft(left-newX+x);
}
});
jQuery("body").mouseup(function(e){down=false;});
//menu categorie paginaprodotti
if (jQuery(window).width() < 768) {
jQuery('#contenuto_328799').hide();
}
jQuery( "#contenuto_328816" ).click(function() {
jQuery( "#contenuto_328799" ).toggle( "slow", function() {
});
});
});