$(function () { $('.cart-sidebar-toggle').click(function (event) { getcartsidebar(); }); $(".overly-mask, .cart-close-trigger").live('click',function (event) { // $('.overly-mask').toggleClass('is-visible'); $('.cart-sidebar').toggleClass('is-visible') $('.cart-sidebar-toggle').toggleClass('active'); $('.cartMenu ').toggleClass('open'); //$('body').toggleClass('modal-open'); $('.cart-sidebar').toggleClass('hasTopBar'); }); $('.privacyok').on('ifChecked', function(event){ var form = $(this).closest('form')[0]; form = form.id; $('#'+form+' .privacyokctrl').val('si'); }); $('.privacyok').on('ifUnchecked', function(event){ var form = $(this).closest('form')[0]; form = form.id; $('#'+form+' .privacyokctrl').val(''); }); $('.testimonials .product').on('click',function(){ var id = $(this).data('index'); $('#myCarousel').carousel('pause'); $('#myCarousel').carousel(id); $('.testimonials img').removeClass('faded-active').addClass('faded'); $('img',this).removeClass('faded').addClass('faded-active'); }); }); function addtocart(idp, qta) { var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'act': 'addproduct', 'id': idp, 'qta': qta, 'prjecommuserlogin': '', 'prjecommorderid': '' } $.get("/shop/_apps/post.inc.html", data, function(result){ var resultsplit = result.split('|'); if(resultsplit[3] == 'notopencart') { showalertmsg(result); } else { if(result != null && result != '') { showalertmsg(result); } getcartsidebar(); $('.li-cart-wrap').css('display','block'); } }); } function deletetocart(idp) { var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'act': 'deleteproduct', 'id': idp } $.post("/shop/_apps/post.inc.html", data, function(result){ if(result != 'reloadpage') { getcartsidebar(); } else { document.location.href = '/ricette/pomodori-ripieni'; } }); } function deletecart() { var data = { 'act': 'deletecart' } $.post("/shop/_apps/post.inc.html", data, function(result){ if(result === 'deleted') { document.location.href = '//catalogo'; } }); } function confirmbox(msg) { bootbox.confirm({ size: 'small', message: msg, callback: function(result) { if (result == false) { return false; } else { getcoupon($('#couponcode').val()); } } }); } function getcoupon(coupon) { if(coupon != '' && coupon != undefined) { var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'pageflag':'228', 'act': 'getcoupon', 'coupon': coupon } $.post("/shop/_apps/post.inc.html", data, function(result){ var resultsplit = result.split('|'); if(resultsplit[3] == 'false') { showalertmsg(result); } getcartcheckout(); }); } } function getcartsidebar() { var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'pageflag':'228', 'act': 'getcartsidebar' } $.post("/shop/_apps/post.inc.html", data, function(result){ $('.cart-sidebar-content').html(result); $('.cart-sidebar-content').addClass('active'); //$('.overly-mask').addClass('is-visible'); $('.cart-sidebar').addClass('is-visible'); $('.cartMenu ').addClass('open'); //$('body').addClass('modal-open'); $(".scroll-pane").mCustomScrollbar(); }); } function getcart() { var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'pageflag':'228', 'act': 'getcart' } $.post("/shop/_apps/post.inc.html", data, function(result){ $('#cartwrap').html(result); }); } function getcartcheckout() { var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'pageflag':'228', 'act': 'getcartcheckout' } $.post("/shop/_apps/post.inc.html", data, function(result){ $('#cartwrap').html(result); }); } function refreshcart() { var data = { 'reloadcart': '1', 'brand':'250' } $.post("/shop/_apps/post.inc.html", data, function(result){ }); } function reloadqta(id,updown) { var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'act': 'updateqta', 'id': id, 'qta': updown } $.post("/shop/_apps/post.inc.html", data, function(result){ getcart(); }); } function savesellerupdates() { $('#formordercheckout input.savesellerupdates').each(function(){ var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'act': 'savesellerupdates', 'id': $(this).data('idproduct'), 'value': $(this).val(), 'field': $(this).data('field') } $.post("/shop/_apps/post.inc.html", data, function(result){ }); }); getcartcheckout(); } $(function(){ $(document).on('mouseover', ".swatches li", function () { $(this).css('opacity',1); $('#colortext').html($(this).data('colortxt')); }); $(document).on('mouseover', ".sizes li", function () { $(this).css('opacity',1); }); $(document).on('mouseleave', ".swatches li.opacity05", function () { $(this).css('opacity',0.5); }); $(document).on('mouseleave', ".sizes li.opacity05", function () { $(this).css('opacity',0.5); }); $(document).on('click', ".swatches li", function () { $(".swatches li.selected").removeClass("selected"); $(this).addClass('selected'); var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'pageflag':'228', 'act': 'variants', 'idparent': $(this).data('idp'), 'idcolor': $(this).data('idcolor'), 'idsize': $('ul.sizes li.selected').data('idsize') } console.log(data); $.post("/shop/_apps/post.inc.html", data, function(result){ $('.selection').html(result); }); }); $(document).on('click', ".sizes li", function () { $(".sizes li.selected").removeClass("selected"); $(this).addClass('selected'); var data = { 'sys_lang':'1', 'lng':'', 'brand':'250', 'pageflag':'228', 'act': 'variants', 'idparent': $(this).data('idp'), 'idcolor': $('ul.swatches li.selected').data('idcolor'), 'idsize': $(this).data('idsize') } $.post("/shop/_apps/post.inc.html", data, function(result){ $('.selection').html(result); }); }); var formregistrazionemodal = $("#formregistrazionemodal").validate({ // Rules for form validation rules: { nome: { required: true }, cognome: { required: true }, email: { required: true, email: true }, password: { required: true }, privacyokctrl: { required: true } }, // Messages for form validation messages: { nome: { required: '' }, cognome: { required: '' }, telefono: { required: '' }, email: { required: '', email: '' }, password: { required: '' }, privacyokctrl: { required: '' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#formregistrazionemodal button' ) ); l.start(); var data = $("#formregistrazionemodal").serialize(); $.post('/shop/_apps/post.inc.html', data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { $('#formregistrazionemodal')[0].reset(); refreshcart(); $('#ModalSignup').modal('hide'); document.location.href = '/ricette/pomodori-ripieni'; } l.stop(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var formregistrazione = $("#formregistrazione").validate({ /* // Rules for form validation rules: { nome: { required: true }, cognome: { required: true }, indirizzo: { required: true }, citta: { required: true }, cap: { required: true }, provincia: { required: true }, email: { required: true, email: true }, password: { required: true }, privacyokctrl: { required: true } }, // Messages for form validation messages: { nome: { required: '' }, cognome: { required: '' }, indirizzo: { required: '' }, citta: { required: '' }, cap: { required: '' }, provincia: { required: '' }, email: { required: '', email: '' }, password: { required: '' }, privacyokctrl: { required: '' } }, */ // Ajax form submition submitHandler: function(form) { var formid = 'formregistrazione'; //if(checkVATCF($("#" + formid + " [name='cf']").val(), formid)) //{ //if($("#" + formid + " [name='piva']").val() == '' || ($("#" + formid + " [name='piva']").val() != '' && checkVATCF($("#" + formid + " [name='piva']").val(), formid))) //{ var l = Ladda.create( document.querySelector( '#formregistrazione button' ) ); l.start(); var data = $("#formregistrazione").serialize(); $.post('/shop/_apps/post.inc.html', data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { $('#formregistrazione')[0].reset(); refreshcart(); document.location.href = '//registrazione-utente'; } if(resultsplit[3] == 'yestrue') { setTimeout(function(){document.location.href = '//' + resultsplit[4];}, 1200); } l.stop(); }); //} //} }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var formregistrazione = $("#companyregform").validate({ // Ajax form submition submitHandler: function(form) { var formid = 'companyregform'; //if(checkVATCF($("#" + formid + " [name='cf']").val(), formid)) //{ //if($("#" + formid + " [name='piva']").val() == '' || ($("#" + formid + " [name='piva']").val() != '' && checkVATCF($("#" + formid + " [name='piva']").val(), formid))) //{ var l = Ladda.create( document.querySelector( '#companyregform button' ) ); l.start(); var data = $("#companyregform").serialize(); $.post('/shop/_apps/post.inc.html', data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { $('#companyregform')[0].reset(); refreshcart(); document.location.href = '//registrazione-utente'; } if(resultsplit[3] == 'yestrue') { setTimeout(function(){document.location.href = '//' + resultsplit[4];}, 1200); } l.stop(); }); //} //} }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var formlogin = $("#formlogin").validate({ // Rules for form validation rules: { username: { required: true }, password: { required: true } }, // Messages for form validation messages: { username: { required: '' }, password: { required: '' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#formlogin button' ) ); l.start(); var data = $("#formlogin").serialize(); $.post('/shop/_apps/post.inc.html', data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { $('#formlogin')[0].reset(); refreshcart(); document.location.href = '/ricette/pomodori-ripieni'; $('#ModalLogin').modal('hide'); } l.stop(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var formlogincheckoutseller = $("#formlogincheckoutseller").validate({ // Rules for form validation rules: { username: { required: true }, password: { required: true } }, // Messages for form validation messages: { username: { required: '' }, password: { required: '' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#formlogincheckoutseller button' ) ); l.start(); var data = $("#formlogincheckoutseller").serialize(); $.post('/shop/_apps/post.inc.html', data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { refreshcart(); document.location.href = '/ricette/pomodori-ripieni'; } l.stop(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var formlogincheckout = $("#formlogincheckout").validate({ // Rules for form validation rules: { username: { required: true }, password: { required: true } }, // Messages for form validation messages: { username: { required: '' }, password: { required: '' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create( document.querySelector( '#formlogincheckout button' ) ); l.start(); var data = $("#formlogincheckout").serialize(); $.post('/shop/_apps/post.inc.html', data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { $('#formlogincheckout')[0].reset(); refreshcart(); document.location.href = '/ricette/pomodori-ripieni'; $('#ModalLogin').modal('hide'); } if(resultsplit[3] == 'yestrue') { $('#formlogin')[0].reset(); // document.location.href = '/' + resultsplit[4]; setTimeout(function(){document.location.href = '//' + resultsplit[4];}, 1200); } l.stop(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var formregistrazione = $("#formedituser").validate({ // Rules for form validation /* rules: { nome: { required: true }, cognome: { required: true }, telefono: { required: true }, giorno: { required: true }, mese: { required: true }, anno: { required: true }, cf: { required: true }, indirizzo: { required: true }, citta: { required: true }, cap: { required: true }, provincia: { required: true }, email: { required: true, email: true }, nome_sped: { required: true }, cognome_sped: { required: true }, indirizzo_sped: { required: true }, citta_sped: { required: true }, cap_sped: { required: true }, provincia_sped: { required: true }, telefono_sped: { required: true } }, // Messages for form validation messages: { nome: { required: '' }, cognome: { required: '' }, telefono: { required: '' }, giorno: { required: '' }, mese: { required: '' }, anno: { required: '' }, cf: { required: '' }, indirizzo: { required: '' }, citta: { required: '' }, cap: { required: '' }, provincia: { required: '' }, email: { required: '', email: '' }, nome_sped: { required: '' }, cognome_sped: { required: '' }, indirizzo_sped: { required: '' }, citta_sped: { required: '' }, cap_sped: { required: '' }, provincia_sped: { required: '' }, telefono_sped: { required: '' } }, */ // Ajax form submition submitHandler: function(form) { var formid = 'formedituser'; //if(checkVATCF($("[name='cf']").val(), formid)) //{ //if($("[name='piva']").val() == '' || ($("[name='piva']").val() != '' && checkVATCF($("[name='piva']").val(), formid))) //{ var l = Ladda.create( document.querySelector( '#formedituser button' ) ); l.start(); var data = $("#formedituser").serialize(); $.post('/shop/_apps/post.inc.html', data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { refreshcart(); document.location.href = '//modalita-pagamento'; } if(resultsplit[3] == 'yestrue') { setTimeout(function(){document.location.href = '//' + resultsplit[4];}, 1200); } l.stop(); }); //} //} }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var formmodalitapagamento = $("#formmodalitapagamento").validate({ // Rules for form validation rules: { modalitapagamento: { required: true } }, // Messages for form validation messages: { modalitapagamento: { required: '' } }, // Ajax form submition submitHandler: function(form) { var l = Ladda.create(document.querySelector( '#formmodalitapagamento button' )); l.start(); var data = $("#formmodalitapagamento").serialize(); $.post('/shop/_apps/post.inc.html', data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { refreshcart(); document.location.href = '//riepilogo-ordine'; } l.stop(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var contactusform = $("#contactus").validate({ // Rules for form validation rules: { act: { required: true } }, // Messages for form validation messages: { act: { required: '' } }, // Ajax form submition submitHandler: function(form) { var data = $("#contactus").serialize(); $.post("/shop/_apps/post.inc.html", data, function(result) { showalertmsg(result); $('#contactus')[0].reset(); }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); var loginrecoveryform = $("#loginrecoveryform").validate({ // Rules for form validation rules: { username: { required: true } }, // Messages for form validation messages: { username: { required: '' } }, // Ajax form submition submitHandler: function(form) { var data = $("#loginrecoveryform").serialize(); $.post("/shop/_apps/post.inc.html", data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { $('#loginrecovery').modal('hide'); $('#loginrecoveryform')[0].reset(); } }); }, // Do not change code below errorPlacement: function(error, element) { error.insertAfter(element.parent()); } }); }); function closeChat(id) { $.cookie('closechat', id); var url = "/shop/_apps/post.inc.html"; var data = { 'act':'closechat', 'id':'' } $.ajax({ type: "POST", url: url, data: data, dataType: 'html' }); } function getmodalchat() { if($.cookie('closechat') != '') { var url = "/shop/_apps/post.inc.html"; if(!$('#chatmodal-').length) { var data = { 'act':'getmodalchat', 'id':'', 'brand':'250' } $.ajax({ type: "POST", url: url, data: data, success: function(data){ $('body').append(data); $(document).ready(function () { $('#chatmodal-').modal('show'); $('#chatmodal-').on('shown.bs.modal', function() { var nicescroll3 = $('.modal-body').niceScroll({ cursorcolor:"#000", cursorwidth:"10px" }); refreshNiceScroll(); // $('#chatmodal-' + ' textarea').focus(); // $("body").removeClass("modal-open"); }); }); refreshNiceScroll(); }, dataType: 'html' }); } else { var data = { 'act':'getmodalchat', 'id':'', 'brand':'250', 'reloadmsg':1 } $.ajax({ type: "POST", url: url, data: data, success: function(data){ $('#chatmodal-' + ' .timeline').html(data); $(document).ready(function () { $('#chatmodal-').modal('show'); $('#chatmodal-').on('shown.bs.modal', function() { var nicescroll3 = $('.modal-body').niceScroll({ cursorcolor:"#000", cursorwidth:"10px" }); refreshNiceScroll(); // $('#chatmodal-' + ' textarea').focus(); // $("body").removeClass("modal-open"); }); refreshNiceScroll(); }); }, dataType: 'html' }); } } } function addmsg(msg,id) { var url = "/shop/_apps/post.inc.html"; var data = { 'act':'addmsgchat', 'id':'', 'brand':'250', 'messaggio':msg } $.ajax({ type: "POST", url: url, data: data, success: function(data){ $('#chatmodal- .timeline').append(data); refreshNiceScroll(); }, dataType: 'html' }); } function passwgenerate(pwd, uid) { var data = { 'act':'passwgenerate', 'password': pwd, 'u': uid }; $.post("/shop/_apps/post.inc.html", data, function(result) { showalertmsg(result); var resultsplit = result.split('|'); if(resultsplit[3] == 'true') { $('#register').hide(500); $('#registerbutton').hide(500); $('#donemsg').show(500); setTimeout(function(){$('#ModalLogin').modal('show');}, 2000); } }); } function refreshNiceScroll(){ if($('.modal-body').length) { $('.modal-body').getNiceScroll().resize(); if ($('.timeline').length) $('.modal-body').scrollTop(($('.timeline').get(0).scrollHeight+300), -1); } }