[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[master]: (attempt to) make NWE work with SET

2016-09-20 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: (attempt to) make NWE work with SET
..


(attempt to) make NWE work with SET

Ugh.

Bug: T143578
Change-Id: I71e08508eb0914be9d624202b13a4369df512b80
---
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
1 file changed, 33 insertions(+), 4 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



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 6bf9527..e7a207e 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
@@ -764,7 +764,8 @@
var showWikitextWelcome = true,
isLoggedIn = !mw.user.isAnon(),
prefSaysShowWelcome = isLoggedIn && 
!mw.user.options.get( 'visualeditor-hidebetawelcome' ),
-   urlSaysHideWelcome = 'hidewelcomedialog' in new mw.Uri( 
location.href ).query;
+   urlSaysHideWelcome = 'hidewelcomedialog' in new mw.Uri( 
location.href ).query,
+   action = 'edit';
 
if ( uri.query.action === 'edit' && $( '#wpTextbox1' ).length ) 
{
initialWikitext = $( '#wpTextbox1' ).textSelection( 
'getContents' );
@@ -784,7 +785,7 @@
// TODO: other params too? See identical list 
in VisualEditor.hooks.php)
) {
if (
-   // … if on a ?veaction=edit page
+   // … if on a ?veaction=edit/editsource 
page
( isViewPage && uri.query.veaction in 
editModes ) ||
// … or if on ?action=edit in single 
edit mode and the user wants it
(
@@ -802,8 +803,19 @@

mw.config.get( 'wgAction' ) !== 'submit'
) ||
(
+   
tabPreference === 'prefer-wte' &&
+   
conf.enableWikitext &&
+   
mw.user.options.get( 'visualeditor-newwikitext' )
+   ) ||
+   (

tabPreference === 'remember-last' &&
-   
getLastEditor() !== 'wikitext'
+   
(
+   
getLastEditor() !== 'wikitext' ||
+   
(
+   
conf.enableWikitext &&
+   
mw.user.options.get( 'visualeditor-newwikitext' )
+   
)
+   
)
)
)
)
@@ -815,7 +827,24 @@
type: uri.query.vesection === 
undefined ? 'page' : 'section',
mechanism: 'url'
} );
-   activateTarget( editModes[ 
uri.query.veaction ] );
+   if ( isViewPage && uri.query.veaction 
in editModes ) {
+   activateTarget( editModes[ 
uri.query.veaction ] );
+   } else {
+   if (
+   conf.enableWikitext &&
+   mw.user.options.get( 
'visualeditor-newwikitext' ) &&
+   (
+   tabPreferen

[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[master]: (attempt to) make NWE work with SET

2016-09-16 Thread Alex Monk (Code Review)
Alex Monk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311207

Change subject: (attempt to) make NWE work with SET
..

(attempt to) make NWE work with SET

Ugh.

Bug: T143578
Change-Id: I71e08508eb0914be9d624202b13a4369df512b80
---
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
1 file changed, 33 insertions(+), 4 deletions(-)


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

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 6bf9527..e7a207e 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
@@ -764,7 +764,8 @@
var showWikitextWelcome = true,
isLoggedIn = !mw.user.isAnon(),
prefSaysShowWelcome = isLoggedIn && 
!mw.user.options.get( 'visualeditor-hidebetawelcome' ),
-   urlSaysHideWelcome = 'hidewelcomedialog' in new mw.Uri( 
location.href ).query;
+   urlSaysHideWelcome = 'hidewelcomedialog' in new mw.Uri( 
location.href ).query,
+   action = 'edit';
 
if ( uri.query.action === 'edit' && $( '#wpTextbox1' ).length ) 
{
initialWikitext = $( '#wpTextbox1' ).textSelection( 
'getContents' );
@@ -784,7 +785,7 @@
// TODO: other params too? See identical list 
in VisualEditor.hooks.php)
) {
if (
-   // … if on a ?veaction=edit page
+   // … if on a ?veaction=edit/editsource 
page
( isViewPage && uri.query.veaction in 
editModes ) ||
// … or if on ?action=edit in single 
edit mode and the user wants it
(
@@ -802,8 +803,19 @@

mw.config.get( 'wgAction' ) !== 'submit'
) ||
(
+   
tabPreference === 'prefer-wte' &&
+   
conf.enableWikitext &&
+   
mw.user.options.get( 'visualeditor-newwikitext' )
+   ) ||
+   (

tabPreference === 'remember-last' &&
-   
getLastEditor() !== 'wikitext'
+   
(
+   
getLastEditor() !== 'wikitext' ||
+   
(
+   
conf.enableWikitext &&
+   
mw.user.options.get( 'visualeditor-newwikitext' )
+   
)
+   
)
)
)
)
@@ -815,7 +827,24 @@
type: uri.query.vesection === 
undefined ? 'page' : 'section',
mechanism: 'url'
} );
-   activateTarget( editModes[ 
uri.query.veaction ] );
+   if ( isViewPage && uri.query.veaction 
in editModes ) {
+   activateTarget( editModes[ 
uri.query.veaction ] );
+   } else {
+   if (
+   conf.enableWikitext &&
+   mw.user.options.get( 
'visualeditor-newwikitext' ) &&
+   (
+