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

1 line
12 KiB
JavaScript
Raw Normal View History

2019-04-16 13:36:37 +00:00
jQuery(function(n){function i(){var t=n("select#product-type").val(),e=n("input#_virtual:checked").length,i=n("input#_downloadable:checked").length,o=".hide_if_downloadable, .hide_if_virtual",a=".show_if_downloadable, .show_if_virtual";n.each(woocommerce_admin_meta_boxes.product_types,function(t,e){o=o+", .hide_if_"+e,a=a+", .show_if_"+e}),n(o).show(),n(a).hide(),i&&n(".show_if_downloadable").show(),e&&n(".show_if_virtual").show(),n(".show_if_"+t).show(),i&&n(".hide_if_downloadable").hide(),e&&n(".hide_if_virtual").hide(),n(".hide_if_"+t).hide(),n("input#_manage_stock").change(),n(".woocommerce_options_panel").each(function(){var t=n(this).children(".options_group");if(0!==t.length&&t.filter(function(){return"none"===n(this).css("display")}).length===t.length){var e=n(this).prop("id");n(".product_data_tabs").find('li a[href="#'+e+'"]').parent().hide()}})}function t(t){var e=n(t).next().is(".hasDatepicker")?"minDate":"maxDate",i="minDate"==e?n(t).next():n(t).prev(),o=n(t).datepicker("getDate");n(i).datepicker("option",e,o),n(t).change()}n(function(){n('[id$="-all"] > ul.categorychecklist').each(function(){var t=n(this),e=t.find(":checked").first();if(e.length){var i=t.find("input").position().top,o=e.position().top;t.closest(".tabs-panel").scrollTop(o-i+5)}})}),n("#upsell_product_data").bind("keypress",function(t){if(13===t.keyCode)return!1}),n(".type_box").appendTo("#woocommerce-product-data .hndle span"),n(function(){n("#woocommerce-product-data").find(".hndle").unbind("click.postboxes"),n("#woocommerce-product-data").on("click",".hndle",function(t){n(t.target).filter("input, option, label, select").length||n("#woocommerce-product-data").toggleClass("closed")})}),n("#catalog-visibility").find(".edit-catalog-visibility").click(function(){return n("#catalog-visibility-select").is(":hidden")&&(n("#catalog-visibility-select").slideDown("fast"),n(this).hide()),!1}),n("#catalog-visibility").find(".save-post-visibility").click(function(){n("#catalog-visibility-select").slideUp("fast"),n("#catalog-visibility").find(".edit-catalog-visibility").show();var t=n("input[name=_visibility]:checked").attr("data-label");return n("input[name=_featured]").is(":checked")&&(t=t+", "+woocommerce_admin_meta_boxes.featured_label,n("input[name=_featured]").attr("checked","checked")),n("#catalog-visibility-display").text(t),!1}),n("#catalog-visibility").find(".cancel-post-visibility").click(function(){n("#catalog-visibility-select").slideUp("fast"),n("#catalog-visibility").find(".edit-catalog-visibility").show();var t=n("#current_visibility").val(),e=n("#current_featured").val();n("input[name=_visibility]").removeAttr("checked"),n("input[name=_visibility][value="+t+"]").attr("checked","checked");var i=n("input[name=_visibility]:checked").attr("data-label");return"yes"===e?(i=i+", "+woocommerce_admin_meta_boxes.featured_label,n("input[name=_featured]").attr("checked","checked")):n("input[name=_featured]").removeAttr("checked"),n("#catalog-visibility-display").text(i),!1}),n("select#product-type").change(function(){var t=n(this).val();"variable"===t?(n("input#_manage_stock").change(),n("input#_downloadable").prop("checked",!1),n("input#_virtual").removeAttr("checked")):"grouped"===t?(n("input#_downloadable").prop("checked",!1),n("input#_virtual").removeAttr("checked")):"external"===t&&(n("input#_downloadable").prop("checked",!1),n("input#_virtual").removeAttr("checked")),i(),n("ul.wc-tabs li:visible").eq(0).find("a").click(),n(document.body).trigger("woocommerce-product-type-change",t,n(this))}).change(),n("input#_downloadable, input#_virtual").change(function(){i()}),n(".sale_price_dates_fields").each(function(){var t=n(this),e=!1,i=t.closest("div, table");t.find("input").each(function(){""!==n(this).val()&&(e=!0)}),e?(i.find(".sale_schedule").hide(),i.find(".sale_price_dates_fields").show()):(i.find(".sale_schedule").show(),i.find(".sale_price_dates_fields").hide())}),n("#woocommerce-product-data").on("click",".sale_schedule",function(){var t=n(this).closest("div, table");return n(this).hide(),t.find(".cancel_sale_schedule").show(),t.find(".sale