2 * MediaWiki Widgets - SizeFilterWidget class.
4 * @copyright 2011-2018 MediaWiki Widgets Team and others; see AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
10 * RadioSelectInputWidget and a TextInputWidget to set minimum or maximum byte size
12 * mw.loader.using( 'mediawiki.widgets.SizeFilterWidget', function () {
13 * var sf = new mw.widgets.SizeFilterWidget();
14 * $( 'body' ).append( sf.$element );
17 * @class mw.widgets.SizeFilterWidget
18 * @extends OO.ui.Widget
19 * @uses OO.ui.RadioSelectInputWidget
20 * @uses OO.ui.TextInputWidget
23 * @param {Object} [config] Configuration options
24 * @cfg {Object} [radioselectinput] Config for the radio select input
25 * @cfg {Object} [textinput] Config for the text input
26 * @cfg {boolean} [selectMin=true] Whether to select 'min', false would select 'max'
28 mw
.widgets
.SizeFilterWidget
= function MwWidgetsSizeFilterWidget( config
) {
29 // Config initialization
30 config
= $.extend( { selectMin
: true }, config
);
31 config
.textinput
= $.extend( {
33 }, config
.textinput
);
34 config
.radioselectinput
= $.extend( {
36 { data
: 'min', label
: mw
.msg( 'minimum-size' ) },
37 { data
: 'max', label
: mw
.msg( 'maximum-size' ) }
39 }, config
.radioselectinput
);
42 this.radioselectinput
= new OO
.ui
.RadioSelectInputWidget( config
.radioselectinput
);
43 this.textinput
= new OO
.ui
.TextInputWidget( config
.textinput
);
44 this.label
= new OO
.ui
.LabelWidget( { label
: mw
.msg( 'pagesize' ) } );
47 mw
.widgets
.SizeFilterWidget
.parent
.call( this, config
);
50 this.radioselectinput
.setValue( config
.selectMin
? 'min' : 'max' );
52 .addClass( 'mw-widget-sizeFilterWidget' )
54 this.radioselectinput
.$element
,
55 this.textinput
.$element
,
61 OO
.inheritClass( mw
.widgets
.SizeFilterWidget
, OO
.ui
.Widget
);
68 mw
.widgets
.SizeFilterWidget
.static.reusePreInfuseDOM = function ( node
, config
) {
69 config
= mw
.widgets
.SizeFilterWidget
.parent
.static.reusePreInfuseDOM( node
, config
);
70 config
.radioselectinput
= OO
.ui
.RadioSelectInputWidget
.static.reusePreInfuseDOM(
71 $( node
).find( '.oo-ui-radioSelectInputWidget' ),
72 config
.radioselectinput
74 config
.textinput
= OO
.ui
.TextInputWidget
.static.reusePreInfuseDOM(
75 $( node
).find( '.oo-ui-textInputWidget' ),
84 mw
.widgets
.SizeFilterWidget
.static.gatherPreInfuseState = function ( node
, config
) {
85 var state
= mw
.widgets
.SizeFilterWidget
.parent
.static.gatherPreInfuseState( node
, config
);
86 state
.radioselectinput
= OO
.ui
.RadioSelectInputWidget
.static.gatherPreInfuseState(
87 $( node
).find( '.oo-ui-radioSelectInputWidget' ),
88 config
.radioselectinput
90 state
.textinput
= OO
.ui
.TextInputWidget
.static.gatherPreInfuseState(
91 $( node
).find( '.oo-ui-textInputWidget' ),
102 mw
.widgets
.SizeFilterWidget
.prototype.restorePreInfuseState = function ( state
) {
103 mw
.widgets
.SizeFilterWidget
.parent
.prototype.restorePreInfuseState
.call( this, state
);
104 this.radioselectinput
.restorePreInfuseState( state
.radioselectinput
);
105 this.textinput
.restorePreInfuseState( state
.textinput
);