Merge "resourceloader: Simplify StringSet fallback"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.GroupWidget.js
1 ( function () {
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 // eslint-disable-next-line no-restricted-properties
26 $.each( config.events, function ( eventName, eventEmit ) {
27 aggregate[ eventName ] = eventEmit;
28 } );
29
30 this.aggregate( aggregate );
31 }
32
33 if ( Array.isArray( config.items ) ) {
34 this.addItems( config.items );
35 }
36 };
37
38 /* Initialize */
39
40 OO.inheritClass( mw.rcfilters.ui.GroupWidget, OO.ui.Widget );
41 OO.mixinClass( mw.rcfilters.ui.GroupWidget, OO.ui.mixin.GroupWidget );
42 }() );