DesktopArticleTarget: Generate the original page title if needed

When switching from the old wikitext editor to VE, we stored "editing..." as
the original page title. Then restored that when saving / switching to "read".
Instead, detect if we're on top of the classic editor, and use the pagename
message to make a plausibly-correct title.

Bug: T126077
Change-Id: Ib0289de71c3ae947ca0a3e45fe1e620378689c35
This commit is contained in:
David Lynch 2016-12-13 11:12:34 -06:00
parent 16c5d489fc
commit b1aed096cb
2 changed files with 11 additions and 1 deletions

View file

@ -384,6 +384,7 @@
"mediawiki.util"
],
"messages": [
"pagetitle",
"creating",
"editing",
"lastmodifiedat",

View file

@ -64,7 +64,16 @@ ve.init.mw.DesktopArticleTarget = function VeInitMwDesktopArticleTarget( config
mw.config.get( 'wgAction' ) === 'view' &&
currentUri.query.diff === undefined
);
this.originalDocumentTitle = document.title;
if ( $( '#wpTextbox1' ).length ) {
// We're loading on top of the classic wikitext editor, so we don't
// know the "proper" page title. But we can fake it with information
// we have.
this.originalDocumentTitle = ve.msg( 'pagetitle', mw.Title.newFromText( mw.config.get( 'wgPageName' ) ).getPrefixedText() );
} else {
this.originalDocumentTitle = document.title;
}
this.tabLayout = mw.config.get( 'wgVisualEditorConfig' ).tabLayout;
this.events = new ve.init.mw.ArticleTargetEvents( this );
this.$originalContent = $( '<div>' ).addClass( 've-init-mw-desktopArticleTarget-originalContent' );