woocommerce/assets/js/admin/write-panels.min.js

1 line
19 KiB
JavaScript
Raw Normal View History

jQuery(function(e){function i(){e(".woocommerce_attributes .woocommerce_attribute").each(function(t,n){e(".attribute_position",n).val(parseInt(e(n).index(".woocommerce_attributes .woocommerce_attribute")))})}e("#upsell_product_data").bind("keypress",function(e){if(e.keyCode==13)return!1});e("ul.tabs").show();e("div.panel-wrap").each(function(){e("div.panel:not(div.panel:first)",this).hide()});e("ul.tabs a").click(function(){var t=e(this).closest("div.panel-wrap");e("ul.tabs li",t).removeClass("active");e(this).parent().addClass("active");e("div.panel",t).hide();e(e(this).attr("href")).show();return!1});jQuery("select.chosen_select").chosen();jQuery("select.chosen_select_nostd").chosen({allow_single_deselect:"true"});jQuery("select.ajax_chosen_select_products").ajaxChosen({method:"GET",url:woocommerce_writepanel_params.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products",security:woocommerce_writepanel_params.search_products_nonce}},function(t){var n={};e.each(t,function(e,t){n[e]=t});return n});jQuery("select.ajax_chosen_select_products_and_variations").ajaxChosen({method:"GET",url:woocommerce_writepanel_params.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products_and_variations",security:woocommerce_writepanel_params.search_products_nonce}},function(t){var n={};e.each(t,function(e,t){n[e]=t});return n});jQuery("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""});e("a.edit_address").click(function(t){e(this).hide();e(this).closest(".order_data").find("div.address").hide();e(this).closest(".order_data").find("div.edit_address").show();t.preventDefault()});e("#order_items_list .remove_row").live("click",function(){var t=confirm(woocommerce_writepanel_params.remove_item_notice);if(t){e(this).closest("tr.item").hide();e("input",e(this).closest("tr.item")).val("")}return!1});e("button.calc_line_taxes").live("click",function(){e(".woocommerce_order_items_wrapper").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var t=confirm(woocommerce_writepanel_params.calc_line_taxes);if(t){var n=e("#order_items_list tr.item"),r=e("#_shipping_country").val();if(r)var i=e("#_shipping_state").val(),s=e("#_shipping_postcode").val();else{r=e("#_billing_country").val();var i=e("#_billing_state").val(),s=e("#_billing_postcode").val()}n.each(function(t){var o=e(this),u={action:"woocommerce_calc_line_taxes",item_id:o.find("input.item_id").val(),line_subtotal:o.find("input.line_subtotal").val(),line_total:o.find("input.line_total").val(),tax_class:o.find("select.tax_class").val(),country:r,state:i,postcode:s,security:woocommerce_writepanel_params.calc_totals_nonce};e.post(woocommerce_writepanel_params.ajax_url,u,function(r){result=jQuery.parseJSON(r);o.find("input.line_subtotal_tax").val(result.line_subtotal_tax);o.find("input.line_tax").val(result.line_tax);t==n.size()-1&&e(".woocommerce_order_items_wrapper").unblock()})})}else e(".woocommerce_order_items_wrapper").unblock();return!1}).hover(function(){e("#order_items_list input.line_subtotal_tax, #order_items_list input.line_tax").css("background-color","#d8c8d2")},function(){e("#order_items_list input.line_subtotal_tax, #order_items_list input.line_tax").css("background-color","")});e("button.calc_totals").live("click",function(){e("#woocommerce-order-totals").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_writepanel_params.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var t=confirm(woocommerce_writepanel_params.calc_totals);if(t){var n=0,r=0,i=0,s=0,o=0,u=parseFloat(e("#_order_shipping").val()),a=parseFloat(e("#_order_shipping_tax").val()),f=parseFloat(e("#_order_discount").val());u||(u=0);a||(a=0);f||(f=0);e("#order_items_list tr.item").each(function(){var t=parseFloat(e(this).find("input.line_subtotal").val()),s=parseFloat(e(this).find("input.line_subtotal_tax").val()),u=parseFloat(e(this).find("input.