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

1 line
24 KiB
JavaScript
Raw Normal View History

2014-11-11 11:23:44 +00:00
jQuery(function(a){function b(){a("#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}})}function c(){a("#woocommerce-order-items").unblock()}function d(){a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})}function e(){var e={order_id:woocommerce_admin_meta_boxes.post_id,action:"woocommerce_load_order_items",security:woocommerce_admin_meta_boxes.order_item_nonce};b(),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:e,type:"POST",success:function(b){a("#woocommerce-order-items .inside").empty(),a("#woocommerce-order-items .inside").append(b),d(),c()}})}a("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),a("a.edit_address").click(function(b){b.preventDefault(),a(this).hide(),a(this).closest(".order_data_column").find("div.address").hide(),a(this).closest(".order_data_column").find("div.edit_address").show()});var f=null,g={};"undefined"!=typeof woocommerce_admin_meta_boxes_order&&"undefined"!=typeof woocommerce_admin_meta_boxes_order.countries&&(f=a.parseJSON(woocommerce_admin_meta_boxes_order.countries.replace(/&quot;/g,'"'))),a(".js_field-country").chosen(g).change(function(b,c){if("undefined"==typeof c&&(c=!1),null!==f){var d=a(this),e=d.val(),h=d.parents(".edit_address").find(".js_field-state"),i=h.parent(),j=h.attr("name"),k=h.attr("id"),l=d.data("woocommerce.stickState-"+e)?d.data("woocommerce.stickState-"+e):h.val(),m=h.attr("placeholder");if(c&&d.data("woocommerce.stickState-"+e,l),i.show().find(".chosen-container").remove(),f[e]){var n=a('<select name="'+j+'" id="'+k+'" class="js_field-state select short" placeholder="'+m+'"></select>'),o=f[e];n.append(a('<option value="">'+woocommerce_admin_meta_boxes_order.i18n_select_state_text+"</option>")),a.each(o,function(b){n.append(a('<option value="'+b+'">'+o[b]+"</option>"))}),n.val(l),h.replaceWith(n),n.show().chosen(g).hide().trigger("chosen:updated")}else h.replaceWith('<input type="text" class="js_field-state" name="'+j+'" id="'+k+'" placeholder="'+m+'" />');a("body").trigger("contry-change.woocommerce",[e,a(this).closest("div")])}}).trigger("change",[!0]),a("body").on("change","select.js_field-state",function(){var b=a(this),c=b.val(),d=b.parents(".edit_address").find(".js_field-country"),e=d.val();d.data("woocommerce.stickState-"+e,c)}).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(),a("button.add-line-item").click(),a("button.cancel-action").attr("data-reload",!0),!1}).on("click",".woocommerce_order_items a.delete-order-item",function(){var d=window.confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(d){var e=a(this).closest("tr.item, tr.fee, tr.shipping"),f=e.attr("data-order_item_id");b();var g={order_item_ids:f,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:g,type:"POST",success:function(){e.remove(),c()}})}return!1}).on("click","#order_refunds .delete_refund",function(){if(window.confirm(woocommerce_admin_meta_boxes.i18n_delete_refund)){var c=a(this).closest("tr.refund"),d=c.attr("data-order_refund_id");b();var f={action:"woocommerce_delete_refund",refund_id:d,security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){e()}})}return!1}).on("change",".woocommerce_order_items input.quantity",function(){var b=a(this).closest("tr.item"),c=a(this).val(),d=a(this).attr("data-qty"),e=a("input.line_total",b),f=a("input.line_subtotal",b),g=accounting.unformat(e.attr("data-total"),woocommerce_admin.mon_decimal_point)/d;e.val(parseFloat(accounting.formatNumber(g*c,woocommerce_admin_meta_boxes.rounding_precision,"")).toString().replace(".",woocommerce_admin.mon_decimal_point));var h=a