1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
( function ( mw ) {
/**
* Widget defining the popup to choose number of results
*
* @extends OO.ui.Widget
*
* @constructor
* @param {mw.rcfilters.dm.FilterGroup} limitModel Group model for 'limit'
* @param {mw.rcfilters.dm.FilterItem} groupByPageItemModel Group model for 'limit'
* @param {Object} [config] Configuration object
*/
mw.rcfilters.ui.ChangesLimitPopupWidget = function MwRcfiltersUiChangesLimitPopupWidget( limitModel, groupByPageItemModel, config ) {
config = config || {};
// Parent
mw.rcfilters.ui.ChangesLimitPopupWidget.parent.call( this, config );
this.limitModel = limitModel;
this.groupByPageItemModel = groupByPageItemModel;
this.valuePicker = new mw.rcfilters.ui.ValuePickerWidget(
this.limitModel,
{
label: mw.msg( 'rcfilters-limit-title' )
}
);
this.groupByPageCheckbox = new OO.ui.CheckboxInputWidget( {
selected: this.groupByPageItemModel.isSelected()
} );
// Events
this.valuePicker.connect( this, { choose: [ 'emit', 'limit' ] } );
this.groupByPageCheckbox.connect( this, { change: [ 'emit', 'groupByPage' ] } );
this.groupByPageItemModel.connect( this, { update: 'onGroupByPageModelUpdate' } );
// Initialize
this.$element
.addClass( 'mw-rcfilters-ui-changesLimitPopupWidget' )
.append(
this.valuePicker.$element,
new OO.ui.FieldLayout(
this.groupByPageCheckbox,
{
align: 'inline',
label: mw.msg( 'rcfilters-group-results-by-page' )
}
).$element
);
};
/* Initialization */
OO.inheritClass( mw.rcfilters.ui.ChangesLimitPopupWidget, OO.ui.Widget );
/* Events */
/**
* @event limit
* @param {string} name Item name
*
* A limit item was chosen
*/
/**
* @event groupByPage
* @param {boolean} isGrouped The results are grouped by page
*
* Results are grouped by page
*/
/**
* Respond to group by page model update
*/
mw.rcfilters.ui.ChangesLimitPopupWidget.prototype.onGroupByPageModelUpdate = function () {
this.groupByPageCheckbox.setSelected( this.groupByPageItemModel.isSelected() );
};
}( mediaWiki ) );
|