Stop for change inputs when add a new variation on admin, closes #8874

This commit is contained in:
Claudio Sanches 2015-08-18 13:00:38 -03:00
parent c6ec8dfd26
commit b6b34255d2
2 changed files with 35 additions and 28 deletions

View File

@ -66,10 +66,16 @@ jQuery( function( $ ) {
/** /**
* Run actions when variations is loaded * Run actions when variations is loaded
*
* @param {Object} event
* @param {Int} needsUpdate
*/ */
variations_loaded: function() { variations_loaded: function( event, needsUpdate ) {
needsUpdate = needsUpdate || false;
var wrapper = $( '#woocommerce-product-data' ); var wrapper = $( '#woocommerce-product-data' );
if ( ! needsUpdate ) {
// Show/hide downloadable, virtual and stock fields // Show/hide downloadable, virtual and stock fields
$( 'input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock', wrapper ).change(); $( 'input.variable_is_downloadable, input.variable_is_virtual, input.variable_manage_stock', wrapper ).change();
@ -89,6 +95,7 @@ jQuery( function( $ ) {
// Disable cancel and save buttons // Disable cancel and save buttons
$( 'button.cancel-variation-changes, button.save-variation-changes', wrapper ).attr( 'disabled', 'disabled' ); $( 'button.cancel-variation-changes, button.save-variation-changes', wrapper ).attr( 'disabled', 'disabled' );
}
// Init TipTip // Init TipTip
$( '#tiptip_holder' ).removeAttr( 'style' ); $( '#tiptip_holder' ).removeAttr( 'style' );
@ -119,16 +126,16 @@ jQuery( function( $ ) {
}); });
// Allow sorting // Allow sorting
jQuery( '.woocommerce_variations' ).sortable({ $( '.woocommerce_variations', wrapper ).sortable({
items : '.woocommerce_variation', items: '.woocommerce_variation',
cursor : 'move', cursor: 'move',
axis : 'y', axis: 'y',
handle : '.sort', handle: '.sort',
scrollSensitivity : 40, scrollSensitivity: 40,
forcePlaceholderSize: true, forcePlaceholderSize: true,
helper : 'clone', helper: 'clone',
opacity : 0.65, opacity: 0.65,
stop : function () { stop: function() {
wc_meta_boxes_product_variations_actions.variation_row_indexes(); wc_meta_boxes_product_variations_actions.variation_row_indexes();
} }
}); });
@ -139,12 +146,12 @@ jQuery( function( $ ) {
/** /**
* Run actions when added a variation * Run actions when added a variation
* *
* @param {Object} event [description] * @param {Object} event
* @param {Int} qty * @param {Int} qty
*/ */
variation_added: function( event, qty ) { variation_added: function( event, qty ) {
if ( 1 === qty ) { if ( 1 === qty ) {
wc_meta_boxes_product_variations_actions.variations_loaded(); wc_meta_boxes_product_variations_actions.variations_loaded( null, true );
} }
}, },

File diff suppressed because one or more lines are too long