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

1 line
18 KiB
JavaScript
Raw Normal View History

2017-08-10 15:32:24 +00:00
jQuery(function(a){var e={init:function(){a("#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),a("input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock").change(),a("#woocommerce-product-data").on("woocommerce_variations_loaded",this.variations_loaded),a(document.body).on("woocommerce_variations_added",this.variation_added)},reload:function(){o.load_variations(1),t.set_paginav(0)},variable_is_downloadable:function(){a(this).closest(".woocommerce_variation").find(".show_if_variation_downloadable").hide(),a(this).is(":checked")&&a(this).closest(".woocommerce_variation").find(".show_if_variation_downloadable").show()},variable_is_virtual:function(){a(this).closest(".woocommerce_variation").find(".hide_if_variation_virtual").show(),a(this).is(":checked")&&a(this).closest(".woocommerce_variation").find(".hide_if_variation_virtual").hide()},variable_manage_stock:function(){a(this).closest(".woocommerce_variation").find(".show_if_variation_manage_stock").hide(),a(this).is(":checked")&&a(this).closest(".woocommerce_variation").find(".show_if_variation_manage_stock").show()},notice_dismiss:function(){a(this).closest("div.notice").remove()},variations_loaded:function(i,o){o=o||!1;var t=a("#woocommerce-product-data");o||(a("input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock",t).change(),a(".woocommerce_variation",t).each(function(e,i){var o=a(i),t=a(".sale_price_dates_from",o).val(),n=a(".sale_price_dates_to",o).val();""===t&&""===n||a("a.sale_schedule",o).click()}),a(".woocommerce_variations .variation-needs-update",t).removeClass("variation-needs-update"),a("button.cancel-variation-changes, button.save-variation-changes",t).attr("disabled","disabled")),a("#tiptip_holder").removeAttr("style"),a("#tiptip_arrow").removeAttr("style"),a(".woocommerce_variations .tips, .woocommerce_variations .help_tip, .woocommerce_variations .woocommerce-help-tip",t).tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),a(".sale_price_dates_fields",t).find("input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,onSelect:function(){var e=a(this).is(".sale_price_dates_from")?"minDate":"maxDate",i=a(this).closest(".sale_price_dates_fields").find("input"),o=a(this).datepicker("getDate");i.not(this).datepicker("option",e,o),a(this).change()}}),a(".woocommerce_variations",t).sortable({items:".woocommerce_variation",cursor:"move",axis:"y",handle:".sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,stop:function(){e.variation_row_indexes()}}),a(document.body).trigger("wc-enhanced-select-init")},variation_added:function(a,i){1===i&&e.variations_loaded(null,!0)},set_menu_order:function(e){e.preventDefault();var i=a(this).closest(".woocommerce_variation").find(".variation_menu_order"),t=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_menu_order,i.val());null!=t&&(i.val(parseInt(t,10)).change(),o.save_variations())},variation_row_indexes:function(){var e=a("#variable_product_options").find(".woocommerce_variations"),i=parseInt(e.attr("data-page"),10),o=parseInt((i-1)*woocommerce_admin_meta_boxes_variations.variations_per_page,10);a(".woocommerce_variations .woocommerce_variation").each(function(e,i){a(".variation_menu_order",i).val(parseInt(a(i).index(".woocommerce_variations .woocommerce_variation"),10)+1+o).change()})}},i={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(){a("#variable_product_options").on("click",".upload_image_button",this.add_image),a("a.add_media").on("click",this.restore_wp_media_post_id)},add_image:function(e){var o=a(this),t=o.attr("rel"),n=o.closest(".upload_image");if(i.