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

1 line
18 KiB
JavaScript
Raw Normal View History

2019-03-15 12:21:51 +00:00
jQuery(function(d){"use strict";var o={init:function(){d("#variable_product_options").on("change","input.variable_is_downloadable",this.variable_is_downloadable).on("change","input.variable_is_virtual",this.variable_is_virtual).on("change","input.variable_manage_stock",this.variable_manage_stock).on("click","button.notice-dismiss",this.notice_dismiss).on("click","h3 .sort",this.set_menu_order).on("reload",this.reload),d("input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock").change(),d("#woocommerce-product-data").on("woocommerce_variations_loaded",this.variations_loaded),d(document.body).on("woocommerce_variations_added",this.variation_added)},reload:function(){n.load_variations(1),m.set_paginav(0)},variable_is_downloadable:function(){d(this).closest(".woocommerce_variation").find(".show_if_variation_downloadable").hide(),d(this).is(":checked")&&d(this).closest(".woocommerce_variation").find(".show_if_variation_downloadable").show()},variable_is_virtual:function(){d(this).closest(".woocommerce_variation").find(".hide_if_variation_virtual").show(),d(this).is(":checked")&&d(this).closest(".woocommerce_variation").find(".hide_if_variation_virtual").hide()},variable_manage_stock:function(){d(this).closest(".woocommerce_variation").find(".show_if_variation_manage_stock").hide(),d(this).closest(".woocommerce_variation").find(".hide_if_variation_manage_stock").show(),d(this).is(":checked")&&(d(this).closest(".woocommerce_variation").find(".show_if_variation_manage_stock").show(),d(this).closest(".woocommerce_variation").find(".hide_if_variation_manage_stock").hide())},notice_dismiss:function(){d(this).closest("div.notice").remove()},variations_loaded:function(a,e){e=e||!1;var i=d("#woocommerce-product-data");e||(d("input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock",i).change(),d(".woocommerce_variation",i).each(function(a,e){var i=d(e),o=d(".sale_price_dates_from",i).val(),t=d(".sale_price_dates_to",i).val();""===o&&""===t||d("a.sale_schedule",i).click()}),d(".woocommerce_variations .variation-needs-update",i).removeClass("variation-needs-update"),d("button.cancel-variation-changes, button.save-variation-changes",i).attr("disabled","disabled")),d("#tiptip_holder").removeAttr("style"),d("#tiptip_arrow").removeAttr("style"),d(".woocommerce_variations .tips, .woocommerce_variations .help_tip, .woocommerce_variations .woocommerce-help-tip",i).tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),d(".sale_price_dates_fields",i).find("input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,onSelect:function(){var a=d(this).is(".sale_price_dates_from")?"minDate":"maxDate",e=d(this).closest(".sale_price_dates_fields").find("input"),i=d(this).datepicker("getDate");e.not(this).datepicker("option",a,i),d(this).change()}}),d(".woocommerce_variations",i).sortable({items:".woocommerce_variation",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,stop:function(){o.variation_row_indexes()}}),d(document.body).trigger("wc-enhanced-select-init")},variation_added:function(a,e){1===e&&o.variations_loaded(null,!0)},set_menu_order:function(a){a.preventDefault();var e=d(this).closest(".woocommerce_variation").find(".variation_menu_order"),i=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_menu_order,e.val());null!=i&&(e.val(parseInt(i,10)).change(),n.save_variations())},variation_row_indexes:function(){var a=d("#variable_product_options").find(".woocommerce_variations"),e=parseInt(a.attr("data-page"),10),i=parseInt((e-1)*woocommerce_admin_meta_boxes_variations.variations_per_page,10);d(".woocommerce_variations .woocommerce_variation").each(function(a,e){d(".variation_menu_order",e).val(parseInt(d(e).index(".woocommerce_variations .woocommerce_variation"),10)+1+i).change()})}},t={variable_image_frame:null,setting_variation_image_id:null,setting_variation_image:null,wp_media_post_id:wp.media.model.settings.post.id,init:function(){d("#variable_product_options").on(