function revertCarrello(){ Richiesta(); var divDettagli = document.getElementById('dettaglioCarrelloMini'); var imgShowCarrello = document.getElementById('showCarrelloMiniImg'); if(divDettagli!=null){ if(divDettagli.style.display=='none'){ divDettagli.style.display=''; if(imgShowCarrello!=null) imgShowCarrello.src='/custom/images/template/hide_carrello.jpg'; }else{ divDettagli.style.display='none'; if(imgShowCarrello!=null) imgShowCarrello.src='/custom/images/template/show_carrello.jpg'; } } } var XMLHTTP; function Richiesta() { var millis = new Date().getTime(); var url = "/carrello/revertCarrello.jsp?time="+millis; XMLHTTP = RicavaBrowser(CambioStato); XMLHTTP.open("GET", url, true); XMLHTTP.send(null); } function CambioStato() { if (XMLHTTP.readyState == 4) { //alert(XMLHTTP.responseText); } } function isFunction(functionToCheck) { var getType = {}; return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'; } function isFunction2(obj) { return !!(obj && obj.constructor && obj.call && obj.apply); }; function RicavaBrowser(QualeBrowser) { //alert(navigator.userAgent); if (navigator.userAgent.indexOf("MSIE") != (-1)) { var Classe = "Msxml2.XMLHTTP"; if (navigator.appVersion.indexOf("MSIE 5.5") != (-1)); { Classe = "Microsoft.XMLHTTP"; } try { OggettoXMLHTTP = new ActiveXObject(Classe); OggettoXMLHTTP.onreadystatechange = QualeBrowser; return OggettoXMLHTTP; } catch(e) { alert("Errore: l'ActiveX non verrà eseguito!"); } } else if (navigator.userAgent.indexOf("Mozilla") != (-1)) { OggettoXMLHTTP = new XMLHttpRequest(); OggettoXMLHTTP.onload = QualeBrowser; OggettoXMLHTTP.onerror = QualeBrowser; return OggettoXMLHTTP; } else { // alert("L'esempio non funziona con altri browser!"); } } fade=600; function recuperaJquery(o) { if (o.fn) { return o; } return null; } function modifica_prodotto_cart(idArticolo,qta,idMagazzino){ realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); var qs='id='+idArticolo+'&idMagazzino=' + idMagazzino; if(qta==null||parseInt(qta)<=0) qs+='&delete=true'; else qs+='&qta='+qta; realjq.ajax({ type: "POST", url: "/UpdateProdottoCarrello.do", data: qs, dataType: "xml", cache: false, success: function(xml) { if(xml!=null){ realjqxml = realjq( xml ); esito = realjqxml.find( "esito" ); esito = realjq( esito ).text(); if(esito!=null&&esito==1){ if(realjq('#carrello_mini_elegance_refresh').length>0) { realjq.ajax ({ type: "GET", url: "/include/carrello/carrelloMiniElegance.jsp", data: 'listArticoli=opened', cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { try{realjq('#carrello_mini_elegance_refresh').html(html);}catch(err){} } }).done(function(result){ ripristinaQuantita(idArticolo,idMagazzino); }); } if(realjq('#carrello_refresh').length>0||realjq('.carrello_refresh').length>0) { // possibile sia usare la classe che l'id per il carrello refresh realjq.ajax ({ type: "GET", url: "/carrello/carrelloMini.jsp", data: 'listArticoli=opened', cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_refresh').html(html); realjq('.carrello_refresh').each(function () { $(this).html(html); }); } }).done(function(result){ ripristinaQuantita(idArticolo,idMagazzino); }); } oltreMaxPezziAcquistabiliPerOrdine = realjqxml.find( "oltreMaxPezziAcquistabiliPerOrdine" ); oltreMaxPezziAcquistabiliPerOrdine = realjq( oltreMaxPezziAcquistabiliPerOrdine ).text(); if (oltreMaxPezziAcquistabiliPerOrdine != null && oltreMaxPezziAcquistabiliPerOrdine === 'true'){ alert('Per questo prodotto non è possibile ordinare altri pezzi'); } oltreLimitaNumeroPezziPerProdottoInOrdine = realjqxml.find( "oltreLimitaNumeroPezziPerProdottoInOrdine" ); oltreLimitaNumeroPezziPerProdottoInOrdine = realjq( oltreLimitaNumeroPezziPerProdottoInOrdine ).text(); if (oltreLimitaNumeroPezziPerProdottoInOrdine != null && oltreLimitaNumeroPezziPerProdottoInOrdine === 'true'){ alert('Non è possibile ordinare ulteriori pezzi di prodotto per ordine'); } } } } }); } // override this function to provide another page function getUrlCarrelloMini() { return "/carrello/carrelloMini.jsp"; } function ripristinaQuantita(idArticolo,idMagazzino){ if(idMagazzino == null || idMagazzino == '') idMagazzino = '0'; realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); var id = 'idProdotto='+idArticolo; realjq.ajax ({ type: "GET", url: "/RecuperaQuantita.do", data: id, success: function(html) { realjq('#qta_chk_'+idArticolo+'_'+idMagazzino).val(html); } }); } function aggiungiArticolo(idArticolo,id_div_contenuto,id_blocco,img,tempoChiusura,idMagazzino,tipologia) { token="_"+idMagazzino; if(idMagazzino==null||idMagazzino==''){ idMagazzino=-1; token=""; } //prima controllo che i dati inseriti siano consistenti: realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); fly=false; if(idArticolo!=null){ var qta=realjq('input[name="qta'+idArticolo+token+'"]').val();//document.getElementById("qta"+idArticolo).value; if(qta!=null&&parseInt(qta,10)){ // campo hidden che contiene il numero di pezzi che posso ancora mettere nel carrello. -1 se il controllo è disabilitato var qtaCheckEl=realjq('input[name="qta_chk_'+idArticolo+token+'"]'); var qtaCheck = -1; var qtaRes = -1; // qtaCheck se è <>-1 mi indica quanti pezzi posso mettere nel carrello if(qtaCheckEl!=null&&!isNaN(qtaCheckEl.val())){ qtaCheck = parseInt(qtaCheckEl.val()); if(qtaCheck>=0){ if(qtaCheck==0){ // quantità residua di magazzino = 0 alert(msgAlertQta); return; }else if(qta>qtaCheck){ // quantità desiderata > di quella residua: chiedo conferma if(!confirm(msgConfirmQta.replace('#qtaCheck#',''+qtaCheck))){ return; } qta = qtaCheck; qtaRes = qtaCheck - qta; // aggiorno la quantità residua }else{ // tutto ok qtaRes = qtaCheck - qta; // aggiorno la quantità residua } }else{ //alert('Non controllo'); } } realjq('img[name="addButton_'+idArticolo+token+'"]').hide(); realjq('button[name="addButton_'+idArticolo+token+'"]').hide(); try{realjq('#div_box_qta_'+idArticolo+token).hide();}catch(err){} realjq('#attesa_'+idArticolo+token).show(); var qs='id='+idArticolo+'&qta='+qta+'&idM='+idMagazzino+'&tipologia='+tipologia; var qss='idProdotto='+idArticolo+'&qta='+qta+'&idM='+idMagazzino+'&tipologia='+tipologia; realjq.ajax ({ type: "POST", url: "/AddProdottoCarrello.do", data: qs, dataType: "xml", cache: false, success: function(xml) { if(xml!=null){ realjqxml = realjq( xml ); prodottiAggiunti = realjqxml.find( "prodottiAggiunti" ).text(); esito = realjqxml.find( "esito" ); esito = realjq( esito ).text(); if(esito!=null&&esito==1){ // usare sempre #carrello_refresh oppure .carrello_refresh //numeroPezziCampagna = realjqxml.find( "limiteNumeroPezzi" ).text(); //realjq('#limite_quantita').html(numeroPezziCampagna); /* if(numeroPezziCampagna == 0) { // attualmente questo è l'identificatore usato nelle pagine realjq.ajax ({ type: "POST", url: '/include/responsive/getNumeroPezziCampagna.jsp?&'+qss, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#bloccoPrezzo').html(html.trim()); //realjq('#limite_pezzi_testo').hide(); } }); */ realjq.ajax({ type: "POST", url: '/include/responsive/getNumeroPezziCampagna.jsp?&'+qss, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { var trimStr = $.trim(html); if(trimStr.length>0){ realjq('#bloccoPrezzo'+idArticolo).html(trimStr) } } }); /*} if(numeroPezziCampagna == 1) { htmlLimitePezzitesto = realjq('#limite_pezzi_testo').html(); htmlLimitePezzitestoReplace = htmlLimitePezzitesto.replace("pezzi","pezzo"); realjq('#limite_pezzi_testo').html(htmlLimitePezzitestoReplace); } */ if(realjq('#carrello_refresh').length>0||realjq('.carrello_refresh').length>0) { // attualmente questo è l'identificatore usato nelle pagine realjq.ajax ({ type: "POST", url: getUrlCarrelloMini(), data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_refresh').html(html); realjq('.carrello_refresh').each(function () { $(this).html(html); }); qtaRes = (qtaCheck != -1) ? (qtaCheck - prodottiAggiunti) : -1; qtaCheckEl.val(qtaRes); } }); } if(realjq('.carrello_refresh_mobile').length>0) { realjq.ajax ({ type: "POST", url: "/carrello/carrelloMini.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('.carrello_refresh_mobile').html(html); qtaRes = (qtaCheck != -1) ? (qtaCheck - prodottiAggiunti) : -1; qtaCheckEl.val(qtaRes); } }); } if(realjq('#carrello_mini_refresh').length>0) { realjq.ajax ({ type: "POST", url: "/include/responsive/carrello/carrelloMini.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_mini_refresh').html(html); qtaRes = (qtaCheck != -1) ? (qtaCheck - prodottiAggiunti) : -1; qtaCheckEl.val(qtaRes); } }); } if(realjq('#carrello_mini_elegance_refresh').length>0) { realjq.ajax ({ type: "POST", url: "/include/responsive/carrello/carrelloMini.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_mini_elegance_refresh').html(html); qtaRes = (qtaCheck != -1) ? (qtaCheck - prodottiAggiunti) : -1; qtaCheckEl.val(qtaRes); } }); } if(realjq('#carrello_mini_ruby_refresh').length>0) { realjq.ajax ({ type: "POST", url: "/include/responsive/carrello/carrelloMiniRuby.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_mini_ruby_refresh').html(html); qtaRes = (qtaCheck != -1) ? (qtaCheck - prodottiAggiunti) : -1; qtaCheckEl.val(qtaRes); } }); } if(realjq('#carrello_mini_smart_refresh').length>0) { realjq.ajax ({ type: "POST", url: "/include/responsive/carrello/carrelloMiniSmart.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_mini_smart_refresh').html(html); qtaRes = (qtaCheck != -1) ? (qtaCheck - prodottiAggiunti) : -1; qtaCheckEl.val(qtaRes); } }); } if(realjq('#carrello_mini_noprodotti_refresh').length>0) { realjq.ajax ({ type: "POST", url: "/include/responsive/carrello/carrelloMiniNoProdotti.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_mini_noprodotti_refresh').html(html); qtaRes = (qtaCheck != -1) ? (qtaCheck - prodottiAggiunti) : -1; qtaCheckEl.val(qtaRes); } }); } if(realjq('#carrello_mini_elegance_refresh').length>0) { realjq.ajax ({ type: "POST", url: "/include/responsive/carrello/carrelloMiniElegance.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_mini_elegance_refresh').html(html); qtaRes = (qtaCheck != -1) ? (qtaCheck - prodottiAggiunti) : -1; qtaCheckEl.val(qtaRes); } }); } totaleCarrelloOp = realjqxml.find( "totaleCarrello" ).text(); numeroArticoli = realjqxml.find( "numeroArticoli" ).text(); prodottiAggiunti = realjqxml.find( "prodottiAggiunti" ).text(); totaleSeparato = realjqxml.find( "totaleSeparato" ).text(); nome = realjqxml.find( "nome" ).text(); try{ //if(prodottiAggiunti!=null&&parseInt(prodottiAggiunti,10)<=1){ //} if(numeroArticoli!=null&&parseInt(numeroArticoli,10)<=1){ realjq('#card_articolo').show(); realjq('#card_articoli').hide(); }else{ realjq('#card_articoli').show(); realjq('#card_articolo').hide(); } }catch(err){} //realjq('#'+id_div_contenuto).html(contenutoDiv); realjq('#num_prod_carrello').html(numeroArticoli); realjq('#tot_carrello').html("€ "+totaleCarrelloOp); realjq('#nome_prodotto').html(nome); realjq('#prod_aggiunti').html(prodottiAggiunti); if(totaleSeparato!=null&&totaleSeparato!=""){ realjq('#tot_carrello_separato').html("€ "+totaleSeparato); realjq("#span_separato").show(); }else{ realjq("#span_separato").hide(); } /* var moveLeft = 30; var moveDown = 15; pos = realjq("#"+img).offset(); posTab = realjq("#tabProdPosition").offset(); width = realjq("#"+img).width(); //show the menu directly over the placeholder */ if(tempoChiusura!=null && parseInt(tempoChiusura)>0){ if(realjq('#'+id_blocco).length>0) { resetTimer(id_blocco); openDiv(tempoChiusura,id_blocco,fade); // se metto tempo di chiusura faccio aprire e chiudere anche l'overlay di background openDiv(tempoChiusura,'overlay_carrello',fade); /* realjq('#'+id_blocco).fadeOut(fade,function(){ // realjq('#'+id_blocco).css({ "left": ((pos.left + width +moveLeft)-posTab.left) + "px", "top":(pos.top-posTab.top +moveDown) + "px" }) openDiv(timeFade,id_blocco,fade); //ripristinaTasto(idArticolo); }); */ ripristinaTasto(idArticolo,token); //realjq('#'+id_blocco).delay(5000).fadeOut(fade); }else{ //realjq('#'+id_blocco).fadeIn(fade).delay(5000).fadeOut(fade); //realjq('#'+id_blocco).css({ "left": ((pos.left + width +moveLeft)-posTab.left) + "px", "top":(pos.top-posTab.top +moveDown) + "px" }) openDiv(tempoChiusura,id_blocco,fade) ripristinaTasto(idArticolo,token); } }else{ openDiv(tempoChiusura,id_blocco,fade) realjq('#overlay_carrello').show(); ripristinaTasto(idArticolo,token); } if (realjqxml.find( "notificaDiv" ) != null && realjqxml.find( "notificaDiv" ).text() != ''){ alert(realjqxml.find( "notificaDiv" ).text()); } if (realjqxml.find( "notificaDivProdotto" ) != null && realjqxml.find( "notificaDivProdotto" ).text() != ''){ $(".middleNav").append(''); $('.alert-catalogo-prodotti').fadeIn(200); $('.alert-catalogo-prodotti').delay(7000).fadeOut(); } }else{ ripristinaTasto(idArticolo,token); erroreAlert = realjqxml.find( "erroreAlert" ).text(); erroreInserimentoProdotto(id_div_contenuto,erroreAlert); } if(realjq('#contenutoOpcCart').length>0) { location.reload(true); } }else{ ripristinaTasto(); erroreInserimentoProdotto(id_div_contenuto,"Impossibile aggiungere il prodotto nel carrello") } } }); //FINE PRIMA CHIAMATA AJAX //}); if(fly){ productIDVal = idArticolo; var productX = realjq("#immagineArticolo_" + productIDVal).offset().left; //l'immagine var productY = realjq("#immagineArticolo_" + productIDVal).offset().top; //l'immagine var basketX = realjq("#dettaglioCarrelloMini").offset().left;//riga nel carrello relativa al prodotto var basketY = realjq("#dettaglioCarrelloMini").offset().top; var gotoX = basketX - productX; var gotoY = basketY - productY; var newImageWidth = realjq("#immagineArticolo_" + productIDVal).width() / 3; var newImageHeight = realjq("#immagineArticolo_" + productIDVal).height() / 3; realjq("#immagineArticolo_" + productIDVal + " > a > img") .clone() .prependTo("#immagineArticolo_" + productIDVal) .css({'position' : 'absolute'}) .animate({opacity: 0.4}, 100 ) .animate({opacity: 0.1, marginLeft: gotoX, marginTop: gotoY, width: newImageWidth, height: newImageHeight}, 1200); } }else{ alert('Inserire la quantita\' del prodotto'); } } return false; } function ripristinaTasto(idArticolo,token){ //setTimeout(function(){ realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); if(realjq('#attesa_'+idArticolo+token).length>0) { realjq('#attesa_'+idArticolo+token).hide(); try{realjq('#div_box_qta_'+idArticolo+token).show();}catch(err){} } if(!realjq('img[name="addButton_'+idArticolo+token+'"]').length==0) { realjq('img[name="addButton_'+idArticolo+token+'"]').show(); try{realjq('#div_box_qta_'+idArticolo+token).show();}catch(err){} } if(!realjq('button[name="addButton_'+idArticolo+token+'"]').length==0) { realjq('button[name="addButton_'+idArticolo+token+'"]').show(); try{realjq('#div_box_qta_'+idArticolo+token).show();}catch(err){} } // },200); } function disableTasto( idArticolo ) { } function erroreInserimentoProdotto(id,testo){ alert('Errore nel salvataggio: '+testo); } function openDiv(timedur,id_blocco,fade){ realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); realjq('#'+id_blocco).css('opacity',''); realjq('#'+id_blocco).fadeIn(fade,function() { if(timedur!=null&&parseInt(timedur)>0){ var elem = realjq(this); realjq.data(this, 'timer', setTimeout(function() { elem.fadeOut(fade); }, timedur)); } }); } function resetTimer(id_blocco){ //realjq('#'+id_blocco).css('opacity'); realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); clearTimeout(realjq('#'+id_blocco).stop().data('timer')); } function chiudiAvvisoCarrello(idDiv){ realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); realjq('#overlay_carrello').hide(); resetTimer(idDiv); realjq('#'+idDiv).fadeOut(fade); $("#overlay_wishlist").css("display", "none"); } function redirectToUrl(url){ window.location.href = url; } function ordinaArticoloMagazzino(idArticolo,idMagazzino) { token="_"+idMagazzino; if(idMagazzino==null||idMagazzino==''){ idMagazzino=-1; token=""; } //prima controllo che i dati inseriti siano consistenti: realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); if(idArticolo!=null){ var qta=realjq('input[name="qta'+idArticolo+token+'"]').val();//document.getElementById("qta"+idArticolo).value; if(qta!=null&&parseInt(qta,10)){ test = confirm('Vuoi ordinare il prodotto?'); if(test){ realjq('#attesa_'+idArticolo+token).show(); realjq('#addButton_'+idArticolo+token).hide(); window.location.href="/SendOrdineMagazzinoInit.do?id="+idArticolo+"&idM_"+idArticolo+"="+idMagazzino+"&qta_"+idArticolo+"="+parseInt(qta,10); } } } return false; } function cambiaQuantitaElemento(riferimento,direzione){ if(direzione=='0'){ // decremento di un pezzo la quantità riferimento.value--; if(riferimento.value<=0){ // se dopo il decremento la qta è >0 riferimento.value='1'; // porto la quantità a 1 } } if(direzione=='1'){ // incremento di un pezzo la quantità riferimento.value++; } } function aggiungiToWishlist(idArticolo,id_div_contenuto,id_blocco,tempoChiusura) { //prima controllo che i dati inseriti siano consistenti: realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); fly=false; if(idArticolo!=null){ realjq('button[name="addWishButton_'+idArticolo+'"]').hide(); realjq('a[name="addWishButton_'+idArticolo+'"]').hide(); realjq('#attesaWish_'+idArticolo).show(); var qs='id='+idArticolo; realjq.ajax ({ type: "POST", url: "/AddProdottoWishlist.do", data: qs, dataType: "xml", cache: false, success: function(xml) { if(xml!=null){ realjqxml = realjq( xml ); esito = realjqxml.find( "esito" ); esito = realjq( esito ).text(); if(esito!=null&&esito==1){ // usare sempre #carrello_refresh nome = realjqxml.find( "nome" ).text(); realjq('#nome_prodotto_wishlist').html(nome); if(tempoChiusura!=null && parseInt(tempoChiusura)>0){ if(realjq('#'+id_blocco).length>0) { resetTimer(id_blocco); openDiv(tempoChiusura,id_blocco,fade); ripristinaTastoWishList(idArticolo); }else{ openDiv(tempoChiusura,id_blocco,fade) ripristinaTastoWishList(idArticolo); } }else{ openDiv(tempoChiusura,id_blocco,fade) realjq('#overlay_carrello').show(); ripristinaTastoWishList(idArticolo); } $("#overlay_wishlist").css("display", "block"); }else{ ripristinaTastoWishList(idArticolo); erroreAlert = realjqxml.find( "erroreAlert" ); erroreInserimentoProdotto(id_div_contenuto,erroreAlert); } }else{ ripristinaTastoWishList(); erroreInserimentoProdotto(id_div_contenuto,"Impossibile aggiungere il prodotto nella wishlist") } } }); //FINE PRIMA CHIAMATA AJAX } return false; } function ripristinaTastoWishList(idArticolo){ realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); if(realjq('#attesaWish_'+idArticolo).length>0) { realjq('#attesaWish_'+idArticolo).hide(); } if(!realjq('img[name="addWishButton_'+idArticolo+'"]').length==0) { realjq('img[name="addWishButton_'+idArticolo+'"]').show(); } if(!realjq('button[name="addWishButton_'+idArticolo+'"]').length==0) { realjq('button[name="addWishButton_'+idArticolo+'"]').show(); } if(!realjq('a[name="addWishButton_'+idArticolo+'"]').length==0) { realjq('a[name="addWishButton_'+idArticolo+'"]').show(); } } function rimuoviProdottoDaWishlist(idProdotto){ if(confirm('Vuoi cancellare il prodotto dalla wishlist?')){ window.location.href='/DeleteProdottoWishlist.do?id='+idProdotto; } } function spostaArticoloNellaWishlist(idArticolo,id_div_contenuto,id_blocco,img,tempoChiusura,idMagazzino) { token="_"+idMagazzino; if(idMagazzino==null||idMagazzino==''){ idMagazzino=-1; token=""; } //prima controllo che i dati inseriti siano consistenti: realjq=recuperaJquery($); if(realjq==null) realjq=recuperaJquery(Jq); fly=false; if(idArticolo!=null){ var qta=1; if(qta!=null&&parseInt(qta,10)){ // campo hidden che contiene il numero di pezzi che posso ancora mettere nel carrello. -1 se il controllo è disabilitato var qtaCheckEl=realjq('input[name="qta_chk_'+idArticolo+token+'"]'); var qtaCheck = -1; var qtaRes = -1; // qtaCheck se è <>-1 mi indica quanti pezzi posso mettere nel carrello if(qtaCheckEl!=null&&!isNaN(qtaCheckEl.val())){ qtaCheck = parseInt(qtaCheckEl.val()); if(qtaCheck>=0){ if(qtaCheck==0){ // quantità residua di magazzino = 0 alert(msgAlertQta); return; }else if(qta>qtaCheck){ // quantità desiderata > di quella residua: chiedo conferma if(!confirm(msgConfirmQta.replace('#qtaCheck#',''+qtaCheck))){ return; } qta = qtaCheck; qtaRes = qtaCheck - qta; // aggiorno la quantità residua }else{ // tutto ok qtaRes = qtaCheck - qta; // aggiorno la quantità residua } }else{ //alert('Non controllo'); } } realjq('img[name="addButton_'+idArticolo+token+'"]').hide(); realjq('button[name="addButton_'+idArticolo+token+'"]').hide(); try{realjq('#div_box_qta_'+idArticolo+token).hide();}catch(err){} realjq('#attesa_'+idArticolo+token).show(); var qs='id='+idArticolo+'&qta='+qta+'&idM='+idMagazzino; realjq.ajax ({ type: "POST", url: "/AddProdottoCarrello.do", data: qs, dataType: "xml", cache: false, success: function(xml) { if(xml!=null){ realjqxml = realjq( xml ); esito = realjqxml.find( "esito" ); esito = realjq( esito ).text(); if(esito!=null&&esito==1){ // usare sempre #carrello_refresh if(realjq('#carrello_refresh').length>0||realjq('.carrello_refresh').length>0) { realjq.ajax({ type: "POST", url: "/carrello/carrelloMini.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html){ realjq('#carrello_refresh').html(html); realjq('.carrello_refresh').each(function () { $(this).html(html); }); qtaCheckEl.val(qtaRes); } }); } if(realjq('.carrello_refresh_mobile').length>0) { realjq.ajax ({ type: "POST", url: "/carrello/carrelloMini.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('.carrello_refresh_mobile').html(html); qtaCheckEl.val(qtaRes); } }); } if(realjq('#carrello_mini_refresh').length>0) { realjq.ajax ({ type: "POST", url: "/include/responsive/carrello/carrelloMini.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_mini_refresh').html(html); qtaCheckEl.val(qtaRes); } }); } if(realjq('#carrello_mini_noprodotti_refresh').length>0) { realjq.ajax ({ type: "POST", url: "/include/responsive/carrello/carrelloMiniNoProdotti.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_mini_noprodotti_refresh').html(html); qtaCheckEl.val(qtaRes); } }); } if(realjq('#carrello_mini_elegance_refresh').length>0) { realjq.ajax ({ type: "POST", url: "/include/responsive/carrello/carrelloMiniElegance.jsp", data: qs, cache: false, contentType: "text/plain; charset=utf-8", success: function(html) { realjq('#carrello_mini_elegance_refresh').html(html); qtaCheckEl.val(qtaRes); } }); } totaleCarrelloOp = realjqxml.find( "totaleCarrello" ).text(); numeroArticoli = realjqxml.find( "numeroArticoli" ).text(); prodottiAggiunti = realjqxml.find( "prodottiAggiunti" ).text(); totaleSeparato = realjqxml.find( "totaleSeparato" ).text(); nome = realjqxml.find( "nome" ).text(); try{ //if(prodottiAggiunti!=null&&parseInt(prodottiAggiunti,10)<=1){ //} if(numeroArticoli!=null&&parseInt(numeroArticoli,10)<=1){ realjq('#card_articolo').show(); realjq('#card_articoli').hide(); }else{ realjq('#card_articoli').show(); realjq('#card_articolo').hide(); } }catch(err){} //realjq('#'+id_div_contenuto).html(contenutoDiv); realjq('#num_prod_carrello').html(numeroArticoli); realjq('#tot_carrello').html("€ "+totaleCarrelloOp); realjq('#nome_prodotto').html(nome); realjq('#prod_aggiunti').html(prodottiAggiunti); if(totaleSeparato!=null&&totaleSeparato!=""){ realjq('#tot_carrello_separato').html("€ "+totaleSeparato); realjq("#span_separato").show(); }else{ realjq("#span_separato").hide(); } /* var moveLeft = 30; var moveDown = 15; pos = realjq("#"+img).offset(); posTab = realjq("#tabProdPosition").offset(); width = realjq("#"+img).width(); //show the menu directly over the placeholder */ if(tempoChiusura!=null && parseInt(tempoChiusura)>0){ if(realjq('#'+id_blocco).length>0) { resetTimer(id_blocco); openDiv(tempoChiusura,id_blocco,fade); /* realjq('#'+id_blocco).fadeOut(fade,function(){ // realjq('#'+id_blocco).css({ "left": ((pos.left + width +moveLeft)-posTab.left) + "px", "top":(pos.top-posTab.top +moveDown) + "px" }) openDiv(timeFade,id_blocco,fade); //ripristinaTasto(idArticolo); }); */ ripristinaTasto(idArticolo,token); //realjq('#'+id_blocco).delay(5000).fadeOut(fade); }else{ //realjq('#'+id_blocco).fadeIn(fade).delay(5000).fadeOut(fade); //realjq('#'+id_blocco).css({ "left": ((pos.left + width +moveLeft)-posTab.left) + "px", "top":(pos.top-posTab.top +moveDown) + "px" }) openDiv(tempoChiusura,id_blocco,fade) ripristinaTasto(idArticolo,token); } }else{ openDiv(tempoChiusura,id_blocco,fade) realjq('#overlay_carrello').show(); ripristinaTasto(idArticolo,token); } }else{ ripristinaTasto(idArticolo,token); erroreAlert = realjqxml.find( "erroreAlert" ); erroreInserimentoProdotto(id_div_contenuto,erroreAlert); } }else{ ripristinaTasto(); erroreInserimentoProdotto(id_div_contenuto,"Impossibile aggiungere il prodotto nel carrello") } } }); //FINE PRIMA CHIAMATA AJAX //}); if(fly){ productIDVal = idArticolo; var productX = realjq("#immagineArticolo_" + productIDVal).offset().left; //l'immagine var productY = realjq("#immagineArticolo_" + productIDVal).offset().top; //l'immagine var basketX = realjq("#dettaglioCarrelloMini").offset().left;//riga nel carrello relativa al prodotto var basketY = realjq("#dettaglioCarrelloMini").offset().top; var gotoX = basketX - productX; var gotoY = basketY - productY; var newImageWidth = realjq("#immagineArticolo_" + productIDVal).width() / 3; var newImageHeight = realjq("#immagineArticolo_" + productIDVal).height() / 3; realjq("#immagineArticolo_" + productIDVal + " > a > img") .clone() .prependTo("#immagineArticolo_" + productIDVal) .css({'position' : 'absolute'}) .animate({opacity: 0.4}, 100 ) .animate({opacity: 0.1, marginLeft: gotoX, marginTop: gotoY, width: newImageWidth, height: newImageHeight}, 1200); } }else{ alert('Inserire la quantita\' del prodotto'); } } return false; } //TODO: modificare $("#alertProdottiInRaggruppamentoConAvviso").click(function() { $("#gtm-startCheckout-desktop").attr("disabled", !this.checked); });