jenkins-bot has submitted this change and it was merged. Change subject: Edit mode switch: Show popup next to VE switch button ......................................................................
Edit mode switch: Show popup next to VE switch button Only show if the user came from VE. Change-Id: Ic362ba534d135fca5516c8ba401f6b2a22886ff1 --- M VisualEditor.hooks.php M extension.json M modules/ve-mw/i18n/en.json M modules/ve-mw/i18n/qqq.json M modules/ve-mw/init/styles/ve.init.MWVESwitchConfirmDialog.css M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js M modules/ve-mw/init/ve.init.mw.ArticleTarget.js 8 files changed, 74 insertions(+), 8 deletions(-) Approvals: Alex Monk: Looks good to me, approved jenkins-bot: Verified diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index 7885946..f6b9f5a 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -543,6 +543,7 @@ $preferences['visualeditor-editor'] = $api; $preferences['visualeditor-hidebetawelcome'] = $api; $preferences['visualeditor-hidetabdialog'] = $api; + $preferences['visualeditor-hidesourceswitchpopup'] = $api; $preferences['visualeditor-hideusered'] = $api; $preferences['visualeditor-findAndReplace-findText'] = $api; $preferences['visualeditor-findAndReplace-replaceText'] = $api; diff --git a/extension.json b/extension.json index f109506..07fed3a 100644 --- a/extension.json +++ b/extension.json @@ -1020,6 +1020,9 @@ "visualeditor-mweditmodesource-warning-cancel", "visualeditor-mweditmodesource-warning-switch", "visualeditor-mweditmodesource-warning-switch-discard", + "visualeditor-mweditmodeve-popup-body", + "visualeditor-mweditmodeve-popup-title", + "visualeditor-mweditmodeve-showagain", "visualeditor-mweditmodeve-title", "visualeditor-mweditmodeve-tool", "visualeditor-mweditmodeve-warning", diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json index ce513eb..e89ff4d 100644 --- a/modules/ve-mw/i18n/en.json +++ b/modules/ve-mw/i18n/en.json @@ -281,6 +281,9 @@ "visualeditor-mweditmodesource-warning-cancel": "Cancel", "visualeditor-mweditmodesource-warning-switch": "Keep changes", "visualeditor-mweditmodesource-warning-switch-discard": "Discard changes", + "visualeditor-mweditmodeve-popup-body": "You can switch back to visual editing at any time by clicking on this icon.", + "visualeditor-mweditmodeve-popup-title": "You have switched to source editing", + "visualeditor-mweditmodeve-showagain": "Don't show this message again", "visualeditor-mweditmodeve-title": "Switch to visual editing?", "visualeditor-mweditmodeve-tool": "Switch to visual editing", "visualeditor-mweditmodeve-warning": "You are switching to visual editing.\nDo you want to continue?", diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json index a174dfa..49a84f0 100644 --- a/modules/ve-mw/i18n/qqq.json +++ b/modules/ve-mw/i18n/qqq.json @@ -291,6 +291,9 @@ "visualeditor-mweditmodesource-warning-cancel": "Label for the cancel button on the confirmation dialog for switching to source editing.\n{{Identical|Cancel}}", "visualeditor-mweditmodesource-warning-switch": "Label for the keep changes button on the confirmation dialog for switching to source editing.", "visualeditor-mweditmodesource-warning-switch-discard": "Label for the discard changes button on the confirmation dialog for switching to source editing.", + "visualeditor-mweditmodeve-popup-body": "Body text of popup shown after switching to source mode from visual mode", + "visualeditor-mweditmodeve-popup-title": "Title of popup shown after switching to source mode from visual mode", + "visualeditor-mweditmodeve-showagain": "Label for checkbox to not show the 'switched to visual mode' popup again", "visualeditor-mweditmodeve-title": "Title of dialog to confirm switching to visual mode.", "visualeditor-mweditmodeve-tool": "Label for tool that changes edit mode to visual editing.", "visualeditor-mweditmodeve-warning": "Warning message show before changing edit mode to visual editing. It may allow the user to keep the changes or to start source editing from scratch using the message {{msg-mw|Visualeditor-mweditmodesource-warning-switch}} and {{msg-mw|Visualeditor-mweditmodesource-warning-switch-discard}}.", diff --git a/modules/ve-mw/init/styles/ve.init.MWVESwitchConfirmDialog.css b/modules/ve-mw/init/styles/ve.init.MWVESwitchConfirmDialog.css index 7f0c3b9..9261ef9 100644 --- a/modules/ve-mw/init/styles/ve.init.MWVESwitchConfirmDialog.css +++ b/modules/ve-mw/init/styles/ve.init.MWVESwitchConfirmDialog.css @@ -12,4 +12,16 @@ .ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-iconElement-icon { opacity: 0.8; -} \ No newline at end of file +} + +.ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-popupWidget-head { + font-weight: bold; +} + +.ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-popupWidget-body > :first-child { + margin-top: 0; +} + +.ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-popupWidget-body > :last-child { + margin-bottom: 1em; +} 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 05f1226..5882c3d 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 @@ -742,15 +742,56 @@ mw.loader.load( 'ext.visualEditor.switching' ); $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-doneInitialSections', function () { mw.loader.using( 'ext.visualEditor.switching' ).done( function () { - var windowManager, editingTabDialog; - $( '.wikiEditor-ui-toolbar' ).prepend( - new OO.ui.ButtonWidget( { + var $content, windowManager, editingTabDialog, showAgainCheckbox, showAgainLayout, switchButton, + showPopup = uri.query.veswitched && !mw.user.options.get( 'visualeditor-hidesourceswitchpopup' ); + + if ( showPopup ) { + $content = $( '<p>' ).text( mw.msg( 'visualeditor-mweditmodeve-popup-body' ) ); + + if ( !mw.user.isAnon() ) { + showAgainCheckbox = new OO.ui.CheckboxInputWidget() + .on( 'change', function ( value ) { + var configValue = value ? '1' : ''; + new mw.Api().saveOption( 'visualeditor-hidesourceswitchpopup', configValue ); + mw.user.options.set( 'visualeditor-hidesourceswitchpopup', configValue ); + } ); + + showAgainLayout = new OO.ui.FieldLayout( showAgainCheckbox, { align: 'inline', label: mw.msg( 'visualeditor-mweditmodeve-showagain' ) } ); + $content = $content.add( showAgainLayout.$element ); + } + + switchButton = new OO.ui.PopupButtonWidget( { + framed: false, + icon: 'edit', + title: mw.msg( 'visualeditor-mweditmodeve-tool' ), + classes: [ 've-init-mw-desktopArticleTarget-editSwitch' ], + popup: { + label: mw.msg( 'visualeditor-mweditmodeve-popup-title' ), + $content: $content, + padded: true, + head: true + } + } ); + + // HACK: Disable the toggle behaviour + switchButton.disconnect( switchButton, { click: 'onAction' } ); + } else { + switchButton = new OO.ui.ButtonWidget( { framed: false, icon: 'edit', title: mw.msg( 'visualeditor-mweditmodeve-tool' ), classes: [ 've-init-mw-desktopArticleTarget-editSwitch' ] - } ).on( 'click', init.activateVe ).$element - ); + } ); + } + + switchButton.on( 'click', init.activateVe ); + + $( '.wikiEditor-ui-toolbar' ).prepend( switchButton.$element ); + + if ( showPopup ) { + // Show the popup after appending + switchButton.getPopup().toggle( true ); + } // Duplicate of this code in ve.init.mw.DesktopArticleTarget.js if ( $( '#ca-edit' ).hasClass( 'visualeditor-showtabdialog' ) ) { 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 54dc82e..49bbf47 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js @@ -1390,7 +1390,7 @@ this.docToSave || this.getSurface().getDom(), function ( wikitext ) { ve.track( 'mwedit.abort', { type: 'switchwith', mechanism: 'navigate' } ); - target.submitWithSaveFields( { wpDiff: 1, veswitched: 1 }, wikitext ); + target.submitWithSaveFields( { wpDiff: 1 }, wikitext ); } ); } diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js index 73e5f26..d076852 100644 --- a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js +++ b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js @@ -49,7 +49,10 @@ this.pageDeletedWarning = false; this.editToken = mw.user.tokens.get( 'editToken' ); this.submitUrl = ( new mw.Uri( mw.util.getUrl( this.pageName ) ) ) - .extend( { action: 'submit' } ); + .extend( { + action: 'submit', + veswitched: 1 + } ); this.events = { track: $.noop, trackActivationStart: $.noop, trackActivationComplete: $.noop }; this.preparedCacheKeyPromise = null; -- To view, visit https://gerrit.wikimedia.org/r/252345 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic362ba534d135fca5516c8ba401f6b2a22886ff1 Gerrit-PatchSet: 12 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Alex Monk <kren...@gmail.com> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits