From 706b64e82c26abf82ee527c281e471ec5d28d9f5 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 17 May 2013 17:09:20 +0100 Subject: [PATCH] Change document title on surface setup/teardown Now reads "Creating/Editing Title - Sitename". Bug: 48272 Change-Id: I9dcc8ec2c37a7ff9cff6cedb7bdb1fed1bdc4deb --- VisualEditor.php | 2 ++ .../mw/targets/ve.init.mw.ViewPageTarget.js | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/VisualEditor.php b/VisualEditor.php index e9a7102fd0..66795bce12 100644 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -147,6 +147,8 @@ $wgResourceModules += array( 'copyrightpage', 'accesskey-ca-editsource', 'accesskey-ca-ve-edit', + 'creating', + 'editing', 'tooltip-ca-createsource', 'tooltip-ca-editsource', 'tooltip-ca-ve-edit', diff --git a/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js b/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js index bc140fa25f..8112f4683b 100644 --- a/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js @@ -64,6 +64,7 @@ ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() { $.client.test( ve.init.mw.ViewPageTarget.compatibility ) || 'vewhitelist' in currentUri.query ); + this.originalDocumentTitle = document.title; this.editSummaryByteLimit = 255; // Tab layout. // * add: Adds #ca-ve-edit. @@ -740,6 +741,7 @@ ve.init.mw.ViewPageTarget.prototype.setUpSurface = function ( doc ) { this.surface.initialize(); this.setUpToolbar(); this.transformPageTitle(); + this.changeDocumentTitle(); // Update UI this.hidePageContent(); this.hideSpinner(); @@ -767,6 +769,7 @@ ve.init.mw.ViewPageTarget.prototype.tearDownSurface = function () { this.hideSpinner(); this.showPageContent(); this.restorePageTitle(); + this.restoreDocumentTitle(); this.showTableOfContents(); // Destroy editor if ( this.surface ) { @@ -1539,6 +1542,27 @@ ve.init.mw.ViewPageTarget.prototype.restorePageTitle = function () { }, 1000 ); }; +/** + * Change the document title to state that we are now editing. + * + * @method + */ +ve.init.mw.ViewPageTarget.prototype.changeDocumentTitle = function () { + document.title = ve.msg( + this.pageExists ? 'editing' : 'creating', + mw.config.get( 'wgTitle' ) + ) + ' - ' + mw.config.get( 'wgSiteName' ); +}; + +/** + * Restore the original document title. + * + * @method + */ +ve.init.mw.ViewPageTarget.prototype.restoreDocumentTitle = function () { + document.title = this.originalDocumentTitle; +}; + /** * Modify page tabs to show that editing is taking place. *