mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "Switch to the wikitext editor if VE fails to load"
This commit is contained in:
commit
0f566448ed
|
@ -698,7 +698,12 @@ ve.init.mw.DesktopArticleTarget.prototype.loadFail = function ( errorText, error
|
||||||
|
|
||||||
if ( confirmPromptMessage && confirm( confirmPromptMessage ) ) {
|
if ( confirmPromptMessage && confirm( confirmPromptMessage ) ) {
|
||||||
this.load();
|
this.load();
|
||||||
|
} else if ( !$( '#wpTextbox1' ).length ) {
|
||||||
|
// TODO: Some sort of progress bar?
|
||||||
|
this.switchToWikitextEditor( true, false );
|
||||||
} else {
|
} else {
|
||||||
|
// If we're switching from the wikitext editor, just deactivate
|
||||||
|
// don't try to switch back to it fully, that'd discard changes.
|
||||||
this.deactivate( true );
|
this.deactivate( true );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,21 +44,30 @@ ve.init.mw.DesktopWikitextArticleTarget.prototype.switchToWikitextEditor = funct
|
||||||
var dataPromise,
|
var dataPromise,
|
||||||
target = this;
|
target = this;
|
||||||
|
|
||||||
this.serialize( this.getDocToSave() );
|
if ( discardChanges ) {
|
||||||
dataPromise = this.serializing.then( function ( response ) {
|
dataPromise = mw.libs.ve.targetLoader.requestPageData(
|
||||||
// HACK
|
'source',
|
||||||
var data = response.visualeditor;
|
this.pageName,
|
||||||
data.etag = target.etag;
|
this.requestedRevId,
|
||||||
data.fromEditedState = modified;
|
this.constructor.name
|
||||||
data.notices = target.remoteNotices;
|
).then(
|
||||||
data.protectedClasses = target.protectedClasses;
|
function ( response ) { return response; },
|
||||||
data.basetimestamp = target.baseTimeStamp;
|
function () {
|
||||||
data.starttimestamp = target.startTimeStamp;
|
// TODO: Some sort of progress bar?
|
||||||
data.oldid = target.revid;
|
ve.init.mw.DesktopWikitextArticleTarget.super.prototype.switchToWikitextEditor.call(
|
||||||
return response;
|
target,
|
||||||
} );
|
discardChanges,
|
||||||
|
modified
|
||||||
|
);
|
||||||
|
// Keep everything else waiting so our error handler can do its business
|
||||||
|
return $.Deferred().promise();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
this.serialize( this.getDocToSave() );
|
||||||
|
dataPromise = this.serializing;
|
||||||
|
}
|
||||||
this.setMode( 'source' );
|
this.setMode( 'source' );
|
||||||
|
|
||||||
this.reloadSurface( dataPromise );
|
this.reloadSurface( dataPromise );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue