woocommerce/assets/js/admin/meta-boxes-order.min.js

1 line
23 KiB
JavaScript
Raw Normal View History

2014-07-10 13:49:04 +00:00
jQuery(function(a){jQuery("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),a("a.edit_address").click(function(b){a(this).hide(),a(this).closest(".order_data_column").find("div.address").hide(),a(this).closest(".order_data_column").find("div.edit_address").show(),b.preventDefault()}),a("#order_items_list tr.item, #order_items_list tr.fee").each(function(){a(this).trigger("init_row"),a(this).find(".edit").hide()}),a("#order_items_list").on("init_row","tr.item",function(){var b=a(this),c=b.find("input.quantity"),d=c.val(),e=accounting.unformat(b.find("input.line_subtotal").val(),woocommerce_admin.mon_decimal_point),f=accounting.unformat(b.find("input.line_total").val(),woocommerce_admin.mon_decimal_point),g=accounting.unformat(b.find("input.line_tax").val(),woocommerce_admin.mon_decimal_point),h=accounting.unformat(b.find("input.line_subtotal_tax").val(),woocommerce_admin.mon_decimal_point);d?(unit_subtotal=parseFloat(accounting.toFixed(e/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_subtotal_tax=parseFloat(accounting.toFixed(h/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_total=parseFloat(accounting.toFixed(f/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_total_tax=parseFloat(accounting.toFixed(g/d,woocommerce_admin_meta_boxes.rounding_precision))):unit_subtotal=unit_subtotal_tax=unit_total=unit_total_tax=0,c.attr("data-o_qty",d),b.attr("data-unit_subtotal",unit_subtotal),b.attr("data-unit_subtotal_tax",unit_subtotal_tax),b.attr("data-unit_total",unit_total),b.attr("data-unit_total_tax",unit_total_tax)}).on("init_row","tr.fee",function(){var b=a(this),c=accounting.unformat(b.find("input.line_total").val(),woocommerce_admin.mon_decimal_point),d=accounting.unformat(b.find("input.line_tax").val(),woocommerce_admin.mon_decimal_point);unit_total=parseFloat(accounting.toFixed(c,woocommerce_admin_meta_boxes.rounding_precision)),unit_total_tax=parseFloat(accounting.toFixed(d,woocommerce_admin_meta_boxes.rounding_precision)),b.attr("data-unit_total",unit_total),b.attr("data-unit_total_tax",unit_total_tax)}).on("click","a.edit_order_item",function(){return a(this).closest("tr").find(".view").hide(),a(this).closest("tr").find(".edit").show(),a(this).hide(),!1}).on("click","a.delete_order_item",function(){var b=confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(b){var c=a(this).closest("tr.item, tr.fee"),d=c.attr("data-order_item_id");a("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var e={order_item_ids:d,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(){c.remove(),a("table.woocommerce_order_items").unblock()}})}return!1}).on("change","input.quantity",function(){var b=a(this).closest("tr.item"),c=a(this).val(),d=b.attr("data-unit_subtotal"),e=b.attr("data-unit_subtotal_tax"),f=b.attr("data-unit_total"),g=b.attr("data-unit_total_tax"),h=(a(this).attr("data-o_qty"),parseFloat(accounting.formatNumber(d*c,woocommerce_admin_meta_boxes.rounding_precision,""))),i=parseFloat(accounting.formatNumber(e*c,woocommerce_admin_meta_boxes.rounding_precision,"")),j=parseFloat(accounting.formatNumber(f*c,woocommerce_admin_meta_boxes.rounding_precision,"")),k=parseFloat(accounting.formatNumber(g*c,woocommerce_admin_meta_boxes.rounding_precision,""));h=h.toString().replace(".",woocommerce_admin.mon_decimal_point),i=i.toString().replace(".",woocommerce_admin.mon_decimal_point),j=j.toString().replace(".",woocommerce_admin.mon_decimal_point),k=k.toString().replace(".",woocommerce_admin.mon_decimal_point),b.find("input.line_subtotal").val(h),b.find("input.line_total").val(j),b.find("input.line_subtotal_tax").val(i),b.find("input.line_tax").val(k),a(this).trigger("quantity_changed")}).on("change","input.line_subtotal",function(){var b=a(this).closest("tr.item"),c=b.find("input.quanti