woocommerce/assets/js/admin/woocommerce_admin.min.js

1 line
7.6 KiB
JavaScript

!function(e,t){e(function(){if(void 0!==t){var i=e(".edit-php.post-type-product"),o=i.find(".page-title-action:first");0===i.find(".woocommerce-BlankState").length?(t.urls.export_products&&o.after('<a href="'+t.urls.export_products+'" class="page-title-action">'+t.strings.export_products+"</a>"),t.urls.import_products&&o.after('<a href="'+t.urls.import_products+'" class="page-title-action">'+t.strings.import_products+"</a>")):o.hide(),e(".woocommerce-progress-form-wrapper .button-next").on("click",function(){return e(".wc-progress-form-content").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),!0}),e(document.body).on("wc_add_error_tip",function(i,o,n){var r=o.position();0===o.parent().find(".wc_error_tip").length&&(o.after('<div class="wc_error_tip '+n+'">'+t[n]+"</div>"),o.parent().find(".wc_error_tip").css("left",r.left+o.width()-o.width()/2-e(".wc_error_tip").width()/2).css("top",r.top+o.height()).fadeIn("100"))}).on("wc_remove_error_tip",function(t,i,o){i.parent().find(".wc_error_tip."+o).fadeOut("100",function(){e(this).remove()})}).on("click",function(){e(".wc_error_tip").fadeOut("100",function(){e(this).remove()})}).on("blur",".wc_input_decimal[type=text], .wc_input_price[type=text], .wc_input_country_iso[type=text]",function(){e(".wc_error_tip").fadeOut("100",function(){e(this).remove()})}).on("change",".wc_input_price[type=text], .wc_input_decimal[type=text], .wc-order-totals #refund_amount[type=text]",function(){var i;i=e(this).is(".wc_input_price")||e(this).is("#refund_amount")?new RegExp("[^-0-9%\\"+t.mon_decimal_point+"]+","gi"):new RegExp("[^-0-9%\\"+t.decimal_point+"]+","gi");var o=e(this).val(),n=o.replace(i,"");o!==n&&e(this).val(n)}).on("keyup",".wc_input_price[type=text], .wc_input_decimal[type=text], .wc_input_country_iso[type=text], .wc-order-totals #refund_amount[type=text]",function(){var i,o;e(this).is(".wc_input_price")||e(this).is("#refund_amount")?(i=new RegExp("[^-0-9%\\"+t.mon_decimal_point+"]+","gi"),o="i18n_mon_decimal_error"):e(this).is(".wc_input_country_iso")?(i=new RegExp("([^A-Z])+|(.){3,}","im"),o="i18n_country_iso_error"):(i=new RegExp("[^-0-9%\\"+t.decimal_point+"]+","gi"),o="i18n_decimal_error");var n=e(this).val();n!==n.replace(i,"")?e(document.body).triggerHandler("wc_add_error_tip",[e(this),o]):e(document.body).triggerHandler("wc_remove_error_tip",[e(this),o])}).on("change","#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]",function(){var i,o=e(this);i=-1!==o.attr("name").indexOf("variable")?o.parents(".variable_pricing").find(".wc_input_price[name^=variable_regular_price]"):e("#_regular_price"),parseFloat(window.accounting.unformat(o.val(),t.mon_decimal_point))>=parseFloat(window.accounting.unformat(i.val(),t.mon_decimal_point))&&e(this).val("")}).on("keyup","#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]",function(){var i,o=e(this);i=-1!==o.attr("name").indexOf("variable")?o.parents(".variable_pricing").find(".wc_input_price[name^=variable_regular_price]"):e("#_regular_price"),parseFloat(window.accounting.unformat(o.val(),t.mon_decimal_point))>=parseFloat(window.accounting.unformat(i.val(),t.mon_decimal_point))?e(document.body).triggerHandler("wc_add_error_tip",[e(this),"i18_sale_less_than_regular_error"]):e(document.body).triggerHandler("wc_remove_error_tip",[e(this),"i18_sale_less_than_regular_error"])}).on("init_tooltips",function(){e(".tips, .help_tip, .woocommerce-help-tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),e(".column-wc_actions .wc-action-button").tipTip({fadeIn:50,fadeOut:50,delay:200}),e(".parent-tips").each(function(){e(this).closest("a, th").attr("data-tip",e(this).data("tip")).tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}).css("cursor","help")})}),e(document.body).trigger("init_tooltips"),e(".wc_input_table.sortable tbody").sortable({items:"tr",cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(e,t){t.item.css("background-color","#f6f6f6")},stop:function(e,t){t.item.removeAttr("style")}}),e(".wc_input_table.sortable tbody input").on("click",function(){e(this).focus()}),e(".wc_input_table .remove_rows").click(function(){var t=e(this).closest(".wc_input_table").find("tbody");return t.find("tr.current").length>0&&t.find("tr.current").each(function(){e(this).remove()}),!1});var n=!1,r=!1,c=!1;e(document.body).bind("keyup keydown",function(e){r=e.shiftKey,n=e.ctrlKey||e.metaKey}),e(".wc_input_table").on("focus click","input",function(t){var i=e(this).closest("table, tbody"),o=e(this).closest("tr");("focus"===t.type&&c!==o.index()||"click"===t.type&&e(this).is(":focus"))&&(c=o.index(),r||n?r?(e("tr",i).removeClass("current"),o.addClass("selected_now").addClass("current"),e("tr.last_selected",i).length>0&&(o.index()>e("tr.last_selected",i).index()?e("tr",i).slice(e("tr.last_selected",i).index(),o.index()).addClass("current"):e("tr",i).slice(o.index(),e("tr.last_selected",i).index()+1).addClass("current")),e("tr",i).removeClass("last_selected"),o.addClass("last_selected")):(e("tr",i).removeClass("last_selected"),n&&e(this).closest("tr").is(".current")?o.removeClass("current"):o.addClass("current").addClass("last_selected")):(e("tr",i).removeClass("current").removeClass("last_selected"),o.addClass("current").addClass("last_selected")),e("tr",i).removeClass("selected_now"))}).on("blur","input",function(){c=!1}),e(".woocommerce_page_wc-settings .shippingrows tbody tr:even, table.attributes-table tbody tr:nth-child(odd)").addClass("alternate"),e(document.body).on("click",".show_order_items",function(){return e(this).closest("td").find("table").toggle(),!1}),e("select.availability").change(function(){"all"===e(this).val()?e(this).closest("tr").next("tr").hide():e(this).closest("tr").next("tr").show()}).change(),e(".hide_options_if_checked").each(function(){e(this).find("input:eq(0)").change(function(){e(this).is(":checked")?e(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide():e(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show()}).change()}),e(".show_options_if_checked").each(function(){e(this).find("input:eq(0)").change(function(){e(this).is(":checked")?e(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show():e(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide()}).change()}),e("input#woocommerce_enable_reviews").change(function(){e(this).is(":checked")?e("#woocommerce_enable_review_rating").closest("tr").show():e("#woocommerce_enable_review_rating").closest("tr").hide()}).change(),e("table.attributes-table tbody tr:nth-child(odd)").addClass("alternate"),e(".wc_gateways").on("click",".wc-payment-gateway-method-toggle-enabled",function(){var i=e(this),o=i.closest("tr"),n=i.find(".woocommerce-input-toggle"),r={action:"woocommerce_toggle_gateway_enabled",security:t.nonces.gateway_toggle,gateway_id:o.data("gateway_id")};return n.addClass("woocommerce-input-toggle--loading"),e.ajax({url:t.ajax_url,data:r,dataType:"json",type:"POST",success:function(e){!0===e.data?(n.removeClass("woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled"),n.addClass("woocommerce-input-toggle--enabled"),n.removeClass("woocommerce-input-toggle--loading")):!1===e.data?(n.removeClass("woocommerce-input-toggle--enabled, woocommerce-input-toggle--disabled"),n.addClass("woocommerce-input-toggle--disabled"),n.removeClass("woocommerce-input-toggle--loading")):"needs_setup"===e.data&&(window.location.href=i.attr("href"))}}),!1})}})}(jQuery,woocommerce_admin);