Merge "registration: Only allow one extension to set a specific config setting"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.GroupWidget.js
1 ( function ( mw ) {
2 /**
3 * A group widget to allow for aggregation of events
4 *
5 * @extends OO.ui.Widget
6 *
7 * @constructor
8 * @param {Object} [config] Configuration object
9 * @param {Object} [events] Events to aggregate. The object represent the
10 * event name to aggregate and the event value to emit on aggregate for items.
11 */
12 mw.rcfilters.ui.GroupWidget = function MwRcfiltersUiViewSwitchWidget( config ) {
13 var aggregate = {};
14
15 config = config || {};
16
17 // Parent constructor
18 mw.rcfilters.ui.GroupWidget.parent.call( this, config );
19
20 // Mixin constructors
21 OO.ui.mixin.GroupElement.call( this, $.extend( {}, config, { $group: this.$element } ) );
22
23 if ( config.events ) {
24 // Aggregate events
25 $.each( config.events, function ( eventName, eventEmit ) {
26 aggregate[ eventName ] = eventEmit;
27 } );
28
29 this.aggregate( aggregate );
30 }
31
32 if ( Array.isArray( config.items ) ) {
33 this.addItems( config.items );
34 }
35 };
36
37 /* Initialize */
38
39 OO.inheritClass( mw.rcfilters.ui.GroupWidget, OO.ui.Widget );
40 OO.mixinClass( mw.rcfilters.ui.GroupWidget, OO.ui.mixin.GroupWidget );
41 }( mediaWiki ) );