* Respond to model initialize event
*/
mw.rcfilters.ui.ChangesLimitButtonWidget.prototype.onModelInitialize = function () {
- var changesLimitPopupWidget, selectedItem, currentValue;
+ var changesLimitPopupWidget, selectedItem, currentValue,
+ displayGroupModel = this.model.getGroup( 'display' );
this.limitGroupModel = this.model.getGroup( 'limit' );
+ this.groupByPageItemModel = displayGroupModel.getItemByParamName( 'enhanced' );
// HACK: We need the model to be ready before we populate the button
// and the widget, because we require the filter items for the
// Note: This will be fixed soon!
if ( this.limitGroupModel ) {
changesLimitPopupWidget = new mw.rcfilters.ui.ChangesLimitPopupWidget(
- this.limitGroupModel
+ this.limitGroupModel,
+ this.groupByPageItemModel
);
selectedItem = this.limitGroupModel.getSelectedItems()[ 0 ];
// Events
this.limitGroupModel.connect( this, { update: 'onLimitGroupModelUpdate' } );
- changesLimitPopupWidget.connect( this, { limit: 'onPopupLimit' } );
+ changesLimitPopupWidget.connect( this, {
+ limit: 'onPopupLimit',
+ groupByPage: 'onPopupGroupByPage'
+ } );
this.$element.append( this.button.$element );
}
* @param {string} filterName Chosen filter name
*/
mw.rcfilters.ui.ChangesLimitButtonWidget.prototype.onPopupLimit = function ( filterName ) {
+ var item = this.limitGroupModel.getItemByName( filterName );
+
this.controller.toggleFilterSelect( filterName, true );
+ this.controller.updateLimitDefault( item.getParamName() );
+ this.button.popup.toggle( false );
+ };
+
+ /**
+ * Respond to popup limit change event
+ *
+ * @param {boolean} isGrouped The result set is grouped by page
+ */
+ mw.rcfilters.ui.ChangesLimitButtonWidget.prototype.onPopupGroupByPage = function ( isGrouped ) {
+ this.controller.toggleFilterSelect( this.groupByPageItemModel.getName(), isGrouped );
+ this.controller.updateGroupByPageDefault( Number( isGrouped ) );
this.button.popup.toggle( false );
};