(bug 37837) Spinner of death on error

* Reusing deactivate method to recover from load error
* Made deactivate resilient to some properties not being set yet (so we can call it on load error)
* Restoring save dialog state after save error

Change-Id: I6a697dc6bddeebecf4e2ab26805bee9f3754c714
This commit is contained in:
Trevor Parscal 2012-12-06 14:18:56 -08:00
parent aebc22f0ed
commit 4737727f34

View file

@ -201,7 +201,7 @@ ve.init.mw.ViewPageTarget.prototype.activate = function () {
* @method
*/
ve.init.mw.ViewPageTarget.prototype.deactivate = function ( override ) {
if ( this.active && !this.deactivating ) {
if ( override || ( this.active && !this.deactivating ) ) {
if (
override ||
!this.surface.getModel().getHistory().length ||
@ -256,11 +256,8 @@ ve.init.mw.ViewPageTarget.prototype.onLoadError = function ( response, status )
this.load();
} else {
this.activating = false;
this.restoreSkinTabs();
this.hideSpinner();
this.showTableOfContents();
this.showPageContent();
this.restorePageTitle();
// User interface changes
this.deactivate( true );
}
};
@ -311,6 +308,8 @@ ve.init.mw.ViewPageTarget.prototype.onSave = function ( html ) {
ve.init.mw.ViewPageTarget.prototype.onSaveError = function ( response, status ) {
// TODO: Don't use alert.
alert( ve.msg( 'visualeditor-saveerror', status ) );
this.unlockSaveDialogSaveButton();
this.$saveDialogLoadingIcon.hide();
};
/**
@ -524,16 +523,20 @@ ve.init.mw.ViewPageTarget.prototype.tearDownSurface = function () {
// Reset tabs
this.restoreSkinTabs();
// Update UI
this.$document.blur();
this.$document = null;
if ( this.$document ) {
this.$document.blur();
this.$document = null;
}
this.detachToolbar();
this.hideSpinner();
this.showPageContent();
this.restorePageTitle();
this.showTableOfContents();
// Destroy editor
this.surface.destroy();
this.surface = null;
if ( this.surface ) {
this.surface.destroy();
this.surface = null;
}
this.active = false;
};