Update HTML title with displaytitle on live preview
authorFomafix <fomafix@googlemail.com>
Tue, 17 Mar 2015 18:56:47 +0000 (18:56 +0000)
committerTheDJ <hartman.wiki@gmail.com>
Tue, 24 Mar 2015 22:34:18 +0000 (22:34 +0000)
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

includes/EditPage.php
resources/Resources.php
resources/src/mediawiki.action/mediawiki.action.edit.preview.js

index 94ed903..fe96f9a 100644 (file)
@@ -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 );
        }
 
        /**
index 0b751f6..2b12c7a 100644 (file)
@@ -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',
index 84bde7d..4c6ca12 100644 (file)
                                }
                                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['*'] );