| 1 |
const ValuePickerWidget = require( './ValuePickerWidget.js' ); |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
const ChangesLimitPopupWidget = function MwRcfiltersUiChangesLimitPopupWidget( limitModel, groupByPageItemModel, config ) { |
| 15 |
config = config || {}; |
| 16 |
|
| 17 |
|
| 18 |
ChangesLimitPopupWidget.super.call( this, config ); |
| 19 |
|
| 20 |
this.limitModel = limitModel; |
| 21 |
this.groupByPageItemModel = groupByPageItemModel; |
| 22 |
|
| 23 |
this.valuePicker = new ValuePickerWidget( |
| 24 |
this.limitModel, |
| 25 |
{ |
| 26 |
label: mw.msg( 'rcfilters-limit-title' ) |
| 27 |
} |
| 28 |
); |
| 29 |
|
| 30 |
this.groupByPageCheckbox = new OO.ui.CheckboxInputWidget( { |
| 31 |
selected: this.groupByPageItemModel.isSelected() |
| 32 |
} ); |
| 33 |
|
| 34 |
|
| 35 |
this.valuePicker.connect( this, { choose: [ 'emit', 'limit' ] } ); |
| 36 |
this.groupByPageCheckbox.connect( this, { change: [ 'emit', 'groupByPage' ] } ); |
| 37 |
this.groupByPageItemModel.connect( this, { update: 'onGroupByPageModelUpdate' } ); |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
this.groupByPageCheckbox.$element.on( 'click', this.onGroupByPageUserClick.bind( this ) ); |
| 43 |
|
| 44 |
|
| 45 |
this.$element |
| 46 |
.addClass( 'mw-rcfilters-ui-changesLimitPopupWidget' ) |
| 47 |
.append( |
| 48 |
this.valuePicker.$element, |
| 49 |
OO.ui.isMobile() ? undefined : |
| 50 |
new OO.ui.FieldLayout( |
| 51 |
this.groupByPageCheckbox, |
| 52 |
{ |
| 53 |
align: 'inline', |
| 54 |
label: mw.msg( 'rcfilters-group-results-by-page' ) |
| 55 |
} |
| 56 |
).$element |
| 57 |
); |
| 58 |
|
| 59 |
this.valuePicker.selectWidget.$element.attr( 'aria-label', mw.msg( 'rcfilters-limit-title' ) ); |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
OO.inheritClass( ChangesLimitPopupWidget, OO.ui.Widget ); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
ChangesLimitPopupWidget.prototype.onGroupByPageModelUpdate = function () { |
| 88 |
this.groupByPageCheckbox.setSelected( this.groupByPageItemModel.isSelected() ); |
| 89 |
}; |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
ChangesLimitPopupWidget.prototype.onGroupByPageUserClick = function () { |
| 95 |
this.emit( 'groupByPageUserClick', this.groupByPageCheckbox.isSelected() ); |
| 96 |
}; |
| 97 |
|
| 98 |
module.exports = ChangesLimitPopupWidget; |