Support programmatic tool titles

Just override OO.ui.Tool.prototype.getTitle. The default implementation
uses the same static property as before.

Change-Id: I80fd95142cafac0e136cfe3031c16c371625b469
This commit is contained in:
Trevor Parscal 2013-10-17 10:30:59 -07:00 committed by Catrope
parent 230d88d182
commit 53d620e389

View file

@ -197,6 +197,17 @@ OO.ui.Tool.prototype.setActive = function ( state ) {
}
};
/**
* Get the tool title.
*
* @method
* @returns {string} [title] Title text
*/
OO.ui.Tool.prototype.getTitle = function () {
var key = this.constructor.static.titleMessage;
return typeof key === 'string' ? OO.ui.msg( key ) : '';
};
/**
* Get the tool's symbolic name.
*
@ -213,10 +224,9 @@ OO.ui.Tool.prototype.getName = function () {
* @method
*/
OO.ui.Tool.prototype.updateLabel = function () {
var titleMessage = this.constructor.static.titleMessage,
var title = this.getTitle(),
labelTooltips = this.toolGroup.constructor.static.labelTooltips,
accelTooltips = this.toolGroup.constructor.static.accelTooltips,
title = titleMessage ? OO.ui.msg( titleMessage ) : '',
accel = this.toolbar.getToolAccelerator( this.constructor.static.name ),
tooltipParts = [];