Merge "Show a different label for the current mode in the editor mode selector"

This commit is contained in:
jenkins-bot 2017-04-21 15:56:04 +00:00 committed by Gerrit Code Review
commit 67d6ac38e6
4 changed files with 28 additions and 9 deletions

View file

@ -1137,6 +1137,7 @@
"visualeditor-editingtabdialog-title",
"visualeditor-mweditmode-tooltip",
"visualeditor-mweditmodesource-tool",
"visualeditor-mweditmodesource-tool-current",
"visualeditor-mweditmodesource-tool-unavailable",
"visualeditor-mweditmodesource-warning-cancel",
"visualeditor-mweditmodesource-warning-switch",
@ -1146,6 +1147,7 @@
"visualeditor-mweditmodeve-showagain",
"visualeditor-mweditmodeve-title",
"visualeditor-mweditmodeve-tool",
"visualeditor-mweditmodeve-tool-current",
"visualeditor-mweditmodeve-tool-unavailable",
"visualeditor-mweditmodeve-warning",
"visualeditor-mweditmodewt-popup-body",

View file

@ -276,6 +276,7 @@
"visualeditor-mweditmodesource-progress": "Switching to source editing…",
"visualeditor-mweditmodesource-title": "Switch to source editing?",
"visualeditor-mweditmodesource-tool": "Switch to source editing",
"visualeditor-mweditmodesource-tool-current": "Source editing",
"visualeditor-mweditmodesource-tool-unavailable": "Source editing is not available here",
"visualeditor-mweditmodesource-warning": "You are switching to source editing.\nDo you want to continue?",
"visualeditor-mweditmodesource-warning-cancel": "Cancel",
@ -287,6 +288,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-current": "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.",

View file

@ -289,6 +289,7 @@
"visualeditor-mweditmodesource-progress": "Title of progress bar shown while switching to source mode.",
"visualeditor-mweditmodesource-title": "Title of dialog to confirm switching to source mode.",
"visualeditor-mweditmodesource-tool": "Label for tool that changes edit mode to source editing.",
"visualeditor-mweditmodesource-tool-current": "Label for tool that changes edit mode to source editing if the user is already in that mode.",
"visualeditor-mweditmodesource-tool-unavailable": "'''Please translate \"Source\" as meaning \"Source codes\", not source of references.''' Label for tool that changes edit mode to source editing when it is not available.",
"visualeditor-mweditmodesource-warning": "Warning message show before changing edit mode to source editing. It may allow the user to keep the changes using the message {{msg-mw|Visualeditor-mweditmodesource-warning-switch}} or cancel.",
"visualeditor-mweditmodesource-warning-cancel": "Label for the button on the confirmation dialog for switching to source editing to cancel and return to editing.\n{{Identical|Cancel}}",
@ -300,6 +301,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-current": "Label for tool that changes edit mode to visual editing if the user is already in that mode.",
"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",

View file

@ -38,6 +38,8 @@ mw.libs.ve.MWEditModeTool.static.autoAddToCatchall = false;
mw.libs.ve.MWEditModeTool.static.autoAddToGroup = false;
mw.libs.ve.MWEditModeTool.static.currentTitle = null;
mw.libs.ve.MWEditModeTool.static.unavailableTooltip = null;
/* Methods */
@ -80,25 +82,32 @@ mw.libs.ve.MWEditModeTool.prototype.onSelect = function () {
if ( this.getMode() !== this.constructor.static.editMode ) {
this.switch();
}
this.setActive( this.getMode() === this.constructor.static.editMode );
};
/**
* @inheritdoc
*/
mw.libs.ve.MWEditModeTool.prototype.onUpdateState = function () {
var modeAvailable = this.isModeAvailable( this.constructor.static.editMode );
var titleKey,
modeAvailable = this.isModeAvailable( this.constructor.static.editMode ),
isCurrent = this.getMode() === this.constructor.static.editMode;
// Change title if state has changed
if ( this.modeAvailable !== modeAvailable ) {
this.$link.attr( 'title', modeAvailable ?
OO.ui.resolveMsg( this.constructor.static.title ) :
OO.ui.resolveMsg( this.constructor.static.unavailableTooltip )
);
this.setDisabled( !modeAvailable );
if ( this.isCurrent !== isCurrent || this.modeAvailable !== modeAvailable ) {
titleKey = isCurrent ?
this.constructor.static.currentTitle :
this.constructor.static.title;
this.setTitle( OO.ui.resolveMsg( titleKey ) );
// Change tooltip if mode is unavailable
if ( !modeAvailable ) {
this.$link.attr( 'title', OO.ui.resolveMsg( this.constructor.static.unavailableTooltip ) );
}
this.modeAvailable = modeAvailable;
this.isCurrent = isCurrent;
}
this.setActive( this.getMode() === this.constructor.static.editMode );
// Update disabled and active state
this.setDisabled( !modeAvailable );
this.setActive( isCurrent );
};
/**
@ -120,6 +129,8 @@ mw.libs.ve.MWEditModeSourceTool.static.name = 'editModeSource';
mw.libs.ve.MWEditModeSourceTool.static.icon = 'wikiText';
mw.libs.ve.MWEditModeSourceTool.static.title =
OO.ui.deferMsg( 'visualeditor-mweditmodesource-tool' );
mw.libs.ve.MWEditModeSourceTool.static.currentTitle =
OO.ui.deferMsg( 'visualeditor-mweditmodesource-tool-current' );
mw.libs.ve.MWEditModeSourceTool.static.unavailableTooltip =
OO.ui.deferMsg( 'visualeditor-mweditmodesource-tool-unavailable' );
@ -142,5 +153,7 @@ mw.libs.ve.MWEditModeVisualTool.static.name = 'editModeVisual';
mw.libs.ve.MWEditModeVisualTool.static.icon = 'eye';
mw.libs.ve.MWEditModeVisualTool.static.title =
OO.ui.deferMsg( 'visualeditor-mweditmodeve-tool' );
mw.libs.ve.MWEditModeVisualTool.static.currentTitle =
OO.ui.deferMsg( 'visualeditor-mweditmodeve-tool-current' );
mw.libs.ve.MWEditModeVisualTool.static.unavailableTooltip =
OO.ui.deferMsg( 'visualeditor-mweditmodeve-tool-unavailable' );