Trevor Parscal has uploaded a new change for review.
https://gerrit.wikimedia.org/r/90376
Change subject: Support programatic tool titles
......................................................................
Support programatic tool titles
Just override ve.ui.Tool.prototype.getTitle. The default implementation uses
the same static property as before.
Change-Id: I80fd95142cafac0e136cfe3031c16c371625b469
---
M modules/ve/ui/ve.ui.Tool.js
M modules/ve/ui/ve.ui.ToolGroup.js
2 files changed, 13 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/76/90376/1
diff --git a/modules/ve/ui/ve.ui.Tool.js b/modules/ve/ui/ve.ui.Tool.js
index 191a38e..4483556 100644
--- a/modules/ve/ui/ve.ui.Tool.js
+++ b/modules/ve/ui/ve.ui.Tool.js
@@ -197,6 +197,17 @@
};
/**
+ * Get the tool title.
+ *
+ * @method
+ * @returns {string} [title] Title text
+ */
+ve.ui.Tool.prototype.getTitle = function () {
+ var key = this.constructor.static.titleMessage;
+ return typeof key === 'string' ? ve.msg( key ) : '';
+};
+
+/**
* Sets the tool title attribute in the DOM.
*
* @method
diff --git a/modules/ve/ui/ve.ui.ToolGroup.js b/modules/ve/ui/ve.ui.ToolGroup.js
index 3a8f82a..de22a00 100644
--- a/modules/ve/ui/ve.ui.ToolGroup.js
+++ b/modules/ve/ui/ve.ui.ToolGroup.js
@@ -224,7 +224,7 @@
* @chainable
*/
ve.ui.ToolGroup.prototype.updateToolTitle = function ( name ) {
- var tool, trigger, labelMessage, labelText,
+ var tool, trigger, labelText,
showTitle = this.constructor.static.showTitle,
showTrigger = this.constructor.static.showTrigger;
@@ -232,10 +232,7 @@
if ( tool ) {
labelText = '';
if ( showTitle ) {
- labelMessage = tool.constructor.static.titleMessage;
- if ( labelMessage ) {
- labelText += ve.msg( labelMessage );
- }
+ labelText += tool.getTitle();
}
if ( showTrigger ) {
trigger = ve.ui.triggerRegistry.lookup(
tool.constructor.static.name );
--
To view, visit https://gerrit.wikimedia.org/r/90376
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I80fd95142cafac0e136cfe3031c16c371625b469
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits