3 * Filter-specific CapsuleMultiselectWidget
5 * @extends OO.ui.CapsuleMultiselectWidget
8 * @param {OO.ui.InputWidget} filterInput A filter input that focuses the capsule widget
9 * @param {Object} config Configuration object
11 mw.rcfilters.ui.FilterCapsuleMultiselectWidget = function MwRcfiltersUiFilterCapsuleMultiselectWidget( filterInput, config ) {
13 mw.rcfilters.ui.FilterCapsuleMultiselectWidget.parent.call( this, $.extend( {
14 $autoCloseIgnore: filterInput.$element
17 this.filterInput = filterInput;
19 this.$content.prepend(
21 .addClass( 'mw-rcfilters-ui-filterCapsuleMultiselectWidget-content-title' )
22 .text( mw.msg( 'rcfilters-activefilters' ) )
26 // Add the filterInput as trigger
27 this.filterInput.$input
28 .on( 'focus', this.focus.bind( this ) );
31 .addClass( 'mw-rcfilters-ui-filterCapsuleMultiselectWidget' );
36 OO.inheritClass( mw.rcfilters.ui.FilterCapsuleMultiselectWidget, OO.ui.CapsuleMultiselectWidget );
42 * @param {string[]} filters Array of names of removed filters
44 * Filters were removed
52 mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.focus = function () {
53 // Override this method; we don't want to focus on the popup, and we
54 // don't want to bind the size to the handle.
55 if ( !this.isDisabled() ) {
56 this.popup.toggle( true );
57 this.filterInput.$input.get( 0 ).focus();
65 mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.onFocusForPopup = function () {
66 // HACK can be removed once I21b8cff4048 is merged in oojs-ui
73 mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.removeItems = function ( items ) {
75 mw.rcfilters.ui.FilterCapsuleMultiselectWidget.parent.prototype.removeItems.call( this, items );
77 this.emit( 'remove', items.map( function ( item ) { return item.getData(); } ) );
83 mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.onKeyDown = function () {};
88 mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.onPopupFocusOut = function () {};
93 mw.rcfilters.ui.FilterCapsuleMultiselectWidget.prototype.clearInput = function () {
94 if ( this.filterInput ) {
95 this.filterInput.setValue( '' );
97 this.menu.toggle( false );
98 this.menu.selectItem();
99 this.menu.highlightItem();
101 }( mediaWiki, jQuery ) );