3 * A button to configure highlight for a filter item
5 * @extends OO.ui.PopupButtonWidget
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
.FilterItemHighlightButton
= function MwRcfiltersUiFilterItemHighlightButton( controller
, model
, config
) {
13 config
= config
|| {};
15 this.colorPickerWidget
= new mw
.rcfilters
.ui
.HighlightColorPickerWidget( controller
, model
);
18 mw
.rcfilters
.ui
.FilterItemHighlightButton
.parent
.call( this, $.extend( {}, config
, {
22 // TODO: There is a bug in non-anchored popups in
23 // OOUI, so we set this popup to "anchored" until
25 // See: https://phabricator.wikimedia.org/T159906
29 horizontalPosition
: 'end',
30 $floatableContainer
: this.$element
,
32 $content
: this.colorPickerWidget
.$element
36 this.controller
= controller
;
40 this.model
.connect( this, { update
: 'onModelUpdate' } );
41 this.colorPickerWidget
.connect( this, { chooseColor
: 'onChooseColor' } );
44 .addClass( 'mw-rcfilters-ui-filterItemHighlightButton' );
49 OO
.inheritClass( mw
.rcfilters
.ui
.FilterItemHighlightButton
, OO
.ui
.PopupButtonWidget
);
54 * Respond to item model update event
56 mw
.rcfilters
.ui
.FilterItemHighlightButton
.prototype.onModelUpdate = function () {
57 var currentColor
= this.model
.getHighlightColor(),
60 this.$icon
.toggleClass(
61 'mw-rcfilters-ui-filterItemHighlightButton-circle',
65 mw
.rcfilters
.HighlightColors
.forEach( function ( c
) {
68 'mw-rcfilters-ui-filterItemHighlightButton-circle-color-' + c
,
74 mw
.rcfilters
.ui
.FilterItemHighlightButton
.prototype.onChooseColor = function () {
75 this.popup
.toggle( false );
77 }( mediaWiki
, jQuery
) );