$(function(){ jQuery('.fancyCotizar').fancybox({ type: 'iframe', scrollOutside: false }); $('.carouselImage').slick({ slidesToShow : 1, slidesToScroll: 1, arrows : true, speed : 500, fade : true, prevArrow : '', nextArrow : '', fade : true, asNavFor : '.carouselNav', }).load(function(){ console.log("cargado") ; }); $('.carouselNav').slick({ asNavFor : '.carouselImage', infinite : false, arrows : false, speed : 300, slidesToShow : 4, centerPadding : '100px', slidesToScroll : 4, focusOnSelect : true, responsive: [ { breakpoint: 1024, settings: { slidesToShow : 3, slidesToScroll : 3, infinite : true, dots : true } }, { breakpoint: 600, settings: { slidesToShow : 2, slidesToScroll : 2 } }, { breakpoint: 480, settings: { slidesToShow : 3, slidesToScroll : 1 } } ] }); }); $(".agregar_producto_nuevo").unbind().click(function(e){ e.preventDefault(); var producto_id = $(this).data("producto_id"); var cantidad = $("#cantidad_producto").val(); if($(this).data("cantidad") == 1) { var cantidad = 1; } if(cantidad < 1) { alert("La cantidad no puede ser menor a 0"); return false; } if($(this).data("cantidad") != 1) { if($("#medida_id").attr("id") == "medida_id") { producto_id = $("#medida_id").val(); } } $.post($("body").data("url"),{"_ajax_": "addProductoCarrito","producto_id" : producto_id , "cantidad": cantidad},function(json){ console.log(json) $("#carrito_productos").html(base64_decode(json.html)); $("#cabecera_carro").html(base64_decode(json.cabecera_carro)); $("#valores_referencia").html(base64_decode(json.referencias)); $("#cabecera_carro").click(); },"json"); }); $("#login-form").unbind().submit(function(e){ e.preventDefault(); var form = $( this ); if($.trim(form.find("[name='crm_contacto[nombre]']").val()) == "") { alert("Debe ingresar su nombre"); form.find("[name='crm_contacto[nombre]']").focus(); return false; } if($.trim(form.find("[name='crm_contacto[email]']").val()) == "") { alert("Debe ingresar su email"); form.find("[name='crm_contacto[email]']").focus(); return false; } form.find("[name='crm_contacto[email]']").val( form.find("[name='crm_contacto[email]']").val().toLowerCase() ); if(!/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.([a-z]){2,4})$/.test( form.find("[name='crm_contacto[email]']").val() )) { alert("Debe ingresar un correo válido"); form.find("[name='contacto[cc_contacto][email]']").focus(); return false; } $.ajax({ url: '/?_ajax_=saveCotizacion', data: $("#login-form").serializeArray(), }) .done(function() { console.log("success"); alert("Su cotización fue almacenada exitosamente pronto nos pondremos en contacto con usted"); $("#modal-login-form").modal('hide'); $("#login-form")[0].reset(); }) .fail(function() { console.log("error"); }) .always(function() { console.log("complete"); }); return false; });