From 7b3deab5a14ece4a46bfbfa286b56f7a97b2c1d3 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 2 Sep 2016 17:30:06 -0700 Subject: [PATCH] Disable veaction=editsource if NWE is disabled Bug: T144651 Change-Id: I6a1e42b2da267bc42adeee0c818046eab0b387f8 --- .../ve.init.mw.DesktopArticleTarget.init.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js index 6c15dbe486..5fa6bfa858 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js @@ -24,6 +24,9 @@ pageCanLoadVE, init, targetPromise, enable, tempdisable, autodisable, tabPreference, userPrefEnabled, userPrefPreferShow, initialWikitext, oldid, onlyTabIsVE, isLoading, + editModes = { + edit: 'visual' + }, active = false, targetLoaded = false, progressStep = 0, @@ -34,6 +37,10 @@ ], plugins = []; + if ( mw.config.get( 'wgVisualEditorConfig' ).enableWikitext ) { + editModes.editsource = 'source'; + } + function showLoading() { var $content, contentRect, offsetTop, windowHeight, top, bottom, middle; @@ -176,7 +183,7 @@ trackActivateStart( { type: 'page', mechanism: 'click' } ); if ( !active ) { - if ( uri.query.action !== 'edit' && uri.query.veaction !== 'edit' && uri.query.veaction !== 'editsource' ) { + if ( uri.query.action !== 'edit' && !( uri.query.veaction in editModes ) ) { if ( history.pushState ) { // Replace the current state with one that is tagged as ours, to prevent the // back button from breaking when used to exit VE. FIXME: there should be a better @@ -636,7 +643,7 @@ trackActivateStart( { type: 'section', mechanism: 'click' } ); - if ( history.pushState && uri.query.veaction !== 'edit' && uri.query.veaction !== 'editsource' ) { + if ( history.pushState && !( uri.query.veaction in editModes ) ) { // Replace the current state with one that is tagged as ours, to prevent the // back button from breaking when used to exit VE. FIXME: there should be a better // way to do this. See also similar code in the DesktopArticleTarget constructor. @@ -770,7 +777,7 @@ ) { if ( // … if on a ?veaction=edit page - ( isViewPage && ( uri.query.veaction === 'edit' || uri.query.veaction === 'editsource' ) ) || + ( isViewPage && uri.query.veaction in editModes ) || // … or if on ?action=edit in single edit mode and the user wants it ( isEditPage && @@ -800,7 +807,7 @@ type: uri.query.vesection === undefined ? 'page' : 'section', mechanism: 'url' } ); - activateTarget( uri.query.veaction === 'editsource' ? 'source' : 'visual' ); + activateTarget( editModes[ uri.query.veaction ] ); } else if ( pageCanLoadVE && userPrefEnabled ) { // Page can be edited in VE, parameters are good, user prefs are mostly good // but have visualeditor-tabs=prefer-wt? Add a keyboard shortcut to go to