mw.rcfilters.ui.FilterWrapperWidget = function MwRcfiltersUiFilterWrapperWidget(
controller, model, savedQueriesModel, changesListModel, config
) {
- var $top, $bottom;
+ var $bottom;
config = config || {};
// Parent
this.controller = controller;
this.model = model;
this.queriesModel = savedQueriesModel;
+ this.changesListModel = changesListModel;
this.$overlay = config.$overlay || this.$element;
this.filterTagWidget = new mw.rcfilters.ui.FilterTagMultiselectWidget(
this.liveUpdateButton = new mw.rcfilters.ui.LiveUpdateButtonWidget(
this.controller,
- changesListModel
+ this.changesListModel
);
- this.numChangesWidget = new mw.rcfilters.ui.ChangesLimitButtonWidget(
+ this.numChangesWidget = new mw.rcfilters.ui.ChangesLimitAndDateButtonWidget(
this.controller,
this.model,
{
}
);
- this.dateWidget = new mw.rcfilters.ui.DateButtonWidget(
- this.controller,
- this.model,
- {
- $overlay: this.$overlay
- }
- );
+ this.showNewChangesLink = new OO.ui.ButtonWidget( {
+ icon: 'reload',
+ framed: false,
+ label: mw.msg( 'rcfilters-show-new-changes' ),
+ flags: [ 'progressive' ],
+ classes: [ 'mw-rcfilters-ui-filterWrapperWidget-showNewChanges' ]
+ } );
// Initialize
- this.$topRow = $( '<div>' )
- .addClass( 'mw-rcfilters-ui-row' )
- .append(
- $( '<div>' )
- .addClass( 'mw-rcfilters-ui-cell' )
- .addClass( 'mw-rcfilters-ui-filterWrapperWidget-top-placeholder' )
- );
- $top = $( '<div>' )
- .addClass( 'mw-rcfilters-ui-filterWrapperWidget-top' )
- .addClass( 'mw-rcfilters-ui-table' )
- .append( this.$topRow );
+ this.$top = $( '<div>' )
+ .addClass( 'mw-rcfilters-ui-filterWrapperWidget-top' );
$bottom = $( '<div>' )
.addClass( 'mw-rcfilters-ui-filterWrapperWidget-bottom' )
.append(
- this.numChangesWidget.$element,
- this.dateWidget.$element
+ this.showNewChangesLink.$element,
+ this.numChangesWidget.$element
);
- this.savedLinksListWidget = new mw.rcfilters.ui.SavedLinksListWidget(
- this.controller,
- this.queriesModel,
- { $overlay: this.$overlay }
- );
-
- this.$topRow.append(
- $( '<div>' )
- .addClass( 'mw-rcfilters-ui-cell' )
- .addClass( 'mw-rcfilters-ui-filterWrapperWidget-top-savedLinks' )
- .append( this.savedLinksListWidget.$element )
- );
-
if ( mw.rcfilters.featureFlags.liveUpdate ) {
- $bottom.append( this.liveUpdateButton.$element );
+ $bottom.prepend( this.liveUpdateButton.$element );
}
+ // Events
+ this.filterTagWidget.menu.connect( this, { toggle: [ 'emit', 'menuToggle' ] } );
+ this.changesListModel.connect( this, { newChangesExist: 'onNewChangesExist' } );
+ this.showNewChangesLink.connect( this, { click: 'onShowNewChangesClick' } );
+ this.showNewChangesLink.toggle( false );
+
this.$element
.addClass( 'mw-rcfilters-ui-filterWrapperWidget' )
.append(
- $top,
+ this.$top,
this.filterTagWidget.$element,
$bottom
);
/* Methods */
/**
- * Add a widget at the beginning of the top row
+ * Set the content of the top section
*
- * @param {OO.ui.Widget} widget Any widget
+ * @param {jQuery} $topSectionElement
*/
- mw.rcfilters.ui.FilterWrapperWidget.prototype.prependToTopRow = function ( widget ) {
- this.$topRow.prepend(
- widget.$element
- .addClass( 'mw-rcfilters-ui-cell' )
- );
+ mw.rcfilters.ui.FilterWrapperWidget.prototype.setTopSection = function ( $topSectionElement ) {
+ this.$top.append( $topSectionElement );
+ };
+
+ /**
+ * Respond to the user clicking the 'show new changes' button
+ */
+ mw.rcfilters.ui.FilterWrapperWidget.prototype.onShowNewChangesClick = function () {
+ this.controller.showNewChanges();
};
+ /**
+ * Respond to changes list model newChangesExist
+ *
+ * @param {boolean} newChangesExist Whether new changes exist
+ */
+ mw.rcfilters.ui.FilterWrapperWidget.prototype.onNewChangesExist = function ( newChangesExist ) {
+ this.showNewChangesLink.toggle( newChangesExist );
+ };
}( mediaWiki ) );