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 = $( '<a>' ).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 = $( this ), @@ -50,7 +50,7 @@ /** * Hide wikitext editor switchEditor controls on load if visualeditor is not available. * - * @param {jQuery} event + * @param {jQuery} $switcher */ FlowBoardComponentSwitchEditorFeatureMixin.UI.events.loadHandlers.requiresVisualEditor = function ( $switcher ) { if ( mw.config.get( 'wgFlowEditorList' ).indexOf( 'visualeditor' ) === -1 ) { diff --git a/modules/styles/board/editor-switcher.less b/modules/styles/board/editor-switcher.less index 5c52d56..d1cdd18 100644 --- a/modules/styles/board/editor-switcher.less +++ b/modules/styles/board/editor-switcher.less @@ -16,18 +16,20 @@ } .flow-editor { - .flow-switcher-controls { - background-color: white; + // because we're attaching switcher controls below the textarea & we + // want them to look unified with the textarea, we'll have to take away + // it's border and re-apply on the parent node that contains both + &.flow-editor-none { border: 1px solid @colorFieldBorder; - border-top: 0; - padding: .25em; - } - textarea { - border-bottom: 0; - border-bottom-left-radius: 0; - border-bottom-right-radius: 0; - margin-bottom: 0; + textarea { + border: 0; + } + + .flow-switcher-controls { + background-color: white; + padding: .25em; + } } // would prefer textarea:not(.flow-input-compressed) above, but ie8 wont do it -- To view, visit https://gerrit.wikimedia.org/r/201153 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia4a0d4e2b10564afe68a567fd5fa93b20324b7dd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits