2013-08-27 23:28:29 +00:00
|
|
|
/*!
|
2013-10-09 20:09:59 +00:00
|
|
|
* ObjectOriented UserInterface MenuToolGroup class.
|
2013-08-27 23:28:29 +00:00
|
|
|
*
|
2013-10-09 20:09:59 +00:00
|
|
|
* @copyright 2011-2013 OOJS Team and others; see AUTHORS.txt
|
2013-08-27 23:28:29 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2013-10-09 20:09:59 +00:00
|
|
|
* Drop down menu layout of tools as selectable menu items.
|
2013-08-27 23:28:29 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @abstract
|
2013-10-09 20:09:59 +00:00
|
|
|
* @extends OO.ui.PopupToolGroup
|
2013-08-27 23:28:29 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2013-10-09 20:09:59 +00:00
|
|
|
* @param {OO.ui.Toolbar} toolbar
|
2013-09-25 10:21:09 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2013-08-27 23:28:29 +00:00
|
|
|
*/
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.ui.MenuToolGroup = function OoUiMenuToolGroup( toolbar, config ) {
|
2013-08-27 23:28:29 +00:00
|
|
|
// Parent constructor
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.ui.PopupToolGroup.call( this, toolbar, config );
|
2013-08-27 23:28:29 +00:00
|
|
|
|
|
|
|
// Events
|
|
|
|
this.toolbar.connect( this, { 'updateState': 'onUpdateState' } );
|
|
|
|
|
|
|
|
// Initialization
|
2013-10-09 20:09:59 +00:00
|
|
|
this.$.addClass( 'oo-ui-menuToolGroup' );
|
2013-08-27 23:28:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.inheritClass( OO.ui.MenuToolGroup, OO.ui.PopupToolGroup );
|
2013-08-27 23:28:29 +00:00
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
2013-10-23 23:27:12 +00:00
|
|
|
OO.ui.MenuToolGroup.static.accelTooltips = true;
|
2013-08-27 23:28:29 +00:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
*/
|
2013-10-09 20:09:59 +00:00
|
|
|
OO.ui.MenuToolGroup.prototype.onUpdateState = function () {
|
2013-08-27 23:28:29 +00:00
|
|
|
var name,
|
|
|
|
labelTexts = [];
|
|
|
|
|
|
|
|
for ( name in this.tools ) {
|
|
|
|
if ( this.tools[name].isActive() ) {
|
2013-10-23 23:27:12 +00:00
|
|
|
labelTexts.push( this.tools[name].$label.find( '.oo-ui-tool-title' ).text() );
|
2013-08-27 23:28:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setLabel( labelTexts.join( ', ' ) );
|
|
|
|
};
|