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 ) ) { 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 );
} }
}; };

View file

@ -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 );
}; };