From: Fomafix Date: Tue, 17 Mar 2015 18:56:47 +0000 (+0000) Subject: Update HTML title with displaytitle on live preview X-Git-Tag: 1.31.0-rc.0~12005 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=3eafa8dd37a428e56de944611ecdb7be203177d2;p=lhc%2Fweb%2Fwiklou.git Update HTML title with displaytitle on live preview Set the new global JavaScript variable 'wgEditMessage' with the name of the message. Document this global JavaScript variable in https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#mw.config after merge. Bug: T88117 Change-Id: Ida5c1d470908cefd16925bd5455758d25db02113 --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 94ed9035b4..fe96f9a1cf 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2098,6 +2098,9 @@ class EditPage { $displayTitle = $contextTitle->getPrefixedText(); } $wgOut->setPageTitle( wfMessage( $msg, $displayTitle ) ); + # Transmit the name of the message to JavaScript for live preview + # Keep Resources.php/mediawiki.action.edit.preview in sync with the possible keys + $wgOut->addJsConfigVars( 'wgEditMessage', $msg ); } /** diff --git a/resources/Resources.php b/resources/Resources.php index 0b751f63c0..2b12c7a6d3 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -1085,6 +1085,13 @@ return array( 'mediawiki.jqueryMsg', ), 'messages' => array( + // Keep the uses message keys in sync with EditPage#setHeaders + 'creating', + 'editconflict', + 'editing', + 'editingcomment', + 'editingsection', + 'pagetitle', 'otherlanguages', 'tooltip-p-lang', 'summary-preview', diff --git a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js index 84bde7d237..4c6ca12ba1 100644 --- a/resources/src/mediawiki.action/mediawiki.action.edit.preview.js +++ b/resources/src/mediawiki.action/mediawiki.action.edit.preview.js @@ -118,6 +118,13 @@ } if ( response.parse.displaytitle ) { $( '#firstHeading' ).html( response.parse.displaytitle ); + document.title = mw.msg( + 'pagetitle', + mw.msg( + mw.config.get( 'wgEditMessage', 'editing' ), + $( '#firstHeading' ).text() + ) + ); } if ( response.parse.categorieshtml ) { $( '#catlinks' ).replaceWith( response.parse.categorieshtml['*'] );