Merge "Switch to the wikitext editor if VE fails to load"

This commit is contained in:
jenkins-bot 2016-10-20 23:01:01 +00:00 committed by Gerrit Code Review
commit 0f566448ed
2 changed files with 28 additions and 14 deletions

View file

@ -698,7 +698,12 @@ ve.init.mw.DesktopArticleTarget.prototype.loadFail = function ( errorText, error
if ( confirmPromptMessage && confirm( confirmPromptMessage ) ) {
this.load();
} else if ( !$( '#wpTextbox1' ).length ) {
// TODO: Some sort of progress bar?
this.switchToWikitextEditor( true, false );
} 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 );
}
};

View file

@ -44,21 +44,30 @@ ve.init.mw.DesktopWikitextArticleTarget.prototype.switchToWikitextEditor = funct
var dataPromise,
target = this;
this.serialize( this.getDocToSave() );
dataPromise = this.serializing.then( function ( response ) {
// HACK
var data = response.visualeditor;
data.etag = target.etag;
data.fromEditedState = modified;
data.notices = target.remoteNotices;
data.protectedClasses = target.protectedClasses;
data.basetimestamp = target.baseTimeStamp;
data.starttimestamp = target.startTimeStamp;
data.oldid = target.revid;
return response;
} );
if ( discardChanges ) {
dataPromise = mw.libs.ve.targetLoader.requestPageData(
'source',
this.pageName,
this.requestedRevId,
this.constructor.name
).then(
function ( response ) { return response; },
function () {
// TODO: Some sort of progress bar?
ve.init.mw.DesktopWikitextArticleTarget.super.prototype.switchToWikitextEditor.call(
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.reloadSurface( dataPromise );
};