mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 14:56:20 +00:00
e6f48c5c93
Because the former isn't a real word. Change-Id: Ie6ed15f9e390b357bbaa768b57f3c3fd7cf21181
60 lines
1.3 KiB
JavaScript
60 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MenuToolGroup class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* UserInterface bar tool group.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
* @extends ve.ui.PopupToolGroup
|
|
*
|
|
* @constructor
|
|
* @param {ve.ui.Toolbar} toolbar
|
|
* @param {Object} [config] Configuration options
|
|
*/
|
|
ve.ui.MenuToolGroup = function VeUiMenuToolGroup( toolbar, config ) {
|
|
// Parent constructor
|
|
ve.ui.PopupToolGroup.call( this, toolbar, config );
|
|
|
|
// Events
|
|
this.toolbar.connect( this, { 'updateState': 'onUpdateState' } );
|
|
|
|
// Initialization
|
|
this.$.addClass( 've-ui-menuToolGroup' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
ve.inheritClass( ve.ui.MenuToolGroup, ve.ui.PopupToolGroup );
|
|
|
|
/* Static Properties */
|
|
|
|
ve.ui.MenuToolGroup.static.showTrigger = true;
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* Handle the toolbar state being updated.
|
|
*
|
|
* When the state changes, the title of each active item in the menu will be joined together and
|
|
* used as a label for the group. The label will be empty if none of the items are active.
|
|
*
|
|
* @method
|
|
*/
|
|
ve.ui.MenuToolGroup.prototype.onUpdateState = function () {
|
|
var name,
|
|
labelTexts = [];
|
|
|
|
for ( name in this.tools ) {
|
|
if ( this.tools[name].isActive() ) {
|
|
labelTexts.push( this.tools[name].getLabelText() );
|
|
}
|
|
}
|
|
|
|
this.setLabel( labelTexts.join( ', ' ) );
|
|
};
|