From 888d57911c8f7b68c878e794907d22c21c783db6 Mon Sep 17 00:00:00 2001 From: Juraj Kiss Date: Tue, 18 Mar 2014 13:51:10 +0100 Subject: [PATCH] Fix bulk editing variation sale price #5164 --- assets/js/admin/meta-boxes-variations.js | 2 +- assets/js/admin/woocommerce_admin.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/admin/meta-boxes-variations.js b/assets/js/admin/meta-boxes-variations.js index 0d57b71bc15..834876bce12 100644 --- a/assets/js/admin/meta-boxes-variations.js +++ b/assets/js/admin/meta-boxes-variations.js @@ -261,7 +261,7 @@ jQuery( function ( $ ) { case 'variable_download_expiry' : value = window.prompt( woocommerce_admin_meta_boxes_variations.i18n_enter_a_value ); - $( ':input[name^="' + bulk_edit + '["]').val( value ).change(); + $( ':input[name^="' + bulk_edit + '"]').not('[name*="dates"]').val( value ).change(); break; default: $( 'select#field_to_edit' ).trigger( bulk_edit ); diff --git a/assets/js/admin/woocommerce_admin.min.js b/assets/js/admin/woocommerce_admin.min.js index 5e4d7b7a494..cc6af08f96c 100644 --- a/assets/js/admin/woocommerce_admin.min.js +++ b/assets/js/admin/woocommerce_admin.min.js @@ -1 +1 @@ -jQuery(function(){jQuery(".wc_input_decimal[type=text], .wc_input_price[type=text]").bind("blur",function(){return jQuery(".wc_error_tip").fadeOut("100",function(){jQuery(this).remove()}),this}),jQuery(".wc_input_price[type=text]").bind("keyup change",function(){var a=jQuery(this).val(),b=new RegExp("[^0-9%.\\"+woocommerce_admin.mon_decimal_point+"]+","gi"),c=a.replace(b,"");if(a!==c&&(jQuery(this).val(c),0==jQuery(this).parent().find(".wc_error_tip").size())){var d=jQuery(this).position();jQuery(this).after('
'+woocommerce_admin.i18n_mon_decimal_error+"
"),jQuery(".wc_error_tip").css("left",d.left+jQuery(this).width()-jQuery(this).width()/2-jQuery(".wc_error_tip").width()/2).css("top",d.top+jQuery(this).height()).fadeIn("100")}return this}),jQuery(".wc_input_decimal[type=text]").bind("keyup change",function(){var a=jQuery(this).val(),b=new RegExp("[^0-9%.\\"+woocommerce_admin.decimal_point+"]+","gi"),c=a.replace(b,"");if(a!==c&&(jQuery(this).val(c),0==jQuery(this).parent().find(".wc_error_tip").size())){var d=jQuery(this).position();jQuery(this).after('
'+woocommerce_admin.i18n_decimal_error+"
"),jQuery(".wc_error_tip").css("left",d.left+jQuery(this).width()-jQuery(this).width()/2-jQuery(".wc_error_tip").width()/2).css("top",d.top+jQuery(this).height()).fadeIn("100")}return this}),jQuery("body").click(function(){jQuery(".wc_error_tip").fadeOut("100",function(){jQuery(this).remove()})}),jQuery(".tips, .help_tip").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),jQuery(".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(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style")}}),jQuery(".wc_input_table .remove_rows").click(function(){var a=jQuery(this).closest(".wc_input_table").find("tbody");return a.find("tr.current").size()>0&&($current=a.find("tr.current"),$current.each(function(){jQuery(this).remove()})),!1});var a=!1,b=!1,c=!1;jQuery(document).bind("keyup keydown",function(c){b=c.shiftKey,a=c.ctrlKey||c.metaKey}),jQuery(".wc_input_table").on("focus click","input",function(d){$this_table=jQuery(this).closest("table"),$this_row=jQuery(this).closest("tr"),("focus"==d.type&&c!=$this_row.index()||"click"==d.type&&jQuery(this).is(":focus"))&&(c=$this_row.index(),b||a?b?(jQuery("tr",$this_table).removeClass("current"),$this_row.addClass("selected_now").addClass("current"),jQuery("tr.last_selected",$this_table).size()>0&&($this_row.index()>jQuery("tr.last_selected, $this_table").index()?jQuery("tr",$this_table).slice(jQuery("tr.last_selected",$this_table).index(),$this_row.index()).addClass("current"):jQuery("tr",$this_table).slice($this_row.index(),jQuery("tr.last_selected",$this_table).index()+1).addClass("current")),jQuery("tr",$this_table).removeClass("last_selected"),$this_row.addClass("last_selected")):(jQuery("tr",$this_table).removeClass("last_selected"),a&&jQuery(this).closest("tr").is(".current")?$this_row.removeClass("current"):$this_row.addClass("current").addClass("last_selected")):(jQuery("tr",$this_table).removeClass("current").removeClass("last_selected"),$this_row.addClass("current").addClass("last_selected")),jQuery("tr",$this_table).removeClass("selected_now"))}).on("blur","input",function(){c=!1}),jQuery("select.availability").change(function(){"all"==jQuery(this).val()?jQuery(this).closest("tr").next("tr").hide():jQuery(this).closest("tr").next("tr").show()}).change(),jQuery("body").on("click",".show_order_items",function(){return jQuery(this).closest("td").find("table").toggle(),!1}),jQuery(".hide_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show()}).change()}),jQuery(".show_options_if_checked").each(function(){jQuery(this).find("input:eq(0)").change(function(){jQuery(this).is(":checked")?jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").show():jQuery(this).closest("fieldset, tr").nextUntil(".hide_options_if_checked, .show_options_if_checked",".hidden_option").hide()}).change()}),jQuery("input#woocommerce_demo_store").change(function(){jQuery(this).is(":checked")?jQuery("#woocommerce_demo_store_notice").closest("tr").show():jQuery("#woocommerce_demo_store_notice").closest("tr").hide()}).change(),jQuery("table.attributes-table tbody tr:nth-child(odd)").addClass("alternate")}); \ No newline at end of file +jQuery(function(a){function b(){a(".woocommerce_variations .woocommerce_variation").each(function(b,c){a(".variation_menu_order",c).val(parseInt(a(c).index(".woocommerce_variations .woocommerce_variation"),10))})}var c={items:".woocommerce_variation",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,c){c.item.removeAttr("style"),b()}};a("#variable_product_options").on("click","button.add_variation",function(){a(".woocommerce_variations").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes_variations.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b=a(".woocommerce_variation").size(),c={action:"woocommerce_add_variation",post_id:woocommerce_admin_meta_boxes_variations.post_id,loop:b,security:woocommerce_admin_meta_boxes_variations.add_variation_nonce};return a.post(woocommerce_admin_meta_boxes_variations.ajax_url,c,function(b){a(".woocommerce_variations").append(b),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50}),a("input.variable_is_downloadable, input.variable_is_virtual").change(),a(".woocommerce_variations").unblock(),a("#variable_product_options").trigger("woocommerce_variations_added")}),!1}),a("#variable_product_options").on("click","button.link_all_variations",function(){var b=window.confirm(woocommerce_admin_meta_boxes_variations.i18n_link_all_variations);if(b){a("#variable_product_options").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes_variations.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_link_all_variations",post_id:woocommerce_admin_meta_boxes_variations.post_id,security:woocommerce_admin_meta_boxes_variations.link_variation_nonce};a.post(woocommerce_admin_meta_boxes_variations.ajax_url,c,function(b){var c=parseInt(b,10);if(window.alert(1===c?c+" "+woocommerce_admin_meta_boxes_variations.i18n_variation_added:0===c||c>1?c+" "+woocommerce_admin_meta_boxes_variations.i18n_variations_added:woocommerce_admin_meta_boxes_variations.i18n_no_variations_added),c>0){var d=window.location.toString();d=d.replace("post-new.php?","post.php?post="+woocommerce_admin_meta_boxes_variations.post_id+"&action=edit&"),a("#variable_product_options").load(d+" #variable_product_options_inner",function(){a("#variable_product_options").unblock(),a("#variable_product_options").trigger("woocommerce_variations_added"),a(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50})})}else a("#variable_product_options").unblock()})}return!1}),a("#variable_product_options").on("click","button.remove_variation",function(b){b.preventDefault();var c=window.confirm(woocommerce_admin_meta_boxes_variations.i18n_remove_variation);if(c){var d=a(this).parent().parent(),e=a(this).attr("rel");if(e>0){a(d).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes_variations.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var f={action:"woocommerce_remove_variation",variation_id:e,security:woocommerce_admin_meta_boxes_variations.delete_variation_nonce};a.post(woocommerce_admin_meta_boxes_variations.ajax_url,f,function(){a(d).fadeOut("300",function(){a(d).remove()})})}else a(d).fadeOut("300",function(){a(d).remove()})}return!1}),a(".wc-metaboxes-wrapper").on("click","a.bulk_edit",function(){var b,c,d,e=a("select#field_to_edit").val();switch(e){case"toggle_enabled":b=a('input[name^="variable_enabled"]'),b.attr("checked",!b.attr("checked"));break;case"toggle_downloadable":b=a('input[name^="variable_is_downloadable"]'),b.attr("checked",!b.attr("checked")),a("input.variable_is_downloadable").change();break;case"toggle_virtual":b=a('input[name^="variable_is_virtual"]'),b.attr("checked",!b.attr("checked")),a("input.variable_is_virtual").change();break;case"delete_all":if(c=window.confirm(woocommerce_admin_meta_boxes_variations.i18n_delete_all_variations),c&&(c=window.confirm(woocommerce_admin_meta_boxes_variations.i18n_last_warning))){var f=[];a(".woocommerce_variations .woocommerce_variation").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes_variations.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a(".woocommerce_variations .woocommerce_variation .remove_variation").each(function(){var b=a(this).attr("rel");b>0&&f.push(b)});var g={action:"woocommerce_remove_variations",variation_ids:f,security:woocommerce_admin_meta_boxes_variations.delete_variations_nonce};a.post(woocommerce_admin_meta_boxes_variations.ajax_url,g,function(){a(".woocommerce_variations .woocommerce_variation").fadeOut("300",function(){a(".woocommerce_variations .woocommerce_variation").remove()})})}break;case"variable_regular_price_increase":case"variable_regular_price_decrease":case"variable_sale_price_increase":case"variable_sale_price_decrease":var h;h=0===e.lastIndexOf("variable_regular_price",0)?"variable_regular_price":"variable_sale_price",d=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_a_value_fixed_or_percent).toString(),a(':input[name^="'+h+'"]').each(function(){var b,c=Number(a(this).val());if(d.indexOf("%")>=0)var f=Number(Number(c)/100*Number(d.replace(/\%/,"")));else var f=Number(d);b=-1!==e.indexOf("increase")?c+f:c-f,a(this).val(b).change()});break;case"variable_regular_price":case"variable_sale_price":case"variable_stock":case"variable_weight":case"variable_length":case"variable_width":case"variable_height":case"variable_download_limit":case"variable_download_expiry":d=window.prompt(woocommerce_admin_meta_boxes_variations.i18n_enter_a_value),a(':input[name^="'+e+'"]').not('[name*="dates"]').val(d).change();break;default:a("select#field_to_edit").trigger(e)}}),a("#variable_product_options").on("change","input.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()}),a("#variable_product_options").on("change","input.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()}),a("input.variable_is_downloadable, input.variable_is_virtual").change(),a("#variable_product_options").on("woocommerce_variations_added",function(){a(".woocommerce_variations").sortable(c)}),a(".woocommerce_variations").sortable(c);var d,e,f,g=wp.media.model.settings.post.id;a("#variable_product_options").on("click",".upload_image_button",function(b){var c=a(this),h=c.attr("rel"),i=c.closest(".upload_image");if(f=i,e=h,b.preventDefault(),c.is(".remove"))f.find(".upload_image_id").val(""),f.find("img").attr("src",woocommerce_admin_meta_boxes_variations.woocommerce_placeholder_img_src),f.find(".upload_image_button").removeClass("remove");else{if(d)return d.uploader.uploader.param("post_id",e),void d.open();wp.media.model.settings.post.id=e,d=wp.media.frames.variable_image=wp.media({title:woocommerce_admin_meta_boxes_variations.i18n_choose_image,button:{text:woocommerce_admin_meta_boxes_variations.i18n_set_image},states:[new wp.media.controller.Library({title:woocommerce_admin_meta_boxes_variations.i18n_choose_image,filterable:"all"})]}),d.on("select",function(){var a=d.state().get("selection").first().toJSON();f.find(".upload_image_id").val(a.id),f.find(".upload_image_button").addClass("remove"),f.find("img").attr("src",a.url),wp.media.model.settings.post.id=g}),d.open()}}),a("a.add_media").on(" click",function(){wp.media.model.settings.post.id=g})}); \ No newline at end of file