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} model Filter item model
10 * @param {Object} config Configuration object
12 mw
.rcfilters
.ui
.FilterMenuOptionWidget
= function MwRcfiltersUiFilterMenuOptionWidget( controller
, model
, config
) {
13 config
= config
|| {};
15 this.controller
= controller
;
19 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.parent
.call( this, controller
, model
, config
);
22 this.model
.getGroupModel().connect( this, { update
: 'onGroupModelUpdate' } );
25 .addClass( 'mw-rcfilters-ui-filterMenuOptionWidget' );
29 OO
.inheritClass( mw
.rcfilters
.ui
.FilterMenuOptionWidget
, mw
.rcfilters
.ui
.ItemMenuOptionWidget
);
31 /* Static properties */
33 // We do our own scrolling to top
34 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.static.scrollIntoViewOnSelect
= false;
41 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.prototype.onModelUpdate = function () {
43 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.parent
.prototype.onModelUpdate
.call( this );
45 this.setCurrentMuteState();
49 * Respond to item group model update event
51 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.prototype.onGroupModelUpdate = function () {
52 this.setCurrentMuteState();
56 * Set the current muted view of the widget based on its state
58 mw
.rcfilters
.ui
.FilterMenuOptionWidget
.prototype.setCurrentMuteState = function () {
60 this.model
.getGroupModel().getView() === 'namespaces' &&
61 this.model
.isInverted()
63 // This is an inverted behavior than the other rules, specifically
64 // for inverted namespaces
66 muted
: this.model
.isSelected()
71 this.model
.isConflicted() ||
73 // Item is also muted when any of the items in its group is active
74 this.model
.getGroupModel().isActive() &&
75 // But it isn't selected
76 !this.model
.isSelected() &&
77 // And also not included
78 !this.model
.isIncluded()