Prepare for REL1_33 cut, labelling master as 1.34-alpha
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / GroupWidget.js
1 ( function () {
2 /**
3 * A group widget to allow for aggregation of events
4 *
5 * @class mw.rcfilters.ui.GroupWidget
6 * @extends OO.ui.Widget
7 *
8 * @constructor
9 * @param {Object} [config] Configuration object
10 * @param {Object} [events] Events to aggregate. The object represent the
11 * event name to aggregate and the event value to emit on aggregate for items.
12 */
13 var GroupWidget = function MwRcfiltersUiViewSwitchWidget( config ) {
14 var aggregate = {};
15
16 config = config || {};
17
18 // Parent constructor
19 GroupWidget.parent.call( this, config );
20
21 // Mixin constructors
22 OO.ui.mixin.GroupElement.call( this, $.extend( {}, config, { $group: this.$element } ) );
23
24 if ( config.events ) {
25 // Aggregate events
26 // eslint-disable-next-line no-jquery/no-each-util
27 $.each( config.events, function ( eventName, eventEmit ) {
28 aggregate[ eventName ] = eventEmit;
29 } );
30
31 this.aggregate( aggregate );
32 }
33
34 if ( Array.isArray( config.items ) ) {
35 this.addItems( config.items );
36 }
37 };
38
39 /* Initialize */
40
41 OO.inheritClass( GroupWidget, OO.ui.Widget );
42 OO.mixinClass( GroupWidget, OO.ui.mixin.GroupWidget );
43
44 module.exports = GroupWidget;
45 }() );