5 * @extends OO.ui.Widget
6 * @mixins OO.ui.mixin.GroupWidget
7 * @mixins OO.ui.mixin.LabelElement
10 * @param {mw.rcfilters.Controller} controller Controller
11 * @param {mw.rcfilters.dm.FilterGroup} model Filter group model
12 * @param {Object} config Configuration object
14 mw.rcfilters.ui.FilterGroupWidget = function MwRcfiltersUiFilterGroupWidget( controller, model, config ) {
15 config = config || {};
18 mw.rcfilters.ui.FilterGroupWidget.parent.call( this, config );
20 this.controller = controller;
25 OO.ui.mixin.GroupWidget.call( this, config );
26 OO.ui.mixin.LabelElement.call( this, $.extend( {}, config, {
27 label: this.model.getTitle(),
29 .addClass( 'mw-rcfilters-ui-filterGroupWidget-title' )
31 this.$overlay = config.$overlay || this.$element;
34 this.populateFromModel();
36 this.model.connect( this, { update: 'onModelUpdate' } );
39 .addClass( 'mw-rcfilters-ui-filterGroupWidget' )
40 .addClass( 'mw-rcfilters-ui-filterGroupWidget-name-' + this.model.getName() )
44 .addClass( 'mw-rcfilters-ui-filterGroupWidget-group' )
50 OO.inheritClass( mw.rcfilters.ui.FilterGroupWidget, OO.ui.Widget );
51 OO.mixinClass( mw.rcfilters.ui.FilterGroupWidget, OO.ui.mixin.GroupWidget );
52 OO.mixinClass( mw.rcfilters.ui.FilterGroupWidget, OO.ui.mixin.LabelElement );
55 * Respond to model update event
57 mw.rcfilters.ui.FilterGroupWidget.prototype.onModelUpdate = function () {
58 this.$element.toggleClass(
59 'mw-rcfilters-ui-filterGroupWidget-active',
65 * Get an item widget from its filter name
67 * @param {string} filterName Filter name
68 * @return {mw.rcfilters.ui.FilterItemWidget} Item widget
70 mw.rcfilters.ui.FilterGroupWidget.prototype.getItemWidget = function ( filterName ) {
71 return this.filters[ filterName ];
75 * Populate data from the model
77 mw.rcfilters.ui.FilterGroupWidget.prototype.populateFromModel = function () {
84 this.model.getItems().map( function ( filterItem ) {
85 var groupWidget = new mw.rcfilters.ui.FilterItemWidget(
89 label: filterItem.getLabel(),
90 description: filterItem.getDescription(),
91 $overlay: widget.$overlay
95 widget.filters[ filterItem.getName() ] = groupWidget;
105 * @return {string} Group name
107 mw.rcfilters.ui.FilterGroupWidget.prototype.getName = function () {
108 return this.model.getName();
110 }( mediaWiki, jQuery ) );