From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- .../oojs/oojs-ui/src/toolgroups/MenuToolGroup.js | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 vendor/oojs/oojs-ui/src/toolgroups/MenuToolGroup.js (limited to 'vendor/oojs/oojs-ui/src/toolgroups/MenuToolGroup.js') diff --git a/vendor/oojs/oojs-ui/src/toolgroups/MenuToolGroup.js b/vendor/oojs/oojs-ui/src/toolgroups/MenuToolGroup.js new file mode 100644 index 00000000..aef69a93 --- /dev/null +++ b/vendor/oojs/oojs-ui/src/toolgroups/MenuToolGroup.js @@ -0,0 +1,58 @@ +/** + * Drop down menu layout of tools as selectable menu items. + * + * @class + * @extends OO.ui.PopupToolGroup + * + * @constructor + * @param {OO.ui.Toolbar} toolbar + * @param {Object} [config] Configuration options + */ +OO.ui.MenuToolGroup = function OoUiMenuToolGroup( toolbar, config ) { + // Allow passing positional parameters inside the config object + if ( OO.isPlainObject( toolbar ) && config === undefined ) { + config = toolbar; + toolbar = config.toolbar; + } + + // Configuration initialization + config = config || {}; + + // Parent constructor + OO.ui.MenuToolGroup.super.call( this, toolbar, config ); + + // Events + this.toolbar.connect( this, { updateState: 'onUpdateState' } ); + + // Initialization + this.$element.addClass( 'oo-ui-menuToolGroup' ); +}; + +/* Setup */ + +OO.inheritClass( OO.ui.MenuToolGroup, OO.ui.PopupToolGroup ); + +/* Static Properties */ + +OO.ui.MenuToolGroup.static.name = 'menu'; + +/* 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. + */ +OO.ui.MenuToolGroup.prototype.onUpdateState = function () { + var name, + labelTexts = []; + + for ( name in this.tools ) { + if ( this.tools[ name ].isActive() ) { + labelTexts.push( this.tools[ name ].getTitle() ); + } + } + + this.setLabel( labelTexts.join( ', ' ) || ' ' ); +}; -- cgit v1.2.3-54-g00ecf