2019-03-20 20:08:52 +00:00
|
|
|
jQuery(function(g){if("undefined"==typeof wc_checkout_params)return!1;var v={updateTimer:!(g.blockUI.defaults.overlayCSS.cursor="default"),dirtyInput:!1,selectedPaymentMethod:!1,xhr:!1,$order_review:g("#order_review"),$checkout_form:g("form.checkout"),init:function(){g(document.body).bind("update_checkout",this.update_checkout),g(document.body).bind("init_checkout",this.init_checkout),this.$checkout_form.on("click",'input[name="payment_method"]',this.payment_method_selected),g(document.body).hasClass("woocommerce-order-pay")&&(this.$order_review.on("click",'input[name="payment_method"]',this.payment_method_selected),this.$order_review.on("submit",this.submitOrder),this.$order_review.attr("novalidate","novalidate")),this.$checkout_form.attr("novalidate","novalidate"),this.$checkout_form.on("submit",this.submit),this.$checkout_form.on("input validate change",".input-text, select, input:checkbox",this.validate_field),this.$checkout_form.on("update",this.trigger_update_checkout),this.$checkout_form.on("change",'select.shipping_method, input[name^="shipping_method"], #ship-to-different-address input, .update_totals_on_change select, .update_totals_on_change input[type="radio"], .update_totals_on_change input[type="checkbox"]',this.trigger_update_checkout),this.$checkout_form.on("change",".address-field select",this.input_changed),this.$checkout_form.on("change",".address-field input.input-text, .update_totals_on_change input.input-text",this.maybe_input_changed),this.$checkout_form.on("keydown",".address-field input.input-text, .update_totals_on_change input.input-text",this.queue_update_checkout),this.$checkout_form.on("change","#ship-to-different-address input",this.ship_to_different_address),this.$checkout_form.find("#ship-to-different-address input").change(),this.init_payment_methods(),"1"===wc_checkout_params.is_checkout&&g(document.body).trigger("init_checkout"),"yes"===wc_checkout_params.option_guest_checkout&&g("input#createaccount").change(this.toggle_create_account).change()},init_payment_methods:function(){var e=g(".woocommerce-checkout").find('input[name="payment_method"]');1===e.length&&e.eq(0).hide(),v.selectedPaymentMethod&&g("#"+v.selectedPaymentMethod).prop("checked",!0),0===e.filter(":checked").length&&e.eq(0).prop("checked",!0);var t=e.filter(":checked").eq(0).prop("id");1<e.length&&g('div.payment_box:not(".'+t+'")').filter(":visible").slideUp(0),e.filter(":checked").eq(0).trigger("click")},get_payment_method:function(){return v.$checkout_form.find('input[name="payment_method"]:checked').val()},payment_method_selected:function(e){if(e.stopPropagation(),1<g(".payment_methods input.input-radio").length){var t=g("div.payment_box."+g(this).attr("ID")),o=g(this).is(":checked");o&&!t.is(":visible")&&(g("div.payment_box").filter(":visible").slideUp(230),o&&t.slideDown(230))}else g("div.payment_box").show();g(this).data("order_button_text")?g("#place_order").text(g(this).data("order_button_text")):g("#place_order").text(g("#place_order").data("value"));var c=g('.woocommerce-checkout input[name="payment_method"]:checked').attr("id");c!==v.selectedPaymentMethod&&g(document.body).trigger("payment_method_selected"),v.selectedPaymentMethod=c},toggle_create_account:function(){g("div.create-account").hide(),g(this).is(":checked")&&(g("#account_password").val("").change(),g("div.create-account").slideDown())},init_checkout:function(){g(document.body).trigger("update_checkout")},maybe_input_changed:function(e){v.dirtyInput&&v.input_changed(e)},input_changed:function(e){v.dirtyInput=e.target,v.maybe_update_checkout()},queue_update_checkout:function(e){if(9===(e.keyCode||e.which||0))return!0;v.dirtyInput=this,v.reset_update_checkout_timer(),v.updateTimer=setTimeout(v.maybe_update_checkout,"1000")},trigger_update_checkout:function(){v.reset_update_checkout_timer(),v.dirtyInput=!1,g(document.body).trigger("update_checkout")},maybe_update_checkout:function(){var e=!0;if(g(v.dirtyInput).length){var t=g(v.dirtyInput).closest("div").find(".address-field.validate-required");t.length&&t.each(function(){""===g(this).find("input.inpu
|