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;
|
||||||
|
|
||||||
|
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() );
|
this.serialize( this.getDocToSave() );
|
||||||
dataPromise = this.serializing.then( function ( response ) {
|
dataPromise = this.serializing;
|
||||||
// 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;
|
|
||||||
} );
|
|
||||||
this.setMode( 'source' );
|
this.setMode( 'source' );
|
||||||
|
|
||||||
this.reloadSurface( dataPromise );
|
this.reloadSurface( dataPromise );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue