Merge "resourceloader: Simplify StringSet fallback"
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.HighlightPopupWidget.js
1 ( function () {
2 /**
3 * A popup containing a color picker, for setting highlight colors.
4 *
5 * @extends OO.ui.PopupWidget
6 *
7 * @constructor
8 * @param {mw.rcfilters.Controller} controller RCFilters controller
9 * @param {Object} [config] Configuration object
10 */
11 mw.rcfilters.ui.HighlightPopupWidget = function MwRcfiltersUiHighlightPopupWidget( controller, config ) {
12 config = config || {};
13
14 // Parent
15 mw.rcfilters.ui.HighlightPopupWidget.parent.call( this, $.extend( {
16 autoClose: true,
17 anchor: false,
18 padded: true,
19 align: 'backwards',
20 horizontalPosition: 'end',
21 width: 290
22 }, config ) );
23
24 this.colorPicker = new mw.rcfilters.ui.HighlightColorPickerWidget( controller );
25
26 this.colorPicker.connect( this, { chooseColor: 'onChooseColor' } );
27
28 this.$body.append( this.colorPicker.$element );
29 };
30
31 /* Initialization */
32
33 OO.inheritClass( mw.rcfilters.ui.HighlightPopupWidget, OO.ui.PopupWidget );
34
35 /* Methods */
36
37 /**
38 * Set the button (or other widget) that this popup should hang off.
39 *
40 * @param {OO.ui.Widget} widget Widget the popup should orient itself to
41 */
42 mw.rcfilters.ui.HighlightPopupWidget.prototype.setAssociatedButton = function ( widget ) {
43 this.setFloatableContainer( widget.$element );
44 this.$autoCloseIgnore = widget.$element;
45 };
46
47 /**
48 * Set the filter item that this popup should control the highlight color for.
49 *
50 * @param {mw.rcfilters.dm.FilterItem} item
51 */
52 mw.rcfilters.ui.HighlightPopupWidget.prototype.setFilterItem = function ( item ) {
53 this.colorPicker.setFilterItem( item );
54 };
55
56 /**
57 * When the user chooses a color in the color picker, close the popup.
58 */
59 mw.rcfilters.ui.HighlightPopupWidget.prototype.onChooseColor = function () {
60 this.toggle( false );
61 };
62
63 }() );