[MediaWiki-commits] [Gerrit] Conditionally add switch buttons - change (mediawiki...Flow)
jenkins-bot has submitted this change and it was merged. Change subject: Conditionally add switch buttons .. Conditionally add switch buttons There should be no switch button if the other editor isn't supported. Since the switch-button under wikitext textarea may not be added, I also had to change how that border is added. I've added it on the parent div, where textarea & switcher are both children of. With or without the switcher, there'll be a complete border. I'm not too happy with the editors depending on one another (that sort of logic should probably be outside of editors) but hey, it works. VE depends on none through Resources.php. None depends in VE in JS. I couldn't add VE as a dependency because VE has no mobile target. Since VE won't work on mobile, the resource won't be able to load in JS & the switcher won't be attached. Meanwhile also slightly cleaned up some jsdoc Bug: T94676 Change-Id: Ia4a0d4e2b10564afe68a567fd5fa93b20324b7dd (cherry picked from commit 3e0cbc544e825a2f7ba3b9952669d4d1ed1a1ac7) --- M Resources.php M handlebars/flow_editor_switcher.partial.handlebars M i18n/en.json M i18n/qqq.json M modules/editor/editors/ext.flow.editors.none.js M modules/editor/editors/visualeditor/ext.flow.editors.visualeditor.js M modules/editor/editors/visualeditor/mw.flow.ve.Target.js M modules/editor/ext.flow.editor.js M modules/engine/components/board/features/flow-board-switcheditor.js M modules/styles/board/editor-switcher.less 10 files changed, 73 insertions(+), 61 deletions(-) Approvals: EBernhardson: Looks good to me, approved jenkins-bot: Verified diff --git a/Resources.php b/Resources.php index 1e39a70..9511d0a 100644 --- a/Resources.php +++ b/Resources.php @@ -239,6 +239,7 @@ "flow-board-header-browse-topics-link", // editor switching "flow-wikitext-editor-help", + "flow-wikitext-editor-help-and-preview", "flow-wikitext-editor-help-uses-wikitext", "flow-wikitext-editor-help-preview-the-result", ), @@ -478,6 +479,7 @@ 'site', 'user', 'mediawiki.api', + 'ext.flow.editors.none', // needed to figure out if that editor is supported, for switch button ), 'messages' => array( 'flow-ve-mention-context-item-label', diff --git a/handlebars/flow_editor_switcher.partial.handlebars b/handlebars/flow_editor_switcher.partial.handlebars index ad0f49c..812b093 100644 --- a/handlebars/flow_editor_switcher.partial.handlebars +++ b/handlebars/flow_editor_switcher.partial.handlebars @@ -3,15 +3,16 @@ {{! this message is manually constructed in ext.flow.editors.none.js !}} {{html help_text}} - - > - + {{#if enable_switcher}} + + > + + {{/if}} diff --git a/i18n/en.json b/i18n/en.json index 7099121..a24107c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -540,7 +540,8 @@ "flow-ve-mention-tool-title": "Mention a user", "flow-ve-mention-template": "ping", "flow-ve-mention-inspector-invalid-user": "The username '$1' is not registered.", - "flow-wikitext-editor-help": "Wikitext $1 and you can $2 anytime.", + "flow-wikitext-editor-help": "Wikitext $1.", + "flow-wikitext-editor-help-and-preview": "Wikitext $1 and you can $2 anytime.", "flow-wikitext-editor-help-uses-wikitext": "[[mw:Help:Formatting|uses markup]]", "flow-wikitext-editor-help-preview-the-result": "preview the result", "flow-wikitext-switch-editor-tooltip": "Switch to VisualEditor", diff --git a/i18n/qqq.json b/i18n/qqq.json index 9460e51..d35b753 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -542,7 +542,8 @@ "flow-ve-mention-tool-title": "Title text for the user mention tool on Flow's VisualEditor toolbar.", "flow-ve-mention-template": "Name of on-wiki template used for user mentions. The template should accept a call in the form {{templatename|Username}}, to mention Username. It will use content language.", "flow-ve-mention-inspector-invalid-user": "Error shown when the poster attempts to mention a user that does not exist. Parameters:\n$1: Username. The username is not registered; thus, gender is unknown.", - "flow-wikitext-editor-help": "Text shown at the bottom of a wikitext editing box", + "flow-wikitext-editor-help": "Text shown at the bottom of a wikitext editing box when visualeditor is not available to switch to", + "flow-wikitext-editor-help-and-preview": "Text shown at the bottom of a wikitext editing box when visualeditor
[MediaWiki-commits] [Gerrit] Conditionally add switch buttons - change (mediawiki...Flow)
EBernhardson has uploaded a new change for review. https://gerrit.wikimedia.org/r/201358 Change subject: Conditionally add switch buttons .. Conditionally add switch buttons There should be no switch button if the other editor isn't supported. Since the switch-button under wikitext textarea may not be added, I also had to change how that border is added. I've added it on the parent div, where textarea & switcher are both children of. With or without the switcher, there'll be a complete border. I'm not too happy with the editors depending on one another (that sort of logic should probably be outside of editors) but hey, it works. VE depends on none through Resources.php. None depends in VE in JS. I couldn't add VE as a dependency because VE has no mobile target. Since VE won't work on mobile, the resource won't be able to load in JS & the switcher won't be attached. Meanwhile also slightly cleaned up some jsdoc Bug: T94676 Change-Id: Ia4a0d4e2b10564afe68a567fd5fa93b20324b7dd (cherry picked from commit 3e0cbc544e825a2f7ba3b9952669d4d1ed1a1ac7) --- M Resources.php M handlebars/flow_editor_switcher.partial.handlebars M i18n/en.json M i18n/qqq.json M modules/editor/editors/ext.flow.editors.none.js M modules/editor/editors/visualeditor/ext.flow.editors.visualeditor.js M modules/editor/editors/visualeditor/mw.flow.ve.Target.js M modules/editor/ext.flow.editor.js M modules/engine/components/board/features/flow-board-switcheditor.js M modules/styles/board/editor-switcher.less 10 files changed, 73 insertions(+), 61 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/58/201358/1 diff --git a/Resources.php b/Resources.php index 1e39a70..9511d0a 100644 --- a/Resources.php +++ b/Resources.php @@ -239,6 +239,7 @@ "flow-board-header-browse-topics-link", // editor switching "flow-wikitext-editor-help", + "flow-wikitext-editor-help-and-preview", "flow-wikitext-editor-help-uses-wikitext", "flow-wikitext-editor-help-preview-the-result", ), @@ -478,6 +479,7 @@ 'site', 'user', 'mediawiki.api', + 'ext.flow.editors.none', // needed to figure out if that editor is supported, for switch button ), 'messages' => array( 'flow-ve-mention-context-item-label', diff --git a/handlebars/flow_editor_switcher.partial.handlebars b/handlebars/flow_editor_switcher.partial.handlebars index ad0f49c..812b093 100644 --- a/handlebars/flow_editor_switcher.partial.handlebars +++ b/handlebars/flow_editor_switcher.partial.handlebars @@ -3,15 +3,16 @@ {{! this message is manually constructed in ext.flow.editors.none.js !}} {{html help_text}} - - > - + {{#if enable_switcher}} + + > + + {{/if}} diff --git a/i18n/en.json b/i18n/en.json index 7099121..a24107c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -540,7 +540,8 @@ "flow-ve-mention-tool-title": "Mention a user", "flow-ve-mention-template": "ping", "flow-ve-mention-inspector-invalid-user": "The username '$1' is not registered.", - "flow-wikitext-editor-help": "Wikitext $1 and you can $2 anytime.", + "flow-wikitext-editor-help": "Wikitext $1.", + "flow-wikitext-editor-help-and-preview": "Wikitext $1 and you can $2 anytime.", "flow-wikitext-editor-help-uses-wikitext": "[[mw:Help:Formatting|uses markup]]", "flow-wikitext-editor-help-preview-the-result": "preview the result", "flow-wikitext-switch-editor-tooltip": "Switch to VisualEditor", diff --git a/i18n/qqq.json b/i18n/qqq.json index 9460e51..d35b753 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -542,7 +542,8 @@ "flow-ve-mention-tool-title": "Title text for the user mention tool on Flow's VisualEditor toolbar.", "flow-ve-mention-template": "Name of on-wiki template used for user mentions. The template should accept a call in the form {{templatename|Username}}, to mention Username. It will use content language.", "flow-ve-mention-inspector-invalid-user": "Error shown when the poster attempts to mention a user that does not exist. Parameters:\n$1: Username. The username is not registered; thus, gender is unknown.", - "flow-wikitext-editor-help": "Text shown at the bottom of a wikitext editing box", + "flow-wikitext-editor-help": "Text shown at the bottom of a wikitext editing box when visualeditor is not available to switch to", + "flow-wikitext-editor-help-and-preview": "Text shown at the
[MediaWiki-commits] [Gerrit] Conditionally add switch buttons - change (mediawiki...Flow)
jenkins-bot has submitted this change and it was merged. Change subject: Conditionally add switch buttons .. Conditionally add switch buttons There should be no switch button if the other editor isn't supported. Since the switch-button under wikitext textarea may not be added, I also had to change how that border is added. I've added it on the parent div, where textarea & switcher are both children of. With or without the switcher, there'll be a complete border. I'm not too happy with the editors depending on one another (that sort of logic should probably be outside of editors) but hey, it works. VE depends on none through Resources.php. None depends in VE in JS. I couldn't add VE as a dependency because VE has no mobile target. Since VE won't work on mobile, the resource won't be able to load in JS & the switcher won't be attached. Meanwhile also slightly cleaned up some jsdoc Bug: T94676 Change-Id: Ia4a0d4e2b10564afe68a567fd5fa93b20324b7dd --- M Resources.php M handlebars/flow_editor_switcher.partial.handlebars M i18n/en.json M i18n/qqq.json M modules/editor/editors/ext.flow.editors.none.js M modules/editor/editors/visualeditor/ext.flow.editors.visualeditor.js M modules/editor/editors/visualeditor/mw.flow.ve.Target.js M modules/editor/ext.flow.editor.js M modules/engine/components/board/features/flow-board-switcheditor.js M modules/styles/board/editor-switcher.less 10 files changed, 73 insertions(+), 61 deletions(-) Approvals: EBernhardson: Looks good to me, approved jenkins-bot: Verified diff --git a/Resources.php b/Resources.php index 1e39a70..9511d0a 100644 --- a/Resources.php +++ b/Resources.php @@ -239,6 +239,7 @@ "flow-board-header-browse-topics-link", // editor switching "flow-wikitext-editor-help", + "flow-wikitext-editor-help-and-preview", "flow-wikitext-editor-help-uses-wikitext", "flow-wikitext-editor-help-preview-the-result", ), @@ -478,6 +479,7 @@ 'site', 'user', 'mediawiki.api', + 'ext.flow.editors.none', // needed to figure out if that editor is supported, for switch button ), 'messages' => array( 'flow-ve-mention-context-item-label', diff --git a/handlebars/flow_editor_switcher.partial.handlebars b/handlebars/flow_editor_switcher.partial.handlebars index ad0f49c..812b093 100644 --- a/handlebars/flow_editor_switcher.partial.handlebars +++ b/handlebars/flow_editor_switcher.partial.handlebars @@ -3,15 +3,16 @@ {{! this message is manually constructed in ext.flow.editors.none.js !}} {{html help_text}} - - > - + {{#if enable_switcher}} + + > + + {{/if}} diff --git a/i18n/en.json b/i18n/en.json index 85032a9..89bc118 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -540,7 +540,8 @@ "flow-ve-mention-tool-title": "Mention a user", "flow-ve-mention-template": "ping", "flow-ve-mention-inspector-invalid-user": "The username '$1' is not registered.", - "flow-wikitext-editor-help": "Wikitext $1 and you can $2 anytime.", + "flow-wikitext-editor-help": "Wikitext $1.", + "flow-wikitext-editor-help-and-preview": "Wikitext $1 and you can $2 anytime.", "flow-wikitext-editor-help-uses-wikitext": "[[mw:Help:Formatting|uses markup]]", "flow-wikitext-editor-help-preview-the-result": "preview the result", "flow-wikitext-switch-editor-tooltip": "Switch to VisualEditor", diff --git a/i18n/qqq.json b/i18n/qqq.json index 91c52d2..4f1c240 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -542,7 +542,8 @@ "flow-ve-mention-tool-title": "Title text for the user mention tool on Flow's VisualEditor toolbar.", "flow-ve-mention-template": "Name of on-wiki template used for user mentions. The template should accept a call in the form {{templatename|Username}}, to mention Username. It will use content language.", "flow-ve-mention-inspector-invalid-user": "Error shown when the poster attempts to mention a user that does not exist. Parameters:\n$1: Username. The username is not registered; thus, gender is unknown.", - "flow-wikitext-editor-help": "Text shown at the bottom of a wikitext editing box", + "flow-wikitext-editor-help": "Text shown at the bottom of a wikitext editing box when visualeditor is not available to switch to", + "flow-wikitext-editor-help-and-preview": "Text shown at the bottom of a wikitext editing box when visualeditor is available to switch to", "flow-wikitext-editor-help-uses-
[MediaWiki-commits] [Gerrit] Conditionally add switch buttons - change (mediawiki...Flow)
Matthias Mullie has uploaded a new change for review. https://gerrit.wikimedia.org/r/201153 Change subject: Conditionally add switch buttons .. Conditionally add switch buttons There should be no switch button if the other editor isn't supported. Since the switch-button under wikitext textarea may not be added, I also had to change how that border is added. I've added it on the parent div, where textarea & switcher are both children of. With or without the switcher, there'll be a complete border. Meanwhile also slightly cleaned up some jsdoc Bug: T94676 Change-Id: Ia4a0d4e2b10564afe68a567fd5fa93b20324b7dd --- M Resources.php M modules/editor/editors/ext.flow.editors.none.js M modules/editor/editors/visualeditor/mw.flow.ve.Target.js M modules/editor/ext.flow.editor.js M modules/engine/components/board/features/flow-board-switcheditor.js M modules/styles/board/editor-switcher.less 6 files changed, 31 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/53/201153/1 diff --git a/Resources.php b/Resources.php index 1e39a70..e79c054 100644 --- a/Resources.php +++ b/Resources.php @@ -439,6 +439,10 @@ 'scripts' => array( 'editor/editors/ext.flow.editors.none.js', ), + 'dependencies' => array( + 'ext.flow.editors.visualeditor', // needed to figure out if that editor is supported, for switch button + // @todo this should be refactored - I'd prefer editors to not have to know about each other + ), 'messages' => array( 'flow-wikitext-switch-editor-tooltip', ), @@ -478,6 +482,7 @@ 'site', 'user', 'mediawiki.api', + 'ext.flow.editors.none', // needed to figure out if that editor is supported, for switch button ), 'messages' => array( 'flow-ve-mention-context-item-label', diff --git a/modules/editor/editors/ext.flow.editors.none.js b/modules/editor/editors/ext.flow.editors.none.js index 06c33de..5e66339 100644 --- a/modules/editor/editors/ext.flow.editors.none.js +++ b/modules/editor/editors/ext.flow.editors.none.js @@ -121,6 +121,11 @@ }; mw.flow.editors.none.prototype.attachSwitcher = function() { + if ( !mw.flow.editors.visualeditor.static.isSupported() ) { + // don't attach switcher is VE isn't supported + return; + } + var board = mw.flow.getPrototypeMethod( 'board', 'getInstanceByElement' )( this.$node ), $preview = $( '' ).attr( { href: '#', diff --git a/modules/editor/editors/visualeditor/mw.flow.ve.Target.js b/modules/editor/editors/visualeditor/mw.flow.ve.Target.js index 8e8dc15..2925164 100644 --- a/modules/editor/editors/visualeditor/mw.flow.ve.Target.js +++ b/modules/editor/editors/visualeditor/mw.flow.ve.Target.js @@ -37,9 +37,11 @@ { include: [ 'flowMention' ] } ]; - mw.flow.ve.Target.static.actionGroups = [ - { include: [ 'flowSwitchEditor' ] } - ]; + if ( mw.flow.editors.none.static.isSupported() ) { + mw.flow.ve.Target.static.actionGroups = [ + { include: [ 'flowSwitchEditor' ] } + ]; + } // Methods diff --git a/modules/editor/ext.flow.editor.js b/modules/editor/ext.flow.editor.js index 351fc7c..95af71d 100644 --- a/modules/editor/ext.flow.editor.js +++ b/modules/editor/ext.flow.editor.js @@ -192,6 +192,7 @@ * and call switchEditor for each iteration. * * @param {jQuery} $node +* @param {string} desiredEditor * @return {jQuery.Promise} Will resolve once editor instance is loaded */ switchEditor: function ( $node, desiredEditor ) { diff --git a/modules/engine/components/board/features/flow-board-switcheditor.js b/modules/engine/components/board/features/flow-board-switcheditor.js index b68de6f..fc3682d 100644 --- a/modules/engine/components/board/features/flow-board-switcheditor.js +++ b/modules/engine/components/board/features/flow-board-switcheditor.js @@ -30,8 +30,8 @@ * code for switching, so this is only run by clicking the switch button from 'none'. * If we add more editors later this will have to be revisited. * -* @param {Event} -* @returns {$.Promise} +* @param {Event} event +* @returns {jQuery.Promise} */ FlowBoardComponentSwitchEditorFeatureMixin.UI.events.interactiveHandlers.switchEditor = function ( event ) { var $this = $(