mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Don't try to prefix browser title if a custom message is incompatible
Some wikis customize the 'pagetitle' in ways that are not compatible with the client-side message parser. Depends-On: If1979da12777e4ee4e97937640fc5e6176f9b5fe Bug: T317600 Change-Id: Ie7c1813552582e10de9e57cd8d772c2134146289
This commit is contained in:
parent
4b661a1fcd
commit
09fec16583
|
@ -985,24 +985,32 @@ ve.init.mw.DesktopArticleTarget.prototype.teardownToolbar = function () {
|
||||||
*/
|
*/
|
||||||
ve.init.mw.DesktopArticleTarget.prototype.changeDocumentTitle = function () {
|
ve.init.mw.DesktopArticleTarget.prototype.changeDocumentTitle = function () {
|
||||||
var title = mw.Title.newFromText( this.getPageName() );
|
var title = mw.Title.newFromText( this.getPageName() );
|
||||||
|
var pageTitleMsg = mw.message( 'pagetitle',
|
||||||
// Use the real title if we loaded a view page, otherwise reconstruct it
|
|
||||||
this.originalDocumentTitle = this.isViewPage ? document.title : ve.msg( 'pagetitle', title.getPrefixedText() );
|
|
||||||
|
|
||||||
// Reconstruct an edit title
|
|
||||||
document.title = ve.msg( 'pagetitle',
|
|
||||||
ve.msg(
|
ve.msg(
|
||||||
this.pageExists ? 'editing' : 'creating',
|
this.pageExists ? 'editing' : 'creating',
|
||||||
title.getPrefixedText()
|
title.getPrefixedText()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// T317600
|
||||||
|
if ( pageTitleMsg.isParseable() ) {
|
||||||
|
// Use the real title if we loaded a view page, otherwise reconstruct it
|
||||||
|
this.originalDocumentTitle = this.isViewPage ? document.title : ve.msg( 'pagetitle', title.getPrefixedText() );
|
||||||
|
// Reconstruct an edit title
|
||||||
|
document.title = pageTitleMsg.text();
|
||||||
|
} else {
|
||||||
|
mw.log.warn( 'VisualEditor: MediaWiki:Pagetitle contains unsupported syntax. ' +
|
||||||
|
'https://www.mediawiki.org/wiki/Manual:Messages_API#Feature_support_in_JavaScript' );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore the original document title.
|
* Restore the original document title.
|
||||||
*/
|
*/
|
||||||
ve.init.mw.DesktopArticleTarget.prototype.restoreDocumentTitle = function () {
|
ve.init.mw.DesktopArticleTarget.prototype.restoreDocumentTitle = function () {
|
||||||
document.title = this.originalDocumentTitle;
|
if ( this.originalDocumentTitle ) {
|
||||||
|
document.title = this.originalDocumentTitle;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue