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

1 line
25 KiB
JavaScript
Raw Normal View History

2018-08-30 16:56:26 +00:00
jQuery(function(l){var u={states:null,init:function(){"undefined"!=typeof woocommerce_admin_meta_boxes_order&&"undefined"!=typeof woocommerce_admin_meta_boxes_order.countries&&(this.states=l.parseJSON(woocommerce_admin_meta_boxes_order.countries.replace(/&quot;/g,'"'))),l(".js_field-country").selectWoo().change(this.change_country),l(".js_field-country").trigger("change",[!0]),l(document.body).on("change","select.js_field-state",this.change_state),l("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),l("a.edit_address").click(this.edit_address),l("a.billing-same-as-shipping").on("click",this.copy_billing_to_shipping),l("a.load_customer_billing").on("click",this.load_billing),l("a.load_customer_shipping").on("click",this.load_shipping),l("#customer_user").on("change",this.change_customer_user)},change_country:function(e,o){if(void 0===o&&(o=!1),null!==u.states){var t=l(this),i=t.val(),a=t.parents("div.edit_address").find(":input.js_field-state"),n=a.parent(),r=a.attr("name"),c=a.attr("id"),d=t.data("woocommerce.stickState-"+i)?t.data("woocommerce.stickState-"+i):a.val(),m=a.attr("placeholder");if(o&&t.data("woocommerce.stickState-"+i,d),n.show().find(".select2-container").remove(),l.isEmptyObject(u.states[i]))a.replaceWith('<input type="text" class="js_field-state" name="'+r+'" id="'+c+'" value="'+d+'" placeholder="'+m+'" />');else{var _=l('<select name="'+r+'" id="'+c+'" class="js_field-state select short" placeholder="'+m+'"></select>'),s=u.states[i];_.append(l('<option value="">'+woocommerce_admin_meta_boxes_order.i18n_select_state_text+"</option>")),l.each(s,function(e){_.append(l('<option value="'+e+'">'+s[e]+"</option>"))}),_.val(d),a.replaceWith(_),_.show().selectWoo().hide().change()}l(document.body).trigger("contry-change.woocommerce",[i,l(this).closest("div")]),l(document.body).trigger("country-change.woocommerce",[i,l(this).closest("div")])}},change_state:function(){var e=l(this),o=e.val(),t=e.parents("div.edit_address").find(":input.js_field-country"),i=t.val();t.data("woocommerce.stickState-"+i,o)},init_tiptip:function(){l("#tiptip_holder").removeAttr("style"),l("#tiptip_arrow").removeAttr("style"),l(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200})},edit_address:function(e){e.preventDefault();var o=l(this),t=o.closest(".order_data_column"),i=t.find("div.edit_address"),a=t.find("div.address"),n=i.find(".js_field-country"),r=i.find(".js_field-state");a.hide(),o.parent().find("a").toggle(),n.val()||(n.val(woocommerce_admin_meta_boxes_order.default_country).change(),r.val(woocommerce_admin_meta_boxes_order.default_state).change()),i.show()},change_customer_user:function(){l("#_billing_country").val()||(l("a.edit_address").click(),u.load_billing(!0),u.load_shipping(!0))},load_billing:function(e){if(!0===e||window.confirm(woocommerce_admin_meta_boxes.load_billing)){var o=l("#customer_user").val();if(!o)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var t={user_id:o,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};l(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),l.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:t,type:"POST",success:function(e){e&&e.billing&&l.each(e.billing,function(e,o){l(":input#_billing_"+e).val(o).change()}),l("div.edit_address").unblock()}})}return!1},load_shipping:function(e){if(!0===e||window.confirm(woocommerce_admin_meta_boxes.load_shipping)){var o=l("#customer_user").val();if(!o)return window.alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var t={user_id:o,action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};l(this).closest("div.edit_address").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),l.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:t,type:"POST",success:function(e){e&&e.billing&&l.each(e.shipping,function(e,o){l(":input#_shipping_"+e).val(o).change()}),l("div.edit_address").u