mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-18 11:46:01 +00:00
8dfbc5baa5
Objectives: * Got rid of mw prefixing in tools, inspectors and dialogs * Simplify tool classes so they can be generically used as items in bars, lists and menus * Add support for a catch-all toolbar group * Simplify tool registration, leaning on tool classes' static name property * Move default commands to command registry * Move default triggers to trigger registry * Get language tool working in standalone Change-Id: Ic97a636f9a193374728629931b6702bee1b3416a
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] Config 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( ', ' ) );
|
|
};
|