3 * A widget representing a single toggle filter
5 * @extends mw.rcfilters.ui.ItemMenuOptionWidget
8 * @param {mw.rcfilters.Controller} controller RCFilters controller
9 * @param {mw.rcfilters.dm.FilterItem} invertModel
10 * @param {mw.rcfilters.dm.FilterItem} model Filter item model
11 * @param {Object} config Configuration object
13 mw
.rcfilters
.ui
.FilterMenuOptionWidget
= function MwRcfiltersUiFilterMenuOptionWidget( controller
, invertModel
, model
, config
) {
14 config
= config
|| {};
16 this.controller
= controller
;
17 this.invertModel
= invertModel
;
21 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.parent
.call( this, controller
, this.invertModel
, model
, config
);
24 this.model
.getGroupModel().connect( this, { update
: 'onGroupModelUpdate' } );
27 .addClass( 'mw-rcfilters-ui-filterMenuOptionWidget' );
31 OO
.inheritClass( mw
.rcfilters
.ui
.FilterMenuOptionWidget
, mw
.rcfilters
.ui
.ItemMenuOptionWidget
);
33 /* Static properties */
35 // We do our own scrolling to top
36 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.static.scrollIntoViewOnSelect
= false;
43 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.prototype.onModelUpdate = function () {
45 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.parent
.prototype.onModelUpdate
.call( this );
47 this.setCurrentMuteState();
51 * Respond to item group model update event
53 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.prototype.onGroupModelUpdate = function () {
54 this.setCurrentMuteState();
58 * Set the current muted view of the widget based on its state
60 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.prototype.setCurrentMuteState = function () {
62 this.model
.getGroupModel().getView() === 'namespaces' &&
63 this.invertModel
.isSelected()
65 // This is an inverted behavior than the other rules, specifically
66 // for inverted namespaces
68 muted
: this.model
.isSelected()
73 this.model
.isConflicted() ||
75 // Item is also muted when any of the items in its group is active
76 this.model
.getGroupModel().isActive() &&
77 // But it isn't selected
78 !this.model
.isSelected() &&
79 // And also not included
80 !this.model
.isIncluded()