| Server IP : 194.124.73.198 / Your IP : 216.73.217.5 Web Server : Apache System : Linux vps0314.00gate.com 5.15.0-1089-azure #98~20.04.1-Ubuntu SMP Fri May 2 20:18:39 UTC 2025 x86_64 User : spaceten.it_vps0314 ( 10000) PHP Version : 8.0.30 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/spaceten.it/salumipasini.spaceten.it/wp-content/themes/Divi-child/js/ |
Upload File : |
jQuery(document).ready(function($){
// HEADER SUBMENU
$('li.menu-item.megamenu').hover(function(){
$(this).children('.sub-menu').stop().slideDown();
},function(){
$(this).children('.sub-menu').stop().slideUp();
});
// ALLINEO IL SUBMENU ALLA VOCE DEL MENU
if (jQuery(window).width() > 1280){
jQuery('.megamenu-container').css('margin-left', (jQuery('li.menu-item.megamenu').offset().left - 20));
jQuery(window).resize(function(){
jQuery('.megamenu-container').css('margin-left', (jQuery('li.menu-item.megamenu').offset().left - 20));
})
}
// MODULO DI RICERCA
jQuery('.placeholder-search-block').click(function(){
jQuery(this).hide();
jQuery('.form-search-block').fadeIn();
});
jQuery('button.button-search-block').click(function(){
jQuery(this).parent().fadeOut();
jQuery('.placeholder-search-block').show(600);
});
// STICKY MENU
$(window).scroll(function(){
if($(window).scrollTop() > 0){
$('div#header-desktop').addClass('sticky');
} else {
$('div#header-desktop').removeClass('sticky');
}
})
// HAMBURGER MOBILE
$('#nav-icon1,#nav-icon2,#nav-icon3,#nav-icon4').click(function(){
$(this).toggleClass('open');
$('html').toggleClass('no-scroll');
$('div#navigation-mobile').slideToggle()
});
// TOGGLE MENU MOBILE
$('ul.menu-content-mobile .toggle-menu').click(function(){
$(this).toggleClass('open');
$(this).siblings('ul.sub-menu-mobile').slideToggle();
})
// CAROUSEL HOME
$('.carousel-home').slick({
slidesToShow: 4,
infinite: true,
speed: 500,
});
// MENU A SCOMPARSA DELL'UTENTE
jQuery('li.icon-user a').click(function(e){
e.preventDefault();
})
jQuery('li.icon-user a').mouseover(function(e){
e.preventDefault();
jQuery('.user-control-panel').fadeIn(100);
if(jQuery('div#yith-wacp-popup.open').length > 0){
jQuery('div#yith-wacp-popup').removeClass('open');
}
})
jQuery('.user-control-panel').mouseleave(function(e){
e.preventDefault();
jQuery(this).stop().fadeOut(100);
})
// TRIGGER CARRELLO
jQuery(document).on('click', 'li.admin-icon.icon-cart', function(){
jQuery('div#yith-wacp-mini-cart').click();
if(jQuery('.user-control-panel:visible')){
jQuery('.user-control-panel').fadeOut(100);
}
});
jQuery(document).on('click', '.cart-mobile a', function(){
jQuery('div#yith-wacp-mini-cart').click()
})
// PAGINA CARRELLO
//TOGGLE CALCOLA SPESE DI SPEDIZIONE
jQuery('.header-shipping.toggle').on('click', function(){
jQuery('.shipping-container.toggle-content').slideToggle();
if(jQuery('section.shipping-calculator-form.empty-fields').length > 0){
setTimeout(function(){
jQuery('section.shipping-calculator-form.empty-fields').slideToggle();
}, 500)
}
jQuery(this).children().toggleClass('active');
})
// POPUP NEWSLETTER
jQuery(document).on('click', 'span.close-modal-form, .overlay-form', function(){
jQuery('.newsletter-popup').fadeOut();
setTimeout(function(){
jQuery('.newsletter-popup').remove();
}, 500);
jQuery('html').removeClass('no-scroll');
});
jQuery('.open__newsletter').click(function(e){
e.preventDefault();
generateForm();
});
jQuery('.admin-icon.icon-newsletter').click(function(){
if(jQuery('.user-control-panel:visible')){
jQuery('.user-control-panel').fadeOut(100);
}
})
// INFINITE SCROLL PRODOTTI SHOP
jQuery(document).ajaxComplete(function(){
jQuery('ul.products.columns-3').infiniteScroll({
// options
path: 'a.next.page-numbers',
append: 'li.product',
status: '.page-load-status',
});
});
// TIMING HIDE CART ON THE CATEGORY PAGE
jQuery('a.button.add_to_cart_button.ajax_add_to_cart').click(function(){
setTimeout(function(){
$('div#yith-wacp-popup').removeClass('open')
}, 10000)
})
// TOGLIERE IL MENO QUANDO LA QUANTIT° DEL PRODOTTO è 1
jQuery('form.cart .quantity input').change(function(){
if(jQuery(this).val() > 1 && jQuery(this).val() < 3 && jQuery(this).siblings('button.minus').length == 0){
jQuery(this).parent().prepend(buttonMinus);
} else if(jQuery(this).val() < 2 && jQuery(this).siblings('button.minus').length > 0) {
jQuery(this).siblings('button.minus').remove();
}
});
jQuery('form.woocommerce-cart-form .quantity input').change(function(){
if(jQuery(this).val() > 1 && jQuery(this).val() < 3 && jQuery(this).siblings('button.minus').length == 0){
jQuery(this).parent().prepend(buttonMinus);
} else if(jQuery(this).val() < 2 && jQuery(this).siblings('button.minus').length > 0) {
jQuery(this).siblings('button.minus').remove();
}
});
// IMPOSTA UNDERLINE PER IL LINK DEL NEGOZIO QUANDO SEI NELLO SHOP
if(category_name == 'shop'){
jQuery('.et_pb_module.et_pb_code.et_pb_code_0.shop__sidebar-filters.obj > div > a').css('text-decoration', 'underline')
}
// NASCONDE TESTO NELLA DESCRIZIONE DEL PRODOTTO SE QUESTA è TROPPO LUNGA
/*let letterCount = 0;
var moreDesc = jQuery('<button />', {id: 'more-description', text: readMoreProduct.read_more})
jQuery('.product__description p').each(function(){
letterCount += jQuery(this).text().length
return letterCount
});
if(letterCount > 250){
jQuery('.product__description').addClass('more-less');
moreDesc.insertAfter('.product__description');
jQuery('.product__description p:first-child').addClass('hide-desc');
if(jQuery('.product__description p').length > 1){
jQuery('.product__description p:not(:first-child)').hide();
}
};
jQuery('button#more-description').click(function(){
jQuery('.product__description').toggleClass('more-less');
if(jQuery('.product__description p.hide-desc').length > 0){
jQuery('.product__description p').removeClass('hide-desc');
}else {
jQuery('.product__description p:first-child').addClass('hide-desc');
}
if(jQuery('.product__description p').length > 1){
jQuery('.product__description p:not(:first-child)').toggle();
}
if(jQuery('.product__description').hasClass('more-less')){
jQuery(this).text(readMoreProduct.read_more);
jQuery(window).scrollTop(jQuery('.product__description').offset().top - (jQuery('.product__description').offset().top * 50 / 100));
} else {
jQuery(this).text(readMoreProduct.close);
}
})
*/
// CONTROLLA SE IL SUBTOTALE è MAGGIORE DI 29 PER POTERE PROCEDERE CON IL CHECKOUT
function checkSubtotalValidator(){
let currentSubTotal = jQuery('.cart-subtotal td bdi').first().text().replace('€', '').replace(',', '.');
let message = jQuery('<span/>', {'class': 'error-message'}).append(subtotal_translate.error_message_1 + (parseFloat(29 - currentSubTotal)).toFixed(2) + ' ' + subtotal_translate.error_message_2).append(jQuery("<a/>", {"class":"backtoshop", "href": subtotal_translate.shop_url, "text": subtotal_translate.backtoshop_label}));
let listItem = jQuery('.wc-proceed-to-checkout');
// CUSTOM LUNA: preleva ID dei prodotti dal carrello
jQuery(".shop_table .cart_item").each(function() {
data_product_id = jQuery(this).find(".product-remove a").attr("data-product_id");
//alert("ID prodotto: " + data_product_id);
});
// inserire qui ID del prodotto per il quale non fare il controllo dei 29€
id_prodotto_specifico = 22669;
// vai al checkout solo se il totale è >= di 29€ o nel carrello c'è il prodotto con ID specificato
if(currentSubTotal < 29 && data_product_id != id_prodotto_specifico){
jQuery('.wc-proceed-to-checkout').addClass('disabled');
jQuery('.wc-proceed-to-checkout').click(function(e){
e.preventDefault();
})
if(jQuery('span.error-message').length === 0){
message.insertAfter(listItem);
}
} else {
console.log('è maggiore')
}
}
checkSubtotalValidator();
jQuery(document).ajaxStop(function(){
checkSubtotalValidator();
});
});
// NEWSLETTER A COMPARSA
function generateForm(e){
var buttonClick = event.target;
var valEmail = '';
jQuery('html').addClass('no-scroll');
if(jQuery(buttonClick).siblings('input#email2').val() != ''){
valEmail = jQuery('div#popupnewsletter input#email2').val();
}
var form =
jQuery('<div/>', {class: 'newsletter-popup'}).append(
jQuery('<div />', {class: 'overlay-form'})
).append(
jQuery('<div />', {class: 'form-generated'}).append(
jQuery('<div />', {class: 'header-newsletter'}).append(
jQuery('<h1 />', {text: newsletter_translate.title}),
jQuery('<span />', {class: 'close-modal-form', text: 'M'})
),
jQuery('<form />', {action: 'https://salumipasini.us12.list-manage.com/subscribe/post?u=ccef56cfbad4ff15b29dfb836&id=08dc1401b6', method: 'POST', target: '_blank' }).append(
jQuery('<div />', {class: 'form-group'}).append(
jQuery('<input />', {id: 'mce-FNAME', name: 'FNAME', type: 'text', placeholder: newsletter_translate.name})
),
jQuery('<div />', {class: 'form-group'}).append(
jQuery('<input />', {id: 'mce-EMAIL', name: 'EMAIL', type: 'email', placeholder: 'E-mail', required: 'true', value: valEmail})
),
jQuery('<div />', {class: 'form-group accept-OTP'}).append(
/* jQuery('<input />', {id: 'OTP', name: 'OTP', type: 'checkbox', required: 'true'}),*/
/* jQuery('<label />', {class: 'checkbox-custom', for: 'OTP'}),*/
jQuery('<label />', {'for': 'OTP', text: newsletter_translate.otp_01}).append(jQuery('<a />', {href: '/termini-newsletter/</a>', style: 'color: #00000060;text-decoration:underline;', target: '_blanq'}).text(newsletter_translate.otp_02)),
),
jQuery('<div />', {class: 'form-group'}).append(
jQuery('<input />', {id: 'mc-embedded-subscribe', type: 'submit', value: newsletter_translate.subscribe, name: 'subscribe'})
)
)
)
)
jQuery('body').append(form);
jQuery('.overlay-form').hide().fadeIn();
}
// quantità
jQuery(document).ready(function($){
$('body').on( 'click', 'button.plus, button.minus', function() {
// Get current quantity values
var qty = $( this ).closest( 'form.cart' ).find( '.qty' ).first();
if (!qty.length) {
qty = $( this ).closest( 'div.quantity' ).find( '.qty' ).first();
}
var val = parseFloat(qty.val());
var max = parseFloat(qty.attr( 'max' ));
var min = parseFloat(qty.attr( 'min' ));
var step = parseFloat(qty.attr( 'step' ));
// Change the value if plus or minus
if ( $( this ).is( '.plus' ) ) {
if ( max && ( max <= val ) ) {
qty.val( max );
}
else {
qty.val( val + step );
}
}
else {
if ( min && ( min >= val ) ) {
qty.val( min );
}
else if ( val > 1 ) {
qty.val( val - step );
}
}
qty.trigger('change');
});
// faccio in modo che il margin left dei correlati sia sempre uguale
jQuery("div#rowFull").css("margin-left", jQuery("div#rowRif").css("margin-left"));
jQuery(window).resize(function(){
jQuery("div#rowFull").css("margin-left", jQuery("div#rowRif").css("margin-left"));
})
});