Esanders has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/377286 )

Change subject: Remove pageName/revision from ArticleTarget constructor
......................................................................

Remove pageName/revision from ArticleTarget constructor

Other page state is read directly, rather than passed in.
If we come up with a use case for passing this in at a later
date we can reconsider the best way to do this.

Change-Id: Iee7e608c969776b89dbb38b3b56a5177e48344af
---
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
M modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js
M modules/ve-mw/init/ve.init.mw.ArticleTarget.js
3 files changed, 10 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/86/377286/1

diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js 
b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
index af1edd4..0d50389 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
@@ -17,13 +17,8 @@
  * @param {Object} config Configuration options
  */
 ve.init.mw.DesktopArticleTarget = function VeInitMwDesktopArticleTarget( 
config ) {
-       // A workaround, as default URI does not get updated after pushState 
(bug 72334)
-       var currentUri = new mw.Uri( location.href );
-
        // Parent constructor
-       ve.init.mw.DesktopArticleTarget.super.call(
-               this, mw.config.get( 'wgRelevantPageName' ), mw.config.get( 
'wgRevisionId' ), config
-       );
+       ve.init.mw.DesktopArticleTarget.super.call( this, config );
 
        // Parent constructor bound key event handlers, but we don't want them 
bound until
        // we activate; so unbind them again
@@ -52,18 +47,17 @@
                tag: 'visualeditor'
        };
        this.scrollTop = null;
-       this.currentUri = currentUri;
        this.section = null;
        if ( $( '#wpSummary' ).length ) {
                this.initialEditSummary = $( '#wpSummary' ).val();
        } else {
-               this.initialEditSummary = currentUri.query.summary;
+               this.initialEditSummary = this.currentUri.query.summary;
        }
        this.namespaceName = mw.config.get( 'wgCanonicalNamespace' );
        this.viewUri = new mw.Uri( mw.util.getUrl( this.pageName ) );
        this.isViewPage = (
                mw.config.get( 'wgAction' ) === 'view' &&
-               currentUri.query.diff === undefined
+               this.currentUri.query.diff === undefined
        );
 
        if ( !this.isViewPage ) {
@@ -90,7 +84,7 @@
                // use the Back button to exit the editor we can restore Read 
mode. This is because we want
                // to ignore foreign states in onWindowPopState. Without this, 
the Read state is foreign.
                // FIXME: There should be a much better solution than this.
-               history.replaceState( this.popState, document.title, currentUri 
);
+               history.replaceState( this.popState, document.title, 
this.currentUri );
        }
 
        this.setupSkinTabs();
diff --git a/modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js 
b/modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js
index 463e9a1..8c76b74 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.MobileArticleTarget.js
@@ -22,9 +22,7 @@
        }, config.toolbarConfig );
 
        // Parent constructor
-       ve.init.mw.MobileArticleTarget.super.call(
-               this, mw.config.get( 'wgRelevantPageName' ), mw.config.get( 
'wgRevisionId' ), config
-       );
+       ve.init.mw.MobileArticleTarget.super.call( this, config );
 
        this.section = config.section;
 
diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js 
b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
index 127ed0d..8510b09 100644
--- a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
+++ b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
@@ -14,12 +14,9 @@
  * @extends ve.init.mw.Target
  *
  * @constructor
- * @param {string} pageName Name of target page
- * @param {string} [revisionId] If the editor should load a revision of the 
page, pass the
- *  revision id here. Defaults to loading the latest version (see #load).
  * @param {Object} [config] Configuration options
  */
-ve.init.mw.ArticleTarget = function VeInitMwArticleTarget( pageName, 
revisionId, config ) {
+ve.init.mw.ArticleTarget = function VeInitMwArticleTarget( config ) {
        config = config || {};
        config.toolbarConfig = $.extend( {
                shadow: true,
@@ -37,9 +34,11 @@
        this.docToSave = null;
        this.originalDmDoc = null;
        this.toolbarSaveButton = null;
-       this.pageName = pageName;
+       this.pageName = mw.config.get( 'wgRelevantPageName' );
        this.pageExists = mw.config.get( 'wgRelevantArticleId', 0 ) !== 0;
        this.toolbarScrollOffset = mw.config.get( 
'wgVisualEditorToolbarScrollOffset', 0 );
+       // A workaround, as default URI does not get updated after pushState 
(bug 72334)
+       this.currentUri = new mw.Uri( location.href );
        this.section = null;
        this.sectionTitle = null;
        this.editSummaryValue = null;
@@ -51,7 +50,7 @@
 
        // Sometimes we actually don't want to send a useful oldid
        // if we do, PostEdit will give us a 'page restored' message
-       this.requestedRevId = revisionId && parseInt( revisionId );
+       this.requestedRevId = mw.config.get( 'wgRevisionId' );
        this.currentRevisionId = mw.config.get( 'wgCurRevisionId' );
        this.revid = this.requestedRevId || this.currentRevisionId;
 

-- 
To view, visit https://gerrit.wikimedia.org/r/377286
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee7e608c969776b89dbb38b3b56a5177e48344af
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to