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

1 line
7.2 KiB
JavaScript

jQuery(function(e){if("undefined"!=typeof woocommerce_admin){var t=e(".edit-php.post-type-product"),i=t.find(".page-title-action:first");0===t.find(".woocommerce-BlankState").length?(i.after('<a href="'+woocommerce_admin.urls.export_products+'" class="page-title-action">'+woocommerce_admin.strings.export_products+"</a>"),i.after('<a href="'+woocommerce_admin.urls.import_products+'" class="page-title-action">'+woocommerce_admin.strings.import_products+"</a>")):i.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(t,i,o){var r=i.position();0===i.parent().find(".wc_error_tip").length&&(i.after('<div class="wc_error_tip '+o+'">'+woocommerce_admin[o]+"</div>"),i.parent().find(".wc_error_tip").css("left",r.left+i.width()-i.width()/2-e(".wc_error_tip").width()/2).css("top",r.top+i.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 t;t=e(this).is(".wc_input_price")||e(this).is("#refund_amount")?new RegExp("[^-0-9%\\"+woocommerce_admin.mon_decimal_point+"]+","gi"):new RegExp("[^-0-9%\\"+woocommerce_admin.decimal_point+"]+","gi");var i=e(this).val(),o=i.replace(t,"");i!==o&&e(this).val(o)}).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 t,i;e(this).is(".wc_input_price")||e(this).is("#refund_amount")?(t=new RegExp("[^-0-9%\\"+woocommerce_admin.mon_decimal_point+"]+","gi"),i="i18n_mon_decimal_error"):e(this).is(".wc_input_country_iso")?(t=new RegExp("([^A-Z])+|(.){3,}","im"),i="i18n_country_iso_error"):(t=new RegExp("[^-0-9%\\"+woocommerce_admin.decimal_point+"]+","gi"),i="i18n_decimal_error");var o=e(this).val();o!==o.replace(t,"")?e(document.body).triggerHandler("wc_add_error_tip",[e(this),i]):e(document.body).triggerHandler("wc_remove_error_tip",[e(this),i])}).on("change","#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]",function(){var t,i=e(this);t=-1!==i.attr("name").indexOf("variable")?i.parents(".variable_pricing").find(".wc_input_price[name^=variable_regular_price]"):e("#_regular_price"),parseFloat(window.accounting.unformat(i.val(),woocommerce_admin.mon_decimal_point))>=parseFloat(window.accounting.unformat(t.val(),woocommerce_admin.mon_decimal_point))&&e(this).val("")}).on("keyup","#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]",function(){var t,i=e(this);t=-1!==i.attr("name").indexOf("variable")?i.parents(".variable_pricing").find(".wc_input_price[name^=variable_regular_price]"):e("#_regular_price"),parseFloat(window.accounting.unformat(i.val(),woocommerce_admin.mon_decimal_point))>=parseFloat(window.accounting.unformat(t.val(),woocommerce_admin.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(){var t={attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200};e(".tips, .help_tip, .woocommerce-help-tip").tipTip(t),e(".parent-tips").each(function(){e(this).closest("a, th").attr("data-tip",e(this).data("tip")).tipTip(t).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 .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 o=!1,r=!1,n=!1;e(document.body).bind("keyup keydown",function(e){r=e.shiftKey,o=e.ctrlKey||e.metaKey}),e(".wc_input_table").on("focus click","input",function(t){var i=e(this).closest("table, tbody"),c=e(this).closest("tr");("focus"===t.type&&n!==c.index()||"click"===t.type&&e(this).is(":focus"))&&(n=c.index(),r||o?r?(e("tr",i).removeClass("current"),c.addClass("selected_now").addClass("current"),e("tr.last_selected",i).length>0&&(c.index()>e("tr.last_selected",i).index()?e("tr",i).slice(e("tr.last_selected",i).index(),c.index()).addClass("current"):e("tr",i).slice(c.index(),e("tr.last_selected",i).index()+1).addClass("current")),e("tr",i).removeClass("last_selected"),c.addClass("last_selected")):(e("tr",i).removeClass("last_selected"),o&&e(this).closest("tr").is(".current")?c.removeClass("current"):c.addClass("current").addClass("last_selected")):(e("tr",i).removeClass("current").removeClass("last_selected"),c.addClass("current").addClass("last_selected")),e("tr",i).removeClass("selected_now"))}).on("blur","input",function(){n=!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_demo_store").change(function(){e(this).is(":checked")?e("#woocommerce_demo_store_notice").closest("tr").show():e("#woocommerce_demo_store_notice").closest("tr").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("#contextual-help-link").on("click",function(){e(".wc-guided-tour-embed").each(function(){var t=e(this).data("video_id");e(this).replaceWith('<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/'+t+'" frameborder="0" allowfullscreen></iframe>')})})}});