woocommerce/assets/js/frontend/checkout.min.js

1 line
7.3 KiB
JavaScript
Raw Normal View History

2014-02-03 14:35:26 +00:00
jQuery(function(a){function b(){e&&e.abort();var b=[];a("select.shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]").each(function(){b[a(this).data("index")]=a(this).val()});var c=a("#order_review input[name=payment_method]:checked").val(),d=a("#billing_country").val(),f=a("#billing_state").val(),g=a("input#billing_postcode").val(),h=a("input#billing_city").val(),i=a("input#billing_address_1").val(),j=a("input#billing_address_2").val();if(a("#ship-to-different-address input").is(":checked")||0==a("#ship-to-different-address input").size())var k=a("#shipping_country").val(),l=a("#shipping_state").val(),m=a("input#shipping_postcode").val(),n=a("input#shipping_city").val(),o=a("input#shipping_address_1").val(),p=a("input#shipping_address_2").val();else var k=d,l=f,m=g,n=h,o=i,p=j;a("#order_methods, #order_review").block({message:null,overlayCSS:{background:"#fff url("+wc_checkout_params.ajax_loader_url+") no-repeat center",backgroundSize:"16px 16px",opacity:.6}});var q={action:"woocommerce_update_order_review",security:wc_checkout_params.update_order_review_nonce,shipping_method:b,payment_method:c,country:d,state:f,postcode:g,city:h,address:i,address_2:j,s_country:k,s_state:l,s_postcode:m,s_city:n,s_address:o,s_address_2:p,post_data:a("form.checkout").serialize()};e=a.ajax({type:"POST",url:wc_checkout_params.ajax_url,data:q,success:function(b){if(b){var c=a(b);a("#order_review").html(c.html()),a("body").trigger("updated_checkout")}}})}function c(){var b=!0;a(f).size()&&($required_siblings=a(f).closest(".form-row").siblings(".address-field.validate-required"),$required_siblings.size()&&$required_siblings.each(function(){(""==a(this).find("input.input-text").val()||"undefined"==a(this).find("input.input-text").val())&&(b=!1)})),b&&(f=!1,a("body").trigger("update_checkout"))}if("undefined"==typeof wc_checkout_params)return!1;var d,e,f=!1;a("body").bind("update_checkout",function(){clearTimeout(d),b()}),a("p.password, form.login, .checkout_coupon, div.shipping_address").hide(),a("input.show_password").change(function(){a("p.password").slideToggle()}),a("a.showlogin").click(function(){return a("form.login").slideToggle(),!1}),a("a.showcoupon").click(function(){return a(".checkout_coupon").slideToggle(400,function(){a("#coupon_code").focus()}),!1}),a("#ship-to-different-address input").change(function(){a("div.shipping_address").hide(),a(this).is(":checked")&&a("div.shipping_address").slideDown()}).change(),"yes"==wc_checkout_params.option_guest_checkout&&(a("div.create-account").hide(),a("input#createaccount").change(function(){a("div.create-account").hide(),a(this).is(":checked")&&a("div.create-account").slideDown()}).change()),a("#order_review").on("click",".payment_methods input.input-radio",function(){if(a(".payment_methods input.input-radio").length>1){var b=a("div.payment_box."+a(this).attr("ID"));a(this).is(":checked")&&!b.is(":visible")&&(a("div.payment_box").filter(":visible").slideUp(250),a(this).is(":checked")&&a("div.payment_box."+a(this).attr("ID")).slideDown(250))}else a("div.payment_box").show();a("#place_order").val(a(this).data("order_button_text")?a(this).data("order_button_text"):a("#place_order").data("value"))}).find("input[name=payment_method]:checked").click(),a("form.checkout").on("input change","select.shipping_method, input[name^=shipping_method], #ship-to-different-address input, .update_totals_on_change select",function(){clearTimeout(d),f=!1,a("body").trigger("update_checkout")}).on("input change",".address-field input.input-text, .update_totals_on_change input.input-text",function(){f&&c()}).on("input change",".address-field select",function(){f=this,c()}).on("keydown",".address-field input.input-text, .update_totals_on_change input.input-text",function(a){var b=a.keyCode||a.which;"9"!=b&&(f=this,clearTimeout(d),d=setTimeout(c,"1000"))}).on("blur input change",".input-text, select",function(){var b=a(this),c=b.closest(".form-row"),d=!0;if(c.is(".validate-required")&&""==b.val()&&(c.removeClass("woocommerce-validated").addClass("woocommerce-i