2013-09-16 13:55:17 +00:00
|
|
|
jQuery(document).ready(function(e){function i(){r&&r.abort();var t=[];e("select#shipping_method, input[name^=shipping_method][type=radio]:checked, input[name^=shipping_method][type=hidden]").each(function(n,r){t[e(this).data("index")]=e(this).val()});var n=e("#order_review input[name=payment_method]:checked").val(),i=e("#billing_country").val(),s=e("#billing_state").val(),o=e("input#billing_postcode").val(),u=e("input#billing_city").val(),a=e("input#billing_address_1").val(),f=e("input#billing_address_2").val();if(e("#ship-to-different-address input").is(":checked")||e("#ship-to-different-address input").size()==0)var l=e("#shipping_country").val(),c=e("#shipping_state").val(),h=e("input#shipping_postcode").val(),p=e("input#shipping_city").val(),d=e("input#shipping_address_1").val(),v=e("input#shipping_address_2").val();else var l=i,c=s,h=o,p=u,d=a,v=f;e("#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 m={action:"woocommerce_update_order_review",security:wc_checkout_params.update_order_review_nonce,shipping_method:t,payment_method:n,country:i,state:s,postcode:o,city:u,address:a,address_2:f,s_country:l,s_state:c,s_postcode:h,s_city:p,s_address:d,s_address_2:v,post_data:e("form.checkout").serialize()};r=e.ajax({type:"POST",url:wc_checkout_params.ajax_url,data:m,success:function(t){if(t){var n=e(t);e("#order_review").html(n.html());e("body").trigger("updated_checkout")}}})}function s(){var t=!0;if(e(n).size()){$required_siblings=e(n).closest(".form-row").siblings(".address-field.validate-required");$required_siblings.size()&&$required_siblings.each(function(){if(e(this).find("input.input-text").val()==""||e(this).find("input.input-text").val()=="undefined")t=!1})}if(t){n=!1;e("body").trigger("update_checkout")}}var t,n=!1,r;e("body").bind("update_checkout",function(){clearTimeout(t);i()});e("p.password, form.login, .checkout_coupon, div.shipping_address").hide();e("input.show_password").change(function(){e("p.password").slideToggle()});e("a.showlogin").click(function(){e("form.login").slideToggle();return!1});e("a.showcoupon").click(function(){e(".checkout_coupon").slideToggle(400,function(){e("#coupon_code").focus()});return!1});e("#ship-to-different-address input").change(function(){e("div.shipping_address").hide();e(this).is(":checked")&&e("div.shipping_address").slideDown()}).change();if(wc_checkout_params.option_guest_checkout=="yes"){e("div.create-account").hide();e("input#createaccount").change(function(){e("div.create-account").hide();e(this).is(":checked")&&e("div.create-account").slideDown()}).change()}e("#order_review").on("click",".payment_methods input.input-radio",function(){if(e(".payment_methods input.input-radio").length>1){e("div.payment_box").filter(":visible").slideUp(250);e(this).is(":checked")&&e("div.payment_box."+e(this).attr("ID")).slideDown(250)}else e("div.payment_box").show()}).find("input[name=payment_method]:checked").click();e("form.checkout").on("input change","select#shipping_method, input[name^=shipping_method], #ship-to-different-address input, .update_totals_on_change select",function(){clearTimeout(t);n=!1;e("body").trigger("update_checkout")}).on("input change",".address-field input.input-text, .update_totals_on_change input.input-text",function(){n&&s()}).on("input change",".address-field select",function(){n=this;s()}).on("keydown",".address-field input.input-text, .update_totals_on_change input.input-text",function(e){var r=e.keyCode||e.which;if(r=="9")return;n=this;clearTimeout(t);t=setTimeout(s,"1000")}).on("blur input change",".input-text, select",function(){var t=e(this),n=t.closest(".form-row"),r=!0;if(n.is(".validate-required")&&t.val()==""){n.removeClass("woocommerce-validated").addClass("woocommerce-invalid woocommerce-invalid-required-field");r=!1}if(n.is(".validate-email")&&t.val()){var i=new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-
|