5 * @mixins OO.EventEmitter
8 * @param {string} name Filter name
9 * @param {Object} config Configuration object
10 * @cfg {string} [group] The group this item belongs to
11 * @cfg {string} [label] The label for the filter
12 * @cfg {string} [description] The description of the filter
13 * @cfg {boolean} [selected] Filter is selected
15 mw
.rcfilters
.dm
.FilterItem
= function MwRcfiltersDmFilterItem( name
, config
) {
16 config
= config
|| {};
19 OO
.EventEmitter
.call( this );
22 this.group
= config
.group
|| '';
23 this.label
= config
.label
|| this.name
;
24 this.description
= config
.description
;
26 this.selected
= !!config
.selected
;
31 OO
.initClass( mw
.rcfilters
.dm
.FilterItem
);
32 OO
.mixinClass( mw
.rcfilters
.dm
.FilterItem
, OO
.EventEmitter
);
39 * The state of this filter has changed
45 * Get the name of this filter
47 * @return {string} Filter name
49 mw
.rcfilters
.dm
.FilterItem
.prototype.getName = function () {
54 * Get the group name this filter belongs to
56 * @return {string} Filter group name
58 mw
.rcfilters
.dm
.FilterItem
.prototype.getGroup = function () {
63 * Get the label of this filter
65 * @return {string} Filter label
67 mw
.rcfilters
.dm
.FilterItem
.prototype.getLabel = function () {
72 * Get the description of this filter
74 * @return {string} Filter description
76 mw
.rcfilters
.dm
.FilterItem
.prototype.getDescription = function () {
77 return this.description
;
81 * Get the selected state of this filter
83 * @return {boolean} Filter is selected
85 mw
.rcfilters
.dm
.FilterItem
.prototype.isSelected = function () {
90 * Toggle the selected state of the item
92 * @param {boolean} [isSelected] Filter is selected
95 mw
.rcfilters
.dm
.FilterItem
.prototype.toggleSelected = function ( isSelected
) {
96 isSelected
= isSelected
=== undefined ? !this.selected
: isSelected
;
98 if ( this.selected
!== isSelected
) {
99 this.selected
= isSelected
;
100 this.emit( 'update' );