mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Fix various issues with prematurely aborting VE load
Add checks to make sure parts of the target are acutally active before trying to tear them down or use them. This fixes a couple of issues which appeared when the VE was closed before it had a chance to finish loading. Bug: 48520 Bug: 47813 Change-Id: Ide5def0e983bab49108b40008fc170957c7fc2a2
This commit is contained in:
parent
4f14fddd2b
commit
1db0ced8cc
|
@ -284,7 +284,16 @@ ve.init.mw.ViewPageTarget.prototype.deactivate = function ( override ) {
|
|||
this.resetSaveDialog();
|
||||
this.hideSaveDialog();
|
||||
this.detachSaveDialog();
|
||||
this.tearDownSurface();
|
||||
// Check we got as far as setting up the surface
|
||||
if ( this.active ) {
|
||||
this.tearDownSurface();
|
||||
} else {
|
||||
this.showPageContent();
|
||||
}
|
||||
// If there is a load in progress, abort it
|
||||
if ( this.loading ) {
|
||||
this.loading.abort();
|
||||
}
|
||||
this.showTableOfContents();
|
||||
this.deactivating = false;
|
||||
}
|
||||
|
@ -324,7 +333,8 @@ ve.init.mw.ViewPageTarget.prototype.onLoad = function ( doc ) {
|
|||
* @param {Mixed} error Thrown exception or HTTP error string
|
||||
*/
|
||||
ve.init.mw.ViewPageTarget.prototype.onLoadError = function ( response, status ) {
|
||||
if ( confirm( ve.msg( 'visualeditor-loadwarning', status ) ) ) {
|
||||
// Don't show an error if the load was manually aborted
|
||||
if ( status !== 'abort' && confirm( ve.msg( 'visualeditor-loadwarning', status ) ) ) {
|
||||
this.load();
|
||||
} else {
|
||||
this.activating = false;
|
||||
|
@ -1478,7 +1488,10 @@ ve.init.mw.ViewPageTarget.prototype.setUpToolbar = function () {
|
|||
.addClass( 've-init-mw-viewPageTarget-toolbar' )
|
||||
.insertBefore( '#firstHeading' );
|
||||
this.toolbar.$bar.slideDown( 'fast', ve.bind( function () {
|
||||
this.surface.getContext().update();
|
||||
// Check the surface wasn't torn down while the toolbar was animating
|
||||
if ( this.surface ) {
|
||||
this.surface.getContext().update();
|
||||
}
|
||||
}, this ) );
|
||||
};
|
||||
|
||||
|
|
|
@ -414,8 +414,7 @@ ve.init.mw.Target.prototype.load = function () {
|
|||
// Start loading the module immediately
|
||||
mw.loader.load( this.modules );
|
||||
// Load DOM
|
||||
this.loading = true;
|
||||
$.ajax( {
|
||||
this.loading = $.ajax( {
|
||||
'url': this.apiUrl,
|
||||
'data': {
|
||||
'action': 'visualeditor',
|
||||
|
|
Loading…
Reference in a new issue