| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
( function () { |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
mw.widgets.SizeFilterWidget = function MwWidgetsSizeFilterWidget( config ) { |
| 31 |
|
| 32 |
config = Object.assign( { selectMin: true }, config ); |
| 33 |
config.textinput = Object.assign( { |
| 34 |
type: 'number' |
| 35 |
}, config.textinput ); |
| 36 |
config.radioselectinput = Object.assign( { |
| 37 |
options: [ |
| 38 |
{ data: 'min', label: mw.msg( 'minimum-size' ) }, |
| 39 |
{ data: 'max', label: mw.msg( 'maximum-size' ) } |
| 40 |
] |
| 41 |
}, config.radioselectinput ); |
| 42 |
|
| 43 |
|
| 44 |
this.radioselectinput = new OO.ui.RadioSelectInputWidget( config.radioselectinput ); |
| 45 |
this.textinput = new OO.ui.TextInputWidget( config.textinput ); |
| 46 |
this.label = new OO.ui.LabelWidget( { label: mw.msg( 'pagesize' ) } ); |
| 47 |
|
| 48 |
|
| 49 |
mw.widgets.SizeFilterWidget.super.call( this, config ); |
| 50 |
|
| 51 |
|
| 52 |
this.radioselectinput.setValue( config.selectMin ? 'min' : 'max' ); |
| 53 |
this.$element |
| 54 |
.addClass( 'mw-widget-sizeFilterWidget' ) |
| 55 |
.append( |
| 56 |
this.radioselectinput.$element, |
| 57 |
this.textinput.$element, |
| 58 |
this.label.$element |
| 59 |
); |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
OO.inheritClass( mw.widgets.SizeFilterWidget, OO.ui.Widget ); |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
mw.widgets.SizeFilterWidget.static.reusePreInfuseDOM = function ( node, config ) { |
| 71 |
config = mw.widgets.SizeFilterWidget.super.static.reusePreInfuseDOM( node, config ); |
| 72 |
config.radioselectinput = OO.ui.RadioSelectInputWidget.static.reusePreInfuseDOM( |
| 73 |
$( node ).find( '.oo-ui-radioSelectInputWidget' ), |
| 74 |
config.radioselectinput |
| 75 |
); |
| 76 |
config.textinput = OO.ui.TextInputWidget.static.reusePreInfuseDOM( |
| 77 |
$( node ).find( '.oo-ui-textInputWidget' ), |
| 78 |
config.textinput |
| 79 |
); |
| 80 |
return config; |
| 81 |
}; |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
mw.widgets.SizeFilterWidget.static.gatherPreInfuseState = function ( node, config ) { |
| 87 |
const state = mw.widgets.SizeFilterWidget.super.static.gatherPreInfuseState( node, config ); |
| 88 |
state.radioselectinput = OO.ui.RadioSelectInputWidget.static.gatherPreInfuseState( |
| 89 |
$( node ).find( '.oo-ui-radioSelectInputWidget' ), |
| 90 |
config.radioselectinput |
| 91 |
); |
| 92 |
state.textinput = OO.ui.TextInputWidget.static.gatherPreInfuseState( |
| 93 |
$( node ).find( '.oo-ui-textInputWidget' ), |
| 94 |
config.textinput |
| 95 |
); |
| 96 |
return state; |
| 97 |
}; |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
mw.widgets.SizeFilterWidget.prototype.restorePreInfuseState = function ( state ) { |
| 105 |
mw.widgets.SizeFilterWidget.super.prototype.restorePreInfuseState.call( this, state ); |
| 106 |
this.radioselectinput.restorePreInfuseState( state.radioselectinput ); |
| 107 |
this.textinput.restorePreInfuseState( state.textinput ); |
| 108 |
}; |
| 109 |
|
| 110 |
}() ); |