;(function () {
$(function() {
$(".lazy").lazyload({effect : "fadeIn",
skip_invisible :false
});
});
function addDotButtonText() {
// loop through each dot element
$('.owl-dot').each(function() {
// remove old text nodes
$(this).find('.offscreen').remove();
// grab its (zero-based) order in the series
let idx = $(this).index() + 1;
// append a span to the button containing descriptive text
$(this).append('Go to slide ' + idx + ' ');
});
}
var owlCarouselUnified = function() {
$( ".owl-unified" ).each(function( index ) {
// console.log( index );
// console.log( $( this ).children().length );
var owl=$( this );
var thumbs=false;
var items=1;
var itemsMobile=1;
var itemsTablet=1;
var itemsDesktop=1;
var loop=true;
var autoplayTimeout=5000;
var dots=true;
var nav=true;
if(owl.hasClass('owl-thumbs')){ autoplayTimeout=2000;
items=5; itemsDesktop=5; itemsTablet=5; itemsMobile=4; }
else if(owl.hasClass('owl-thumbs-video')){
items=4; itemsDesktop=4; itemsTablet=4; autoplayTimeout=2000; itemsMobile=3; }
else if(owl.hasClass('owl-thumbs-video')){
items=4; itemsDesktop=4; itemsTablet=4; autoplayTimeout=2000; itemsMobile=3; }
else if(owl.hasClass('owl-carousel-2-item')){ items=2; itemsDesktop=2; itemsTablet=2; itemsMobile=1; }
else if(owl.hasClass('owl-carousel-3-item')){ items=3; itemsDesktop=3; itemsTablet=2; itemsMobile=1; }
else if(owl.hasClass('owl-carousel-4-item')){ items=4; itemsDesktop=4; itemsTablet=2; itemsMobile=1; }
else if(owl.hasClass('owl-carousel-5-item')){ items=5; itemsDesktop=5; itemsTablet=2; itemsMobile=2; }
else if(owl.hasClass('owl-carousel-6-item')){ items=6; itemsDesktop=4; itemsTablet=3; itemsMobile=2; }
else if(owl.hasClass('owl-carousel-7-item')){ items=7; itemsDesktop=7; itemsTablet=3; itemsMobile=2; }
else if(owl.hasClass('owl-carousel-8-item')){ items=8; itemsDesktop=6; itemsTablet=3; itemsMobile=2; }
else if(owl.hasClass('owl-carousel-9-item')){ items=9; itemsDesktop=7; itemsTablet=5; itemsMobile=3; }
else if(owl.hasClass('owl-carousel-10-item')){ items=10; itemsDesktop=8; itemsTablet=6; itemsMobile=4; }
if(owl.hasClass('owl-thumbs-video-immobili')){ items=6; itemsDesktop=6; itemsTablet=5; }
else if(owl.hasClass('owl-thumbs-immobili')){ items=7; itemsDesktop=7; itemsTablet=6; }
if(owl.hasClass('no-loop')){ loop=false; }
if ($( this ).children().length <= itemsDesktop) {
loop=false;
dots=false;
nav=false;
}
if($( owl ).hasClass('owl-carousel-main-thumb')){ thumbs=true; }
// effetti
var effect='';
if(owl.hasClass('effect_flip_y')){ effect='flipOutY'; }
else if(owl.hasClass('effect_fade')){ effect='fadeOut';}
else if(owl.hasClass('effect_flip_x')){ effect='flipOutX';}
else if(owl.hasClass('effect_fade_out_right')){ effect='lightSpeedOut';}
else if(owl.hasClass('effect_slide_vertical')){ effect='slideOutDown';}
// effetti extra
else if(owl.hasClass('effect_bounceOut')){ effect='bounceOut';}
else if(owl.hasClass('effect_bounceOutDown')){ effect='bounceOutDown';}
else if(owl.hasClass('rotateOut')){ effect='rotateOut';}
else if(owl.hasClass('fadeOutDown')){ effect='fadeOutDown';}
else if(owl.hasClass('rotateOutDownLeft')){ effect='rotateOutDownLeft';}
else if(owl.hasClass('rollOut')){ effect='rollOut';}
else if(owl.hasClass('hinge')){ effect='hinge';}
else if(owl.hasClass('zoomOut')){ effect='zoomOut';}
else if(owl.hasClass('zoomOutUp')){ effect='zoomOutUp';}
owl.owlCarousel({
nav: nav,
dots: dots,
lazyLoad:true,
items:items,
onInitialized: addDotButtonText,
onResized: addDotButtonText,
responsive:{
0:{ items:itemsMobile,
nav:false},
500:{items:itemsTablet,
nav:true },
768:{items:itemsDesktop,
nav:true },
1200:{items:items,
nav:true }
},
autoHeight: false,
autoplay:true,
autoplayTimeout:autoplayTimeout,
mouseDrag: true,
loop: loop,
thumbs: thumbs,
thumbsPrerendered: true,
margin: 0,
responsiveClass: true,
smartSpeed: 800,
//autoplay: true,
navText: [
' Prew ',
'Next '
],
callbacks: true,
URLhashListener: false,
autoplayHoverPause: true,
animateOut: effect,
// animateIn: complement,
});
$(window).resize(function(){
owl.trigger('refresh.owl.carousel');
});
});
}
function letterize(container){
// var letterAnimationAos = $(".letter-animation").attr("data-aos");
// var letterAnimationAosDuration = $(".letter-animation").attr("data-aos-duration");
var letterAnimationWords = $(container).html().replaceAll(" ", " ").replaceAll(" ", " ").replaceAll(/<\/?[^>]+(>|$)/g, "").split(" ");
//.replace(/([^\x00-\x80]|\w)/g, " ")
const wrappedWords = letterAnimationWords
.map((word) => {
const wrappedLetters = Array.from(word)
.map(
(letter) =>
`${letter} `
)
.join("");
return `${wrappedLetters} `;
})
.join(" ");
$(container).html(wrappedWords);
var dL = 0;
$(container).find(".letter").each(function () {
console.log($(container).data( "delaytext"))
var delayletter=dL * 15 + $(container).data( "delaytext") * 120;
$(this).css("transition-delay", delayletter + "ms");
dL++;
});
}
$(window).on("load", function () {
var n = 0;
$(".text-anim").each(function () {
$(this).css("transition-delay", n * 20 + "ms") ;
$(this).data( "delaytext", n ) ;
n++;
// $(this).html($(this).text().replace(/\S/g, "$& "));
letterize($(this));
});
})
//ricerca veloce
var typingTimer;
$('.quick_search').focus( function() {
var inputSearch = this;
a = document.getElementById(inputSearch.getAttribute('data-auto'));
a.classList.add('show-auto');
});
$('.quick_search').keyup( function() {
var inputSearch = this;
clearTimeout(typingTimer);
if ( this.value.length) {
typingTimer = setTimeout(function(){
if( inputSearch.value.length < 2 ) return;
var categ=""
a = document.getElementById(inputSearch.getAttribute('data-auto'));
a.innerHTML = '';/**/
a.innerHTML = '
';/**/
if($('#'+inputSearch.id+' ~ select[name="search_by_cat"]').length){
categ='/cid='+$('#'+inputSearch.id+' ~ select[name="search_by_cat"]').val();
// console.log('exist categorie'+categ)
}
var position='/searchposition=' +$(inputSearch).data('position') ;
apiUsed = '/api/rest/section=products/template=quicksearch'+categ+position+'/lng=/search='+ inputSearch.value ;
//console.log('stampo risultati'+apiUsed);
//chiamo api
$.ajax({ url: apiUsed,
context: document.body,
type: 'GET',
dataType: "json",
success: function(){
state="success";
},
error: function(data) {
}, complete: function(data){
// console.log(data.responseJSON.message);
if(state=="success"){
var arr =data.responseJSON.rows;
// console.log(inputSearch.getAttribute('data-auto'));
a = document.getElementById(inputSearch.getAttribute('data-auto'));
// a.innerHTML = ' ';/**/
a.innerHTML = '';/**/
a.classList.add('show-auto');
for (i = 0; i < arr.length; i++) {
// console.log(arr[i]['nome_prodotto']);
b = document.createElement("DIV");
var htmlCustom="";
htmlCustom = '' ;//+ arr[i]['nome_prodotto'] ;
// if( !(arr[i]['json_images'].length === 0) ){
if( typeof(arr[i]['json_images']) !== "undefined" && arr[i]['json_images'] !== null ){
htmlCustom += '';
} else{htmlCustom += '
';
}
htmlCustom += "" + arr[i]['nome_prodotto'] + "
";
if(parseInt(arr[i]['prezzo_scontato']) >= 0){
htmlCustom += "";
if( (parseInt(arr[i]['prezzo']) >= 0) && ((parseInt(arr[i]['prezzo'])) !=(parseInt(arr[i]['prezzo_scontato'])) ) ){
htmlCustom += ""+parseFloat(arr[i]['prezzo']).toFixed(2).replace('.', ',')+"€ ";
}
htmlCustom += parseFloat(arr[i]['prezzo_scontato']).toFixed(2).replace('.', ',')+"€ ";
htmlCustom += " ";
}
else{
if(parseInt(arr[i]['prezzo']) >= 0){
htmlCustom += ""+parseFloat(arr[i]['prezzo']).toFixed(2).replace('.', ',')+"€ ";
htmlCustom += " ";
}
}
htmlCustom += " ";
b.innerHTML =htmlCustom;
/* b.innerHTML += " ";
b.addEventListener("click", function(e) {
inp.value = this.getElementsByTagName("input")[0].value;
});*/
a.appendChild(b);
}
if(!arr.length){
b = document.createElement("DIV");
var htmlCustom="";
htmlCustom = 'Nessun prodotto trovato
' ;//+ arr[i]['nome_prodotto'] ;
b.innerHTML =htmlCustom;
a.appendChild(b);/**/
}
if(data.responseJSON.num_results> data.responseJSON.num_rows){
showall = document.createElement("DIV");
showall.innerHTML ='Vedi tutti ';
a.appendChild(showall);
}
}
}
});
}, 500);
}
});
//ricerca autocomplete
/*
function autocomplete(inp, arr) {
var currentFocus;
inp.addEventListener("input", function(e) {
var a, b, i, val = this.value;
closeAllLists();
if (!val) { return false;}
currentFocus = -1;
a = document.createElement("DIV");
a.setAttribute("id", this.id + "autocomplete-list");
a.setAttribute("class", "autocomplete-items");
this.parentNode.parentNode.appendChild(a);
for (i = 0; i < arr.length; i++) {
if ( (arr[i]['nome_prodotto'].toUpperCase().includes(val.toUpperCase()) ) || (arr[i]['id'].toString().includes(val.toUpperCase()) ) || (arr[i]['sku'].toString().includes(val.toUpperCase()) ) ) {
b = document.createElement("DIV");
var htmlCustom="";
htmlCustom = '' ;//+ arr[i]['nome_prodotto'] ;
if(arr[i]['json_images'][0]){
htmlCustom += '';
} else{htmlCustom += '
';
}
htmlCustom += "" + arr[i]['nome_prodotto'] + "
";
if(parseInt(arr[i]['prezzo']) > 0){
htmlCustom += ""+parseFloat(arr[i]['prezzo']).toFixed(2).replace('.', ',')+"€ ";
}
htmlCustom += " ";
b.innerHTML =htmlCustom;
b.innerHTML += " ";
b.addEventListener("click", function(e) {
inp.value = this.getElementsByTagName("input")[0].value;
closeAllLists();
});
a.appendChild(b);
}
}
});
inp.addEventListener("keydown", function(e) {
var x = document.getElementById(this.id + "autocomplete-list");
if (x) x = x.getElementsByTagName("div");
if (e.keyCode == 40) {
currentFocus++;
addActive(x);
} else if (e.keyCode == 38) {
currentFocus--;
addActive(x);
} else if (e.keyCode == 13) {
e.preventDefault();
if (currentFocus > -1) {
if (x) x[currentFocus].click();
}
}
});
function addActive(x) {
if (!x) return false;
removeActive(x);
if (currentFocus >= x.length) currentFocus = 0;
if (currentFocus < 0) currentFocus = (x.length - 1);
x[currentFocus].classList.add("autocomplete-active");
}
function removeActive(x) {
for (var i = 0; i < x.length; i++) {
x[i].classList.remove("autocomplete-active");
}
}
}*/
function closeAllLists(elmnt) {
var x = document.getElementsByClassName("autocomplete-items");
for (var i = 0; i < x.length; i++) {
if (elmnt != x[i] && (!elmnt.classList.contains('quick_search') )) {
x[i].classList.remove('show-auto');
// x[i].parentNode.removeChild(x[i]);
}
}
}
document.addEventListener("click", function (e) {
closeAllLists(e.target);
});
/*
setTimeout(function(){
var now = new Date();
if ((parseInt(localStorage.getItem("timeSearch")) < parseInt(now.getTime() - 86400000)) || (!localStorage.getItem("timeSearch"))) {
$.ajax({ url: '/api/rest/section=products/template=quicksearch',// /api/rest/section=products/template=quicksearch/search=mar
context: document.body,
type: 'GET',
dataType: "json",
success: function(){
state="success";
},
error: function(data) {
}, complete: function(data){
// console.log(data.responseJSON.message);
if(state=="success"){
localStorage.setItem('jsonSearch',JSON.stringify(data.responseJSON.rows));
localStorage.setItem('timeSearch', new Date().getTime());
if(document.getElementById("search_menu_nametop")){ autocomplete(document.getElementById("search_menu_nametop"), JSON.parse(localStorage.getItem("jsonSearch")));}
if(document.getElementById("search_menu_name")){ autocomplete(document.getElementById("search_menu_name"), JSON.parse(localStorage.getItem("jsonSearch")));}
console.log(JSON.parse(localStorage.getItem("jsonSearch")));
}
}
});
}else{
if(document.getElementById("search_menu_nametop")){ autocomplete(document.getElementById("search_menu_nametop"), JSON.parse(localStorage.getItem("jsonSearch")));}
if(document.getElementById("search_menu_name")){ autocomplete(document.getElementById("search_menu_name"), JSON.parse(localStorage.getItem("jsonSearch")));}
console.log(JSON.parse(localStorage.getItem("jsonSearch")));
}
}, 2000);*/
// filter isotope
// external js: isotope.pkgd.js
// init Isotope
if( $('.filter_grid').length){
var $grid = $('.filter_grid').isotope({
itemSelector: '.filter-item',
layoutMode: 'fitRows'
});
// filter functions
var filterFns = {
// show if number is greater than 50
numberGreaterThan50: function() {
var number = $(this).find('.number').text();
return parseInt( number, 10 ) > 50;
},
// show if name ends with -ium
ium: function() {
var name = $(this).find('.name').text();
return name.match( /ium$/ );
}
};
// bind filter button click
$('.filters-button-group').on( 'click', 'button', function() {
var filterValue = $( this ).attr('data-filter');
// use filterFn if matches value
filterValue = filterFns[ filterValue ] || filterValue;
$grid.isotope({ filter: filterValue });
});
// change is-checked class on buttons
$('.button-group').each( function( i, buttonGroup ) {
var $buttonGroup = $( buttonGroup );
$buttonGroup.on( 'click', 'button', function() {
$buttonGroup.find('.is-checked').removeClass('is-checked');
$( this ).addClass('is-checked');
});
});
}
// END filter isotope
//'use strict';
$('body').on('change','input',function(e){
$(e.currentTarget).attr('data-empty', !e.currentTarget.value);
// console.log(e.currentTarget.value);
});
// iPad and iPod detection
var isiPad = function(){
return (navigator.platform.indexOf("iPad") != -1);
};
var isiPhone = function(){
return (
(navigator.platform.indexOf("iPhone") != -1) ||
(navigator.platform.indexOf("iPod") != -1)
);
};
var dropDownMenu = function() {
$(".drop-down-menu").hover(function(){
$(this).addClass('active');
},
function(){
$(this).removeClass('active');
});
};
var loaderPage = function() {
$(".fh5co-loader").fadeOut("slow");
};
var goToTop = function() {
$('.js-gotop').on('click', function(event){
event.preventDefault();
$('html, body').animate({
scrollTop: $('html').offset().top
}, 500, 'easeInOutExpo');
return false;
});
$(window).scroll(function(){
var $win = $(window);
if ($win.scrollTop() > 200) {
$('.js-top').addClass('active');
} else {
$('.js-top').removeClass('active');
}
});
};
var owlCarouselMenuCat = function() {
var owl = $('.menu_categorie_top');
owl.owlCarousel({
margin:0,
nav:true,
//center: true,
URLhashListener: false,
dots:false,
navText: [
' ',
' '
],
// loop:true,
autoWidth:true,
items:4
})
}
/**/
var owlCarouselMainProd = function() {
var owlProd = $('.owl-carousel-prod');
owlProd.owlCarousel({
items:1,
autoHeight: true,
mouseDrag: true,
loop: false, //non va la navigazione con le thumb altrimenti..
thumbs: false,
thumbsPrerendered: false,
margin: 0,
responsiveClass: true,
nav: true,
dots: true,
smartSpeed: 100,
//autoplay: true,
navText: [
' ',
' '
],
callbacks: true,
autoplayHoverPause: true,
});
$(window).resize(function(){
hh_set();
owlProd.trigger('refresh.owl.carousel');
});
};
var mainOwlDetail = $("#mainOwlDetail");
$(function(){
$('.checkbox_required').change(function(){
var name = $(this).attr("name");
if($('.checkbox_required').is(':checked')) {
$('.checkbox_required[name="'+name+'"]').removeAttr('required');
} else {
var n = $( '.checkbox_required[name="'+name+'"]:checked' ).length;
if(n >0 ){
$('.checkbox_required[name="'+name+'"]').removeAttr('required');
}else{
$('.checkbox_required[name="'+name+'"]').attr('required', 'required');
}
}
});
});
$('body').on('click', '#thumb_seq .button', function(event){
//$("#thumb_seq").on("click", ".button", function(e) {
event.preventDefault();
var number = $(this).parent().index();
// console.log('asd' + number);
$('#mainOwlDetail').data('owl.carousel').to(number, 300, true);
});
$('body').on('click', '.showInfo[data-action]', function(event){
event.preventDefault();
var id = $(this).data('id') ;
var action = $(this).data('action') ;
var apiChange ='apidachiamare***&action='+action+'&id='+id;
CallApi(apiChange,$(this),'','','','','updateTooltipInfo('+id+','+action+')');
// call api
//update tooltip title
});
function updateTooltipInfo(id,action,title){
var title_new="";
if(action == 'mail'){
title_new="Scrivi a" + title; //***mettere eventuale traduzione
}
else if(action == 'tel'){
title_new="Chiama il " + title;
}
$('.cta_real_{$prod.recordID|intval}[data-action="'+action+'"] i').attr('data-original-title', title_new).tooltip('show');
}
$(".thumb_seq").on("click", ".button", function(e) {
e.preventDefault();
var number = $(this).index();
$(this).parent().prev().data('owl.carousel').to(number, 300, true);
});
var owlcarouselOneobj = function() {
var owl = $('.owl-carousel-one-obj');
// var item_count = parseInt($(owl).find('.slide').length);
var item_count = parseInt($('.owl-carousel-one-obj>div ').length);
owl.owlCarousel({
nav: true,
dots: true,
onInitialize: function(event) {
if (item_count <= 1) {
this.settings.loop = false;
this.settings.nav = false;
this.settings.dots = false;
}
// I have more than one slide?! Great what are my options?!
else {
this.settings.loop = true;
this.settings.nav = true;
this.settings.dots = true;
}
},
items:1,
mouseDrag: true,
loop: true,
margin: 2,
// nav: true,
smartSpeed: 500,
// autoplay: true,
autoplayHoverPause: true,
URLhashListener: false,
navText: [
' ',
' '
]
});
$(window).resize(function(){
owl.trigger('refresh.owl.carousel');
});
};
var Carousel5itemnoloop = function() {
var owl = $('.carousel-5-item-noloop');
owl.owlCarousel({
items:5,
mouseDrag: true,
loop: false,
margin: 0,
responsiveClass: true,
nav: true,
//dots: true,
//autoHeight: true,
smartSpeed: 500,
responsive:{
0:{
items:2,
nav:false
},
500:{
items:2,
nav:false
},
768:{
items:5,
nav:true
}
},
autoplay: true,
autoplayHoverPause: true,
navText: [
' ',
' '
]
});
$(window).resize(function(){ owl.trigger('refresh.owl.carousel'); });
};
var offcanvasMenu = function() {
$('#wrap').prepend('
');
$('#fh5co-offcanvas').append( $('#fh5co-main-nav').clone() );
};
var burgerMenu = function() {
$('body').on('click', '.js-fh5co-nav-toggle', function(event){
var $this = $(this);
if ( $('body').hasClass('offcanvas-visible') ) {
$('body').removeClass('fh5co-overflow offcanvas-visible');
$this.removeClass('active');
} else {
$('body').addClass('fh5co-overflow offcanvas-visible');
$this.addClass('active');
}
event.preventDefault();
});
$('#fh5co-offcanvas').css('height', $(window).height());
$(window).resize(function() {
$('#fh5co-offcanvas').css('height', $(window).height());
if ( $('body').hasClass('offcanvas-visible') ) {
$('body').removeClass('offcanvas-visible');
$('.js-fh5co-nav-toggle').removeClass('active');
}
});
$(window).scroll(function(){
if ( $('body').hasClass('offcanvas-visible') ) {
$('body').removeClass('offcanvas-visible');
$('.js-fh5co-nav-toggle').removeClass('active');
}
});
};
$('.galleria_fotografica').each(function() { // the containers for all your galleries
$(this).magnificPopup({
delegate: 'a:not(.no-popup):not(.popup-video)',
type: 'image',
removalDelay: 300,
mainClass: 'mfp-with-zoom',
gallery: {
enabled:true
},
image: {
titleSrc: 'data-title'
},
zoom: {
//enabled: true,
enabled: false,
duration: 300,
easing: 'ease-in-out',
// The "opener" function should return the element from which popup will be zoomed in
// and to which popup will be scaled down
// By defailt it looks for an image tag:
opener: function(openerElement) {
// openerElement is the element on which popup was initialized, in this case its tag
// you don't need to add "opener" option if this code matches your needs, it's defailt one.
return openerElement.is('img') ? openerElement : openerElement.find('img');
}
}
});
});
// MagnificPopup
var magnifPopup = function() {
$('.image-popup').magnificPopup({
type: 'image',
removalDelay: 300,
mainClass: 'mfp-with-zoom',
gallery:{
enabled:true
},
zoom: {
enabled: true,
duration: 300,
easing: 'ease-in-out',
// The "opener" function should return the element from which popup will be zoomed in
// and to which popup will be scaled down
// By defailt it looks for an image tag:
opener: function(openerElement) {
// openerElement is the element on which popup was initialized, in this case its tag
// you don't need to add "opener" option if this code matches your needs, it's defailt one.
return openerElement.is('img') ? openerElement : openerElement.find('img');
}
}
});
};
var magnifPopupSingle = function() {
$('.image-popup-single').magnificPopup({
type: 'image',
removalDelay: 300,
mainClass: 'mfp-with-zoom',
gallery:{
enabled:false
},
zoom: {
enabled: true,
duration: 300,
easing: 'ease-in-out',
// The "opener" function should return the element from which popup will be zoomed in
// and to which popup will be scaled down
// By defailt it looks for an image tag:
opener: function(openerElement) {
// openerElement is the element on which popup was initialized, in this case its tag
// you don't need to add "opener" option if this code matches your needs, it's defailt one.
return openerElement.is('img') ? openerElement : openerElement.find('img');
}
}
});
};
var magnifPopupGalleryIframe = function() {
$('.popupPDF').magnificPopup({
delegate: 'a.popupPDF_link', // the selector for gallery item
type: 'iframe',
removalDelay: 300,
mainClass: 'mfp-fade',
gallery:{
enabled:true
},
iframe: {
// options for image content type
titleSrc: 'title'
}
});
};
var magnifVideo = function() {
$('.popup-youtube, .popup-vimeo, .popup-gmaps,.popup-video').magnificPopup({
// disableOn: 700,
type: 'iframe',
mainClass: 'mfp-fade',
removalDelay: 160,
preloader: false,
fixedContentPos: false,
callbacks: {
markupParse: function(template, values, item) {
if(item.el.hasClass( "ratio3by4" ) ){
template.addClass('embed-responsive-3by4');
}
else if(item.el.hasClass( "ratio1by1" ) ){
template.addClass('embed-responsive-1by1');
}
else if(item.el.hasClass( "ratio4by3" ) ){
template.addClass('embed-responsive-4by3');
}
else if(item.el.hasClass( "ratio21by9" ) ){
template.addClass('embed-responsive-21by9');
}
}
}
});
};
// Animations
var contentWayPoint = function() {
};
fadefn();
setTimeout(function(){ }, 500);
// Call the functions
magnifPopup();
magnifPopupSingle();
magnifVideo();
magnifPopupGalleryIframe();
$(window).on("load", function() {
hh_set();
//dropDownMenu();
/* owlCarouselMainFade();
owlCarouselMainFadeOutRight();
owlCarouselMainSlideVertical();
owlCarouselMainFlipX();
owlCarouselMainFlipY();
owlCarouselMain();*/
owlCarouselUnified();
owlCarouselMainProd();
owlCarouselMenuCat();
Carousel5itemnoloop();
owlcarouselOneobj();
offcanvasMenu();
burgerMenu();
loaderPage();
goToTop();
// Animate
contentWayPoint();
$('.select_combinazioni').on('change', function() {
changeImage(this.value,eval($(this).data('imagecombo')),$(this).data('id'));
});
});
}());
$( window ).resize(function() {
lancia_vetrina();
createHamb();
});
function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
};
function changeImage(value,arraycombo,id){
if(arraycombo[value]){
if(id){
$('#spinner'+id ).removeClass('hide');
// console.log('#spinner'+id )
var comboName=arraycombo[value]['name'];
var newImage=arraycombo[value]['images'][0];
// console.log('');
setTimeout(function(){
$('#spinner'+id ).addClass('hide');
}, 500);
}
else{
$('.image_detail_col .spinner-border').removeClass('hide');
var wall= false ;
var comboName=arraycombo[value]['name'];
var thumbpart='';
var mainpart='';
if(wall){
$.each( arraycombo[value]['images'], function( key, value ) {
thumbpart+=' ';
});
$( '#thumb_seq .comboImage' ).each(function( index ) {
$(this).remove();
})
$('#thumb_seq').append(thumbpart)
//magari refresh magnifPopup
$('[data-toggle="tooltip"]').tooltip();
setTimeout(function(){
$('.image_detail_col .spinner-border').addClass('hide');
}, 500);
}
else{
$.each( arraycombo[value]['images'], function( key, value ) {
thumbpart+='';
thumbpart+='';
thumbpart+=' ';
thumbpart+=' ';
mainpart+='';
mainpart+='
';
});
$( '#mainOwlDetail .comboImage' ).each(function( index ) {
$('.owl-carousel-prod').owlCarousel('remove', $(this).parent().index()).trigger('refresh.owl.carousel');
$('#thumb_seq').owlCarousel('remove', $(this).parent().index()).trigger('refresh.owl.carousel');
})
$('#thumb_seq').trigger('add.owl.carousel', [thumbpart]).trigger('refresh.owl.carousel');
$('.owl-carousel-prod').trigger('add.owl.carousel', [mainpart]).trigger('refresh.owl.carousel');
$('[data-toggle="tooltip"]').tooltip();
setTimeout(function(){
$( '#mainOwlDetail .comboImage' ).each(function( index ) {
$('.owl-carousel-prod').trigger('to.owl.carousel', $(this).parent().index())
})
$('.image_detail_col .spinner-border').addClass('hide');
}, 500);
}
}
}
}
var header_h =$('header').outerHeight();
function scrollDocument(target) {
if(!header_h){
var header_h =$('header').outerHeight();
}
if( $(target).length ) {
$('html, body').animate({
scrollTop: $(target).offset().top - header_h /*???*/
}, 1000);
}
};
function validate_req() {
if (document.getElementById('dati_diversi').checked) {
$('#dati_diversi_elenco .required').each(function(i, obj) {
//console.log("checked1");
$( this ).attr('required', '');
});
} else {
$('#dati_diversi_elenco .required').each(function(i, obj) {
$( this ).removeAttr('required');
});
}
console.log("validate_req");
}
function validate_req_register(btn) {
var container_input = $(btn).attr("data-controls");
if ($(btn).hasClass('collapsed') ) {
$((container_input) + ' .billing_required').each(function(i, obj) {
//console.log("checked2");
$( this ).attr('required', '');
});
} else {
$((container_input) + ' .billing_required').each(function(i, obj) {
$( this ).removeAttr('required');
});
}
}
function letterAnim(container) {
setTimeout(function () {
$(container).find(".letter").addClass('bigfind');
}, 800);
}
function fadefn() {
$('.fade_in').each(function() {
$(this).waypoint(function() {
letterAnim($(this.element));
$(this.element).addClass('animated fadeIn');
}, { offset: '100%' } );
});
$('.fade_up').each(function() {
$(this).waypoint(function() {
letterAnim($(this.element));
$(this.element).addClass('animated fadeInUp');
}, { offset: '100%' } );
});
$('.fade_down').each(function() {
letterAnim($(this.element));
// animate_this_element(this);
$(this).waypoint(function() {
letterAnim($(this.element));
$(this.element).addClass('animated fadeInDown');
}, { offset: '100%' } );
});
$('.fade_right').each(function() {
// animate_this_element(this);
$(this).waypoint(function() {
letterAnim($(this.element));
$(this.element).addClass('animated fadeInRight');
}, { offset: '100%' } );
});
$('.fade_left').each(function() {
// animate_this_element(this);
$(this).waypoint(function() {
letterAnim($(this.element));
$(this.element).addClass('animated fadeInLeft');
}, { offset: '100%' } );
});
}
function createHamb(){
setTimeout(function(){
//var ulw=$('#mainMenu').width() - $('#mainMenu li.wishlist.icon').width() - $('#mainMenu li.carrello.icon').width() - $('#mainMenu .include_login_bar').width() ;
var ulw=$('#mainMenu').width() - 33 ;
//console.log( ulw +'w');
if( $('#mainMenu .include_login_bar').css("display") != "none" ){
ulw =ulw - $('#mainMenu .include_login_bar').width();
}
// console.log( ulw +'w include_login_bar');
if( $('#mainMenu li.search').css("display") != "none" ){
ulw =ulw - $('#mainMenu li.search').width();
}
// console.log( ulw +'w search');
if( $('#mainMenu li.wishlist.icon').css("display") != "none" ){
ulw =ulw - $('#mainMenu li.wishlist.icon').width();
}
// console.log( ulw +'w wishlist');
if( $('#mainMenu li.carrello.icon').css("display") != "none" ){
ulw =ulw - $('#mainMenu li.carrello.icon').width();
}
// console.log( ulw +'w carrello');
if( $('#mainMenu li.lang_li').css("display") != "none" ){
ulw =ulw - $('#mainMenu li.lang_li').width();
}
// console.log( ulw +'w lang_li');
/*
if( $('#mainMenu li+li.spacer_m').css("display") != "none" ){
ulw =ulw - $('#mainMenu li+li.spacer_m').outerWidth();
}*/
// console.log( ulw +'w spacer_m end');
var lispace=0;
//console.log( ulw);
//console.log( 'window).width() > 767 '+window.outerWidth);
// if($(window).width() > 767){
if(document.documentElement.clientWidth > 767){
//console.log( 'document.documentElement.clientWidth'+ document.documentElement.clientWidth)
// console.log( 'window).width() > 767')
$( "#page-container:not(.hamburger_sx):not(.hamburger_dx) #mainMenu >li:not(#hamburgerDeskLi):not(.icon):not(.lang_li):not(.include_login_bar)" ).each(function( index ) {
lispace += $( this ).width();
// console.log('lispace >>' + $( this ).width());
if(lispace>ulw && this.id){
$( ".spacer_m").addClass('p-0');
$('#'+ this.id).detach().appendTo("#hamburgerDesk");
$('#hamburgerDeskLi').removeClass('hide');
}
});
}
}, 1000);
}
function lancia_vetrina() {
if($(window).width() < 768){
$(function(){
var owlCarouselVetrina = function() {
var owl = $('.accordianul');
owl.owlCarousel({
items:1,
autoplayTimeout:3500,
autoHeight: false,
mouseDrag: true,
loop: true,
margin: 0,
responsiveClass: true,
nav: true,
dots: false,
transitionStyle : "fade",
//autoHeight: true,
smartSpeed: 300,
autoplay: true,
autoplayHoverPause: true /**//*,
navText: [
' ',
' '
]*/
});
};
owlCarouselVetrina();
});
}
}
let stateCheck = setInterval(() => {
if (document.readyState === 'complete') {
clearInterval(stateCheck);
// console.log('complete');
//read hash in url
if(window.location.hash) {
if($(window.location.hash+' .faq_item').length) {
$(window.location.hash+' .faq_item').trigger('click');
}
if($(window.location.hash+'_control').length){
$(window.location.hash+'_control').trigger('click');
}
setTimeout(function() {
scrollDocument(window.location.hash);
}, 300);
}
}
}, 100);
$(document).ready(function(){
if($('.item_in_cart_n_sec').length){
quickCart();
}
else{
$('.item_in_cart_n_sec').html(0)
$('.total_in_cart_sec').html(0)
}
$(document).on("click", ".cb_has_child", function () {
if($(this).parent().hasClass('open_child')){
$(this).parent().removeClass('open_child');
$(this).parent().find('input:checkbox').prop('checked', false);
}
else{
$(this).parent().addClass('open_child');
$(this).parent().find('input:checkbox').prop('checked', true);
}
submitFn('formFilter')
});
$(document).on("click", ".open_cb", function () {
$(this).parent().toggleClass('open_child');
});
$(document).on("mouseover", ".loading-cart", function () {
quickCart();
});
if (document.getElementById('ProdottiVisti') || (document.getElementById('ProdottiVisti_full'))) {
smpidscookie=getCookie('smpids');
console.log('cookie_last_seen_pids:'+smpidscookie);
if (document.getElementById('ProdottiVisti') && (typeof smpidscookie !== 'undefined' && ( smpidscookie !== '0,' ))) {
CallApi('/api/rest/section=products/template=quicksearch/ids='+smpidscookie,'#ProdottiVisti','','','','','prodotti_visti()');
}
if (document.getElementById('ProdottiVisti_full') && (typeof smpidscookie !== 'undefined' && ( smpidscookie !== '0,' ))) {
var section_api="";
if(document.getElementById('ProdottiVisti_full').classList.contains('lastseen_cart')){
section_api="source=cart/"
}
CallApi('/api/html/section=product-lastseen/template=full/'+section_api+'ids='+smpidscookie,'#ProdottiVisti_full','','','','','prodotti_ultimi_visti');
}
if((typeof smpidscookie === 'undefined' || ( smpidscookie === '0,' ))){
$('.prodotti_visti,.ProdottiVisti_main ').addClass('hidden');
}
}
var copyTextareaBtn = document.querySelector('.js-textareacopybtn');
$(document).on("click", ".js-textareacopybtn", function () {
var copyTextarea = $( this ).next();
copyTextarea.select();
try {
// $( this ).find('i').tooltip('hide').attr('data-original-title', '✔Link copiato').tooltip('show');
$( this ).html( '✔Link copiato ') ;
$( this ).parent( ).addClass('copied');
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
} catch (err) { $( this ).html(' ✕ Error!');
alert('Not copied');
}
});
$(document).on("click", ".notify-action", function (e) {
e.preventDefault();
var postdata="";
var idact=$(this).data('id');
$('#notify_'+idact+'_mail').each(function(){
//console.log($(this).val());
postdata += '&'+$(this).attr('name')+'='+ $(this).val();
});
document.getElementById('notify_'+idact+'_mail').reportValidity();
if(document.getElementById('notify_'+idact+'_mail').reportValidity()){
var baseApi="/go.php?function=api&action=backorder&command=add&pid="+$(this).data('id');
CallApi(baseApi,$(this).parents('.notify_box'), postdata ,"",'submitted_notify','','') ;
}
//console.log(postdata);
});
$('.wishlist-action').click(function(e){
if($(this).hasClass( "action_add" )){ var actionBtn="add"}
else{var actionBtn="delete"}
var baseApi="/go.php?function=api&action=wishlist&command="+actionBtn+"&pid="+$(this).data('id');
if($(this).hasClass( "wishlist-remove" )){
CallApi(baseApi,$(this).closest('.prodotto_row'),'','',"",'removeRow','','updateWishlist()') ;
}
else{
CallApi(baseApi,$(this).parent('.wishlist_box'),'','actionMade'+actionBtn,"action_add",'','updateWishlist()') ;
}
});
$('button[data-target="#AddToCartModal"]').click(function(e){
var id=$(this).data('id');
var baseApi="/api/html/section=product-overlay/template=full/id="+id;
CallApi(baseApi,'#spinnerAdd','','' ,"",'','insertFormAdd()') ;
});
$('#modalSize').on('shown.bs.modal', function () {
setTimeout(() => {
$(".lazy").lazyload({effect : "fadeIn",
skip_invisible :false
});
}, "1500");
})
$('body').on('click', '.btn_apiAdd', function(event){
event.preventDefault();
if(!$(this).hasClass('disabled')){
var id=$(this).data('id');
var qtytoAdd =parseInt($('#quantita_prod'+id).val());
if(parseInt($('#quantita_prod'+id).attr('max'))){
var maxtoAdd =parseInt($('#quantita_prod'+id).attr('max'));
}else{ var maxtoAdd =1000000000000;}
/*console.log(qtytoAdd)
console.log(maxtoAdd) */
var inpputRequiredFilled=true;
//console.log('quantita_prod'+id);
document.getElementById('quantita_prod'+id).reportValidity();
$("form#shop_"+id+"_form [required]").each(function(){
document.getElementById($(this).attr('id')).reportValidity();
});
$("form#shop_"+id+"_form .hf-invalid").each(function(){
inpputRequiredFilled=false;
if(!$( "form#shop_"+id+"_form" ).hasClass( "field-required" )){
$("form#shop_"+id+"_form").append( 'Compila i campi obbligatori
' ).addClass('field-required');
}
});
if( qtytoAdd <= maxtoAdd){
// CallApi(apiChange,btn,postdata,classToAdd,classToggle,removeRow,FnBack) {
//
var apiAdd="/api/rest/section=cart/command=add/id="+id;
var postdata="";
$("form#shop_"+id+"_form input:not([type=button]):not([type=checkbox]):not([type=radio]),form#shop_"+id+"_form textarea,form#shop_"+id+"_form select,form#shop_"+id+"_form input[type=checkbox]:checked,form#shop_"+id+"_form input[type=radio]:checked").each(function(){
// var input = $(this).attr('name'); // This is the jquery object of the input, do what you will
postdata += '&'+$(this).attr('name')+'='+ $(this).val();
});
if(inpputRequiredFilled){
if($( "form#shop_"+id+"_form" ).hasClass( "field-required" )){
$("form#shop_"+id+"_form").removeClass('field-required');
$("form#shop_"+id+"_form .required_field_alert").remove( );
}
CallApi(apiAdd,'',postdata,'','','','itemAdded("'+id+'")');
}/**/
//console.log(postdata)
}
/*else { console.log('abbassa la qty bello mio!*** ')}*/
}else{
}
});
//set hash to url
/* */
$('.faq_item').click(function(e){
e.preventDefault();
// window.location.hash = $(this).closest('.panel-heading').attr('id');
if(history.pushState) {
history.pushState(null, null, window.location.pathname+'#'+$(this).closest('.panel-heading').attr('id'));
}
else {
location.hash = window.location.pathname+'#'+$(this).closest('.panel-heading').attr('id');
}
/*setTimeout(function() {
scrollDocument(window.location.hash);
}, 300);*/
});
$(".select_combinazioni").each(function(i) {
var idQty = $(this).closest('.attribute_container').find('.quantita_prod').attr('id');
var nMinQty = $("option:selected", this).data('combination_qty');
if(!nMinQty){ nMinQty = 100000}
$('#'+idQty).attr({ "max" : nMinQty});
document.getElementById(idQty).reportValidity();
});
$( ".select_combinazioni" ).change(function () {
var idQty = $(this).closest('.attribute_container').find('.quantita_prod').attr('id');
var nMinQty = $("option:selected", this).data('combination_qty');
//if(parseInt(nMinQty) <1){ console.log(nMinQty);}
if(!nMinQty){ nMinQty = 100000}
$('#'+idQty).attr({ "max" : nMinQty});
setTimeout(function(){
document.getElementById(idQty).reportValidity();
}, 10);
})
$('.show-open').modal('show');
$('body').on('click', '.table_discount_qty tr', function(event){
$("input#quantita_prod"+$('.table_discount_qty').attr('data-prodid' )).val($(this).attr('data-setqty' ));
$(this).tooltip( {
container: 'body',
html: true,
selector: 'tr',
trigger: 'manual',
title: function() {
return $(this).attr('data-title' ) ;
}
});
$(this).tooltip('show');
setTimeout(function(){ $('tr').tooltip('hide'); }, 2000);
})
$('.dropdown-submenu .dropdown-toggle').on("click", function(e){
$(this).parent().toggleClass('open');
e.stopPropagation();
e.preventDefault();
});
//#menu_cont
/*
$('#calendar').fullCalendar({
monthNames: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
monthNamesShort:['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
dayNames:['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
dayNamesShort:['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'],
firstDay: 1,
// titleFormat: 'DD, MM, YYYY' ,
buttonText:{
today: 'oggi',
month: 'mese',
week: 'sett',
day: 'giorno',
list: 'lista'
},
eventLimitText: "...",
height: 500,
header: {
center: 'title',
right:'',
left:''
},
footer: {
left: 'prev,next today',
right: 'month,basicWeek,basicDay'
},
// defaultDate: '2017-05-12',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: eventi // var dichiarata nel modulo
})*/
})
$(document).ready(function() {
if (document.getElementById('goBack')){
//console.log(history.length);
if (history.length <3) {
// if history is not empty, go back:
$('#goBack').fadeOut()
}
}
$('.form-label ').find('input').each(function( index ,e) {
if( $(this).val() == ''){
$(this).attr('data-empty', true);
}else{
$(this).attr('data-empty', false);
}
});
var currentURL = $(location).attr('href');
$('.changeurl').each(function(i, obj) {/*
if($(this).hasClass('elenco')){
var res = currentURL.replace('/shop/grid', '/shop/list');
} else{
var res = currentURL.replace('/shop/list', '/shop/grid');
}
console.log('switch js res:');
console.log(res);
// $(this).href = res;
// this.setAttribute("style", "background-color: red;");
this.setAttribute("href", res);*/
});
if (document.getElementById('container_sticky')){
moveScroller();}
$('.form_register_form').submit(function(event) {
$("#ModalSignUp").animate({ scrollTop: 0 }, 1000);
});
window.addEventListener('load', function(){
/*
A NodeList of all your image containers (Or a single Node).
The library will locate an within each
container to create the gradient from.
*/
if (document.querySelector('.gradient-wrap') !== null) {
Grade(document.querySelectorAll('.gradient-wrap'))
}
})
$('.togglesidebarbtn').click(function() {
$('.sidebar').toggleClass('active');
$('.sidebar .hide_sidebar:not('+$(this).data('show')+')').addClass('hide');
$($(this).data('show')).removeClass('hide');
$('#page-container').toggleClass('sidebar_open')
})
$('.toggle_search').click(function() {
//console.log('asd')
// document.getElementById("mytext").focus();
if(!$('.navbar-toggle').hasClass('collapsed')){
$($('.navbar-toggle')).trigger('click');
}
$('.search').toggleClass('active');
$('#page-container').toggleClass('search_open')
})
$('.toggle_search_products').click(function() {
$('.search_products').toggleClass('active');
$('#page-container').toggleClass('search_open_products')
})
if (document.getElementById("search_gridlist_name")){
if (document.getElementById("search_gridlist_name").value.trim() != '') {
$('.search_products').addClass('active');
$('#page-container').addClass('search_open_products')
}
}
$(document).click(function(e) {
var sidebar = $(".sidebar, .togglesidebarbtn");
var cerca = $(".search, .toggle_search");
if (!sidebar.is(e.target) && sidebar.has(e.target).length === 0) {
sidebar.removeClass('active');
$('#page-container').removeClass('sidebar_open')
}
if (!cerca.is(e.target) && cerca.has(e.target).length === 0) {
cerca.removeClass('active');
$('#page-container').removeClass('search_open')
}
var cercaprod = $(".search_products, .toggle_search_products");
if (!cercaprod.is(e.target) && cercaprod.has(e.target).length === 0) {
cercaprod.removeClass('active');
$('#page-container').removeClass('search_open_products')
}
});
var inputs = document.querySelectorAll( '.inputfile' );
Array.prototype.forEach.call( inputs, function( input )
{
var label = input.nextElementSibling,
labelVal = label.innerHTML;
input.addEventListener( 'change', function( e )
{
var fileName = '';
if( this.files && this.files.length > 1 )
fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '[count]', this.files.length );
else
fileName = e.target.value.split( '\\' ).pop();
if( fileName )
label.querySelector( 'span' ).innerHTML = fileName;
else
label.innerHTML = labelVal;
});
});
$('#select_5').change(function() {
checkselectvariante();
});
createHamb();
lancia_vetrina();
$(function(){
$('[data-toggle="tooltip"]').tooltip();
});
$('.load_this').click(function() {
//if($("#enlarge a").attr("href") != $(this).data("href")){
// $(this).next().next().attr("href", $("#enlarge a").attr("href")); }
// $(this).next().next().addClass("hide");
$("#enlarge a").attr("href", $(this).data("href"));
$("#enlarge a").attr("title", $(this).data ("title"));
$("#enlarge img").attr("src", $(this).data("enlarge"));
$("#select_5").val($(this).data("select"));
});
$('.prodotti_elenco_minimal input.quantita_prod').on("change paste keyup", function() {
hasOption($(this));
});
//if exist input type email
var inputm = document.querySelectorAll("input[type=email]:required");
for (var i = 0; i < inputm.length; i++) {
// console.log()
hyperform.addValidator(
document.getElementById(inputm.item(i).id), function(element) {
var mailformat = /^([A-Za-z0-9_\-\.\+])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,20})$/;
var valuemail= document.getElementById(element.id).value;
if(valuemail != '' && valuemail.match(mailformat)){
//console.log("VALID email address.");
var valid = true;
}
else{
//console.log("Invalid email address.");
//document.getElementById(emailId).focus();
var valid = false;
}
element.setCustomValidity(valid? '' :
//
'Inserisci email valida');
//
return valid;
});
}
function hyperformfunction(id) { /*console.log('function hyperformfunction');*/
hyperform.addValidator(
document.getElementById(id), function (element) {
if($(element).hasClass('billing_required')){
var valid = ! document.getElementById('dati_diversi').checked || element.value;
//
element.setCustomValidity( valid? '' :'Inserisci il testo qui perchè hai compilato dati di fatturazione diversi' );
//
//console.log(valid)
return valid;
}
}
//'the script returned true';
);
}
if( document.getElementById('billing_email')){ hyperformfunction('billing_email'); }
if( document.getElementById('billing_firstname')){ hyperformfunction('billing_firstname'); }
if( document.getElementById('billing_lastname')){ hyperformfunction('billing_lastname'); }
if( document.getElementById('billing_company_name')){ hyperformfunction('billing_company_name'); }
if( document.getElementById('billing_address_1')){ hyperformfunction('billing_address_1'); }
if( document.getElementById('billing_city')){ hyperformfunction('billing_city'); }
if( document.getElementById('billing_state')){ hyperformfunction('billing_state'); }
if( document.getElementById('billing_zip_code')){ hyperformfunction('billing_zip_code'); }
if( document.getElementById('billing_country')){ hyperformfunction('billing_country'); }
if( document.getElementById('billing_phone_number')){ hyperformfunction('billing_phone_number'); }
if( document.getElementById('billing_mobile_number')){ hyperformfunction('billing_mobile_number'); }
if( document.getElementById('billing_vat_id')){ hyperformfunction('billing_vat_id'); }
if( document.getElementById('billing_tax_id')){ hyperformfunction('billing_tax_id'); }
/* whenever the checkbox is clicked, revalidate the text field, too */
if( document.getElementById('billing_email')){
document.getElementById('dati_diversi').addEventListener('click', function() { console.log('click dati_Diversi');
/* if( document.getElementById('billing_email')){ document.getElementById('billing_email').reportValidity(); }
if( document.getElementById('billing_firstname')){ document.getElementById('billing_firstname').reportValidity(); }
if( document.getElementById('billing_lastname')){ document.getElementById('billing_lastname').reportValidity(); }
if( document.getElementById('billing_company_name')){ document.getElementById('billing_company_name').reportValidity(); }
if( document.getElementById('billing_company_name')){ document.getElementById('billing_company_name').reportValidity(); }
if( document.getElementById('billing_address_1')){ document.getElementById('billing_address_1').reportValidity(); }
if( document.getElementById('billing_city')){ document.getElementById('billing_city').reportValidity(); }
if( document.getElementById('billing_state')){ document.getElementById('billing_state').reportValidity(); }
if( document.getElementById('billing_zip_code')){ document.getElementById('billing_zip_code').reportValidity(); }
if( document.getElementById('billing_country')){ document.getElementById('billing_country').reportValidity(); }
if( document.getElementById('billing_phone_number')){ document.getElementById('billing_phone_number').reportValidity(); }
if( document.getElementById('billing_mobile_number')){ document.getElementById('billing_mobile_number').reportValidity(); }
if( document.getElementById('billing_vat_id')){ document.getElementById('billing_vat_id').reportValidity(); }
if( document.getElementById('billing_tax_id')){ document.getElementById('billing_tax_id').reportValidity(); }
*/
});
}
hyperform(window);
$(window).scroll(function(){
if (document.getElementById('logo_sopra_menu')){
var scroll_change = $("#preheader").height();
}
else{ var scroll_change = 10;}
var currentScroll=$(this).scrollTop();
if($(this).scrollTop()> scroll_change){
$('#page-container').addClass('scrolldown');
$('#page-container').removeClass('top');
}
else{
$('#page-container').removeClass('scrolldown');
$('#page-container').addClass('top');}
var st = $(window).scrollTop();
if (document.getElementById('fixBottomContainer')){
ReleaseOnScroll('fixBottom','fixBottomContainer',st);
}
if (document.getElementById('menuFixContainer')){
FixAttachOnScroll('stickyBox','menuFixContainer',st);
}
if (document.getElementById('stickyBoxProduct')){
// FixAttachOnScroll(target,container,st) {
FixAttachOnScroll('stickyBoxProduct','stickyProductContainer',st);
$("#stickyBoxProduct").width( $('#stickyBoxProduct').width()) ;
}
if (document.getElementById('stickyfilters')){
// FixAttachOnScroll('stickyBoxfilters','stickyfilters',st);
FixAttachOnScroll('stickyfilters','stickyBoxfilters',st);
}
});
$('.obbligo').change(function(e){
var str = $(this).attr("id");
var res = str.replace("_privacy", "_submit");
var tooltip = str.replace("_privacy", "tltp");
var sendbtn = document.getElementById(res);
sendbtn.disabled = !this.checked;
if(this.checked){$('#'+tooltip).tooltip('disable')}
else{$('#'+tooltip).tooltip('enable')}
});
$('.scrollpage,a[href^="#"]:not(.dropdown-toggle):not(.faq_item):not([data-toggle="tab"])').click(function() {
//console.log('click a href'+$(this).attr('href'))
if ($(this).parents('div#navbar').length) {
$('.navbar-toggle').click();
$('div#navbar .active').removeClass('active');
$(this).parent().addClass('active');
}
event.preventDefault();
scrollDocument($(this).attr('href'));
});
$('#page-container').addClass('js');
if ( $( "#call_button" ).length ) {
$('#page-container').addClass('call_button_space');
if( $( "#call_button" ).hasClass('hidden-md') || $( "#call_button" ).hasClass('hidden-lg') ) {
$('#page-container').addClass('call_button_no_space_desktop'); }
if( $( "#call_button" ).hasClass('hidden-sm') || $( "#call_button" ).hasClass('hidden-xs') ) {
$('#page-container').addClass('call_button_no_space_mobile'); }
}
if ( $( "#sedeleg" ).length ) {
$('#page-container').addClass('sedeleg_h');
}
if ( $( "#sedeam" ).length ) {
$('#page-container').addClass('sedeam_h');
}
var uagent = navigator.userAgent.toLowerCase();
// console.log(uagent);
if (uagent.search("mobile") > -1){
$('#page-container').addClass('mobile_dev');
$( "form" ).each(function( index ) {
$( this ).append(' ');
});
console.log('mobile');}
else{
//desktop
}
$('.prodotti_grid').children().each(function() {
$(this).on("mouseover", function(event) {
var marginBottom, targetClass;
marginBottom = 0;
targetClass = $(this).children().find('.content_info');
// targetClass = $(this);
$('.extrainfo', this).map(function() {
marginBottom = marginBottom + parseInt($(this).outerHeight());
});
if (marginBottom > 0) {
// $(this).css('margin-bottom', '-' + marginBottom + 'px');
// console.log(marginBottom);
}
});
$(this).on("mouseout", function(event) {
// $(this).removeAttr('style');
});
});
})
function animate_this(sub,animation,direction,i){
if( direction === 'down' && !$(sub.element).hasClass('animated') ) {
i++;
$(sub.element).addClass('item-animate');
setTimeout(function(){
$(sub.element).addClass(animation).removeClass('item-animate');
/* $('body .fadeInLeft.item-animate').each(function(k){
var el = $(sub);
setTimeout( function () {
el.addClass('fadeInLeft animated');
el.removeClass('item-animate');
}, k * 200, 'easeInOutExpo' );
}); */
}, 100);
}
}
function incrementValue(segno){
var id_prod= $(segno).attr('data-idprodotto');
var value = parseInt(document.getElementById('quantita_prod' + id_prod).value, 10);
value = isNaN(value) ? 0 : value;
value++;
document.getElementById('quantita_prod' + id_prod).value = value;
hasOption($('#quantita_prod' + id_prod));
}
function decrementValue(segno){
var id_prod= $(segno).attr('data-idprodotto');
var value = parseInt(document.getElementById('quantita_prod' + id_prod).value, 10);
var minValue = parseInt(document.getElementById('quantita_prod' + id_prod).min, 10);
value = isNaN(value) ? 0 : value;
if(value != minValue){value--;}
document.getElementById('quantita_prod' + id_prod).value = value;
hasOption($('#quantita_prod' + id_prod));
}
function hasOption(inputN){
var idQty=inputN.attr("id");
var idSelect=inputN.parents('.attribute_container').find('.custom-select').attr("id");
if(idSelect){
document.getElementById(idSelect).reportValidity();
/* register a custom validator for the text field */
console.log(inputN.val());
hyperform.addValidator(
document.getElementById(idSelect),
function (element) {
var valid2 = ! (inputN.val()>0) || element.value;
console.log('value '+valid2)
element.setCustomValidity(
valid2?
'' :
'Compila questo campo.'
);
return valid2;
}
);
document.getElementById(idQty).reportValidity();
hyperform(window);
}
/*
console.log('hasOption')
$('#'+idSelect).prop('required',false);
$('#'+idSelect).attr('novalidate');
$(inputN).prop('required',false);
document.getElementById(idSelect).validity.valid;
document.getElementById(idSelect).reportValidity();
document.getElementById(idQty).reportValidity(); */
//}
}
function checkselectvariante() {
if($('*[data-select="'+$("#select_5").val()+'"]')){
$("#enlarge a").attr("href", $('*[data-select="'+$("#select_5").val()+'"]').data("href"));
$("#enlarge img").attr("src", $('*[data-select="'+$("#select_5").val()+'"]').data("enlarge"));
}
}
function submitFn(id) {
$("#"+id).submit().addClass('red');
// $("#"+id).submit().addClass('red');
//$( "#"+id )[0].submit();
console.log('submit '+id)
}
function hh_set(){
$(".space_header").css("padding-top", $('header').outerHeight()+"px");
}
function moveScroller() {
var move = function() {
var st = $(window).scrollTop();
if (document.getElementById('sidebar')){
// console.log('sdf')
var ot = $("#container_sticky").offset().top - 125;
var oh = $("#container_sticky").height() + ot - $("#sidebarCont").height() ;
// var ob = $("#personalize_box").offset().bottom;
var s = $("#sidebar");
if(st > ot) {
// $("#fix_title").addClass('fix');
s.addClass('boxfix');
if(st > oh) {s.addClass('boxfixbottom');$('body').addClass('nearbott');}
else {if(st <= oh) { s.removeClass('boxfixbottom'); $('body').removeClass('nearbott');}}
}
else {if(st <= ot) { s.removeClass('boxfix');
// $("#fix_title").removeClass('fix');
//boxfixbottom
}}
}
};
$(window).scroll(move);
move();
}
function FixAttachOnScroll(target,container,st) {
if($("#logo_sopra_menu" ).length > 0) {
var header = 50;
} else{
var header = $('#page-container header').height();
}
var ot = $('#'+container).offset().top - header;
var oh = $('#'+container).height() + ot - $('#'+target).height() - 0 ;
// var ob = $("#section1").offset().bottom;
var s = $('#'+target);
$('#'+ target ).css( "top", header );
if(st > ot) {
// console.log('st > ot');
s.addClass('boxfixed' );
if(st > oh) {
s.addClass('boxfixbottom' );
}
else {if(st <= oh) {
// console.log('st <= article_box").height() + ot');
s.removeClass('boxfixbottom'); }}
}
else {if(st <= ot) { s.removeClass('boxfixed');
//boxfixbottom
}}
}
function ReleaseOnScroll(target,container,st) {
var ot = $('#'+container).offset().top ;
var oh = $('#'+container).height() ;
var total = ot + oh - $(window).height() ;
var s = $('#'+target);
if(st > total ) {
//console.log('add class');
s.addClass('boxRelease' );
}
else { s.removeClass('boxRelease');
}
}
function WMsetCookie(cname,cvalue,exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function WMgetCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function wmVideoAutoPlay(container,videoId) {
var videoHtml="";
videoHtml += '';
videoHtml += '';
videoHtml += '
';
$(container).html( videoHtml ) ;
}
var prodotti_visti_list;
var prodotti_cart_list;
function CallApi(apiChange,btn,postdata,classToAdd,classToggle,removeRow,FnBack,type) {
if(!type){ var type='POST';}
event.preventDefault();
$(btn).children( ".spinner-border" ).removeClass('hide') ;
var state="";
$.ajax({ url: apiChange,
context: document.body,
type: type,
data: postdata,
dataType: "json",
success: function(){
state="success";
$(btn).children( ".spinner-border" ).addClass('hide');
},
error: function(data) {
alert("Si è verificato un errore ricarica la pagina");
$(btn).children( ".spinner-border" ).addClass('hide');
}, complete: function(data){
// console.log(data.responseJSON);
if(state=="success" && data.responseJSON.status!='error'){
if(removeRow){ $(btn).remove();}
else{
$(btn).addClass(classToAdd);
$(btn).children('.wishlist-action,.notify_form').toggleClass( classToggle);
setTimeout(function(){ $(btn).removeClass(classToAdd); }, 1500);
$(btn).children( ".spinner-border" ).addClass('hide');}
// if(FnBack.toString() ){
if(FnBack !== undefined ){
if(FnBack.toString() == 'insertFormAdd()'){
$(btn).addClass('ready');
$('#containerAdd').html(data.responseJSON.html);
setTimeout(function(){
//owlCarouselUnified();
var owlCarouselUnified =function() {
$( ".owl-unified" ).each(function( index ) {
var owl=$( this );
var thumbs=false;
// items
var items=1;
var itemsMobile=1;
var itemsTablet=1;
var itemsDesktop=1;
var loop=true;
var autoplayTimeout=5000;
var dots=true;
var nav=true;
if(owl.hasClass('owl-thumbs')){ autoplayTimeout=2000; items=5; itemsDesktop=5; itemsTablet=5; itemsMobile=4; }
if(owl.hasClass('no-loop')){ loop=false; }
if ($( this ).children().length <= 1) {
loop=false;
dots=false;
nav=false;
}
if($( owl ).hasClass('owl-carousel-main-thumb')){ thumbs=true; }
var effect='';
owl.owlCarousel({
nav: nav,
dots: dots,
lazyLoad:true,
items:items,
responsive:{
0:{ items:itemsMobile,
nav:false},
500:{items:itemsTablet,
nav:true },
768:{items:itemsDesktop,
nav:true },
1200:{items:items,
nav:true }
},
autoHeight: false,
autoplay:true,
autoplayTimeout:autoplayTimeout,
mouseDrag: true,
loop: loop,
thumbs: thumbs,
thumbsPrerendered: true,
margin: 0,
responsiveClass: true,
smartSpeed: 800,
navText: [
' ',
' '
],
callbacks: true,
URLhashListener: false,
autoplayHoverPause: true,
animateOut: effect,
});
$(window).resize(function(){
owl.trigger('refresh.owl.carousel');
});
});
}
owlCarouselUnified();
var owlCarouselMainProd = function() {
var owlProd = $('.owl-carousel-prod');
owlProd.owlCarousel({
items:1,
autoHeight: true,
mouseDrag: true,
loop: false, //non va la navigazione con le thumb altrimenti..
thumbs: false,
thumbsPrerendered: false,
margin: 0,
responsiveClass: true,
nav: true,
dots: true,
smartSpeed: 100,
//autoplay: true,
navText: [
' ',
' '
],
callbacks: true,
autoplayHoverPause: true,
});
$(window).resize(function(){
owlProd.trigger('refresh.owl.carousel');
});
};
owlCarouselMainProd();
}, 1500);
}
else if(FnBack.toString() == 'updateWishlist()'){
var prevWishlistItem=Number($('.item_in_wishlist_n').html());
if (data.responseJSON.wid){ $('.item_in_wishlist_n').removeClass('hide').html(prevWishlistItem + 1);}
else {
prevWishlistItem =- 1;
$('.item_in_wishlist_n').html(Number($('.item_in_wishlist_n').html()) - 1);
if(prevWishlistItem == 0){$('.item_in_wishlist_n').addClass('hide')}
}
}
else if(FnBack.toString() == 'insertTextTermini()'){
$('#modalprivacy_iub_content').html(data.responseJSON.content)
//eval(FnBack.replace(")","'"+data.responseJSON.content +"')"));
}
else if (FnBack.toString().match("^updateTooltipInfo")) {
eval(FnBack.replace(")",",'"+data.responseJSON.info +"')"));
}
else if (FnBack.toString().match("^itemAdded")) {
eval(FnBack.replace(")",",'"+data.responseJSON.cart_num_prods +"','"+data.responseJSON.cart_total +"')"));
}
else if (FnBack.toString() == ("QuickCartItem()")) {
prodotti_cart_list=data.responseJSON;
eval(FnBack.replace(")", " )"));
}
else if (FnBack.toString().match("prodotti_visti()")) {
prodotti_visti_list=data.responseJSON.rows;
eval(FnBack.replace(")", " )"));
}
else if (FnBack.toString().match("prodotti_ultimi_visti()")) {
console.log('ProdottiVisti_full')
$('#ProdottiVisti_full').html(data.responseJSON.html)
setTimeout(function(){
var Carousel5itemnoloop = function() {
var owl = $('.carousel-5-item-noloop');
owl.owlCarousel({
items:5,
mouseDrag: true,
loop: false,
margin: 0,
responsiveClass: true,
nav: true,
//dots: true,
//autoHeight: true,
smartSpeed: 500,
responsive:{
0:{
items:2,
nav:false
},
500:{
items:2,
nav:false
},
768:{
items:5,
nav:true
}
},
autoplay: true,
autoplayHoverPause: true,
navText: [
' ',
' '
]
});
$(window).resize(function(){ owl.trigger('refresh.owl.carousel'); });
};
Carousel5itemnoloop();
}, 100);
}
else{
//loadContent();
// console.log(FnBack.replace(")", ",'"+data.responseJSON.status+"')"));
console.log(data.responseJSON.message );
//eval(FnBack.replace(")", "'"+api+"','"+tplHtml+"','"+container+"')"));
eval(FnBack.replace(")",",'"+data.responseJSON.status+"')"));
// eval(FnBack);
}
}
}
else if(data.responseJSON.status == 'error'){
console.log(data.responseJSON.message)
var erroralert=''+data.responseJSON.message+'
';
$(btn ).find('.form-group.label_float ').append(erroralert)
// CallApi(baseApi,$(this).parents('.notify_box'), postdata ,"",'submitted_notify','','') ;
// CallApi(apiChange,btn,postdata,classToAdd,classToggle,removeRow,FnBack,type) {
}
}
});
}
function QuickCartItem(){
//console.log('QuickCartItem')
var cartHtml='';
//console.log(prodotti_cart_list)
if(prodotti_cart_list.rows.length != 0){
cartHtml+='';
//foreach
$.each(prodotti_cart_list.rows, function( index, value ) {
cartHtml+='
';
});
cartHtml+='
';
cartHtml+=' Totale prodotti
';
cartHtml+= parseFloat(prodotti_cart_list.cart_total).toFixed(2).replace('.', ',');
$('.item_in_cart_n_sec').html(prodotti_cart_list.cart_num_prods);
$('.total_in_cart_sec').html(parseFloat(prodotti_cart_list.cart_total).toFixed(2).replace('.', ','));
cartHtml+='€ ';
cartHtml+='
';
cartHtml+=' ';
cartHtml+="Procedi con l'ordine ";
cartHtml+=' ';
cartHtml+=' ';
cartHtml+="Vai al carrello ";
cartHtml+=' ';
}else{
/* X NESSUN PRODOTTO
*/
$('.item_in_cart_n_sec').html(0);
$('.total_in_cart_sec').html(0);
cartHtml+='
Non ci sono prodotti nel carrello ';
}
$('.QuickCartBox').html(cartHtml);
$('[data-toggle="tooltip"]').tooltip();
}
function prodotti_visti(){
var lista='' ;
$.each(prodotti_visti_list, function( index, value ) {
var iva =''
lista+='';
});
$( "#ProdottiVisti" ).append( lista );
}
function quickCart( JustAdd){
$('.QuickCart.loading-cart').removeClass('loading-cart')
CallApi('/api/rest/section=cart/command=list/?&rnd='+Math.floor((Math.random() * 10000) + 1)
,'.dropdownCart','','','','','QuickCartItem()','');
};
function itemAdded(id,incart,total){
$("#AddToCartModal").modal('hide');
$('.carrello i,.carrello_sezione_sign').addClass('productAdded');
quickCart();
$('#anchor_prod_'+id).parent().addClass('item_added');
setTimeout(function() {
$( ".carrello >a> i " ).each(function( index ) {
if($( this ).next('.item_in_cart_n').length){
$( this ).next('.item_in_cart_n').html(incart)
}
else{
$( this ).after( ''+incart+" " );
}
});
//$('.item_in_cart_n_sec').html(incart)
//$('.total_in_cart_sec').html(parseFloat(total).toFixed(2).replace('.', ','))
}, 2000);
setTimeout(function() {
$('.carrello i,.carrello_sezione_sign').removeClass('productAdded');
$('#anchor_prod_'+id).parent().removeClass('item_added');
}, 10000);
}
/**/
// Set a Cookie
function setCookie(cName, cValue, expDays) {
let date = new Date();
date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = cName + "=" + cValue + "; " + expires + "; path=/";
}
function getCookie(cName) {
const name = cName + "=";
const cDecoded = decodeURIComponent(document.cookie); //to be careful
const cArr = cDecoded .split('; ');
let res;
cArr.forEach(val => {
if (val.indexOf(name) === 0) res = val.substring(name.length);
})
return res;
}