Merge "For the mode switch tool, show a different tooltip when disabled"

This commit is contained in:
jenkins-bot 2017-02-24 19:23:53 +00:00 committed by Gerrit Code Review
commit a629b62b43
4 changed files with 18 additions and 2 deletions

View file

@ -319,7 +319,8 @@
"tooltip-ca-editsource",
"tooltip-ca-ve-edit",
"visualeditor-ca-editsource-section",
"visualeditor-mweditmodeve-tool"
"visualeditor-mweditmodeve-tool",
"visualeditor-mweditmodeve-tool-unavailable"
],
"position": "top"
},
@ -1144,6 +1145,7 @@
"visualeditor-mweditmodeve-showagain",
"visualeditor-mweditmodeve-title",
"visualeditor-mweditmodeve-tool",
"visualeditor-mweditmodeve-tool-unavailable",
"visualeditor-mweditmodeve-warning",
"visualeditor-mweditmodewt-popup-body",
"visualeditor-mweditmodewt-popup-title",

View file

@ -285,6 +285,7 @@
"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-tool-unavailable": "Visual editing is not available here",
"visualeditor-mweditmodeve-warning": "You are switching to visual editing.\nDo you want to continue?",
"visualeditor-mweditmodewt-popup-body": "You can switch back to source editing at any time by clicking on this icon.",
"visualeditor-mweditmodewt-popup-title": "You have switched to visual editing",

View file

@ -298,6 +298,7 @@
"visualeditor-mweditmodeve-showagain": "Label for the checkboxes to not show one of the 'switched to visual mode' or 'switched to source mode' popups 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-tool-unavailable": "Label for tool that changes edit mode to visual editing when it is not available.",
"visualeditor-mweditmodeve-warning": "Warning message show before changing edit mode to visual editing. It may allow the user to keep the changes using the message {{msg-mw|Visualeditor-mweditmodesource-warning-switch}}, or instaed that they'd need to start source editing from scratch using {{msg-mw|Visualeditor-mweditmodesource-warning-switch-discard}}.",
"visualeditor-mweditmodewt-popup-body": "Body text of popup shown after switching to visual mode from source mode",
"visualeditor-mweditmodewt-popup-title": "Title of popup shown after switching to visual mode from source mode",

View file

@ -131,9 +131,21 @@ ve.ui.MWEditModeVisualTool.prototype.onSelect = function () {
* @inheritdoc
*/
ve.ui.MWEditModeVisualTool.prototype.onUpdateState = function () {
var isVisualModeNowAvailable = ve.init.target.isModeAvailable( 'visual' );
// Parent method
ve.ui.MWEditModeVisualTool.super.prototype.onUpdateState.apply( this, arguments );
this.setDisabled( !ve.init.target.isModeAvailable( 'visual' ) );
// Cached for performance
if ( this.isVisualModeAvailable !== isVisualModeNowAvailable ) {
this.isVisualModeAvailable = isVisualModeNowAvailable;
this.setDisabled( !isVisualModeNowAvailable );
this.setTitle( OO.ui.msg(
isVisualModeNowAvailable ?
'visualeditor-mweditmodeve-tool' :
'visualeditor-mweditmodeve-tool-unavailable'
) );
}
};
ve.ui.toolFactory.register( ve.ui.MWEditModeVisualTool );