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

1 line
7.9 KiB
JavaScript

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