Use blockui while saving taxes

This commit is contained in:
Claudio Sanches 2015-12-19 12:12:31 -02:00
parent 7adafc77c9
commit a81f0f6eea
4 changed files with 39 additions and 16 deletions

View File

@ -62,14 +62,33 @@
return rates; return rates;
}, },
block: function() {
$( '.wc_tax_rates' ).block({
message: null,
overlayCSS: {
background: '#fff',
opacity: 0.6
}
});
},
unblock: function() {
$( '.wc_tax_rates' ).unblock();
},
save: function() { save: function() {
$.post( ajaxurl + '?action=woocommerce_tax_rates_save_changes', { var self = this;
self.block();
Backbone.ajax({
method: 'POST',
dataType: 'json',
url: ajaxurl + '?action=woocommerce_tax_rates_save_changes',
data: {
current_class: data.current_class, current_class: data.current_class,
wc_tax_nonce: data.wc_tax_nonce, wc_tax_nonce: data.wc_tax_nonce,
changes : this.changes changes: self.changes
}, this.onSaveResponse, 'json' );
}, },
onSaveResponse: function( response, textStatus ) { success: function( response, textStatus ) {
if ( 'success' === textStatus ) { if ( 'success' === textStatus ) {
WCTaxTableModelInstance.set( 'rates', response.data.rates ); WCTaxTableModelInstance.set( 'rates', response.data.rates );
WCTaxTableModelInstance.trigger( 'change:rates' ); WCTaxTableModelInstance.trigger( 'change:rates' );
@ -77,6 +96,10 @@
WCTaxTableModelInstance.changes = {}; WCTaxTableModelInstance.changes = {};
WCTaxTableModelInstance.trigger( 'saved:rates' ); WCTaxTableModelInstance.trigger( 'saved:rates' );
} }
self.unblock();
}
});
} }
} ), } ),
WCTaxTableViewConstructor = Backbone.View.extend({ WCTaxTableViewConstructor = Backbone.View.extend({

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -101,7 +101,7 @@ class WC_Admin_Assets {
wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION ); wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION ); wp_register_script( 'flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION ); wp_register_script( 'flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );
wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone' ), WC_VERSION ); wp_register_script( 'wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array( 'jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui' ), WC_VERSION );
// Chosen is @deprecated (2.3) in favour of select2, but is registered for backwards compat // Chosen is @deprecated (2.3) in favour of select2, but is registered for backwards compat
wp_register_script( 'ajax-chosen', WC()->plugin_url() . '/assets/js/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'chosen' ), WC_VERSION ); wp_register_script( 'ajax-chosen', WC()->plugin_url() . '/assets/js/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'chosen' ), WC_VERSION );