// Help icon for Tagged edits
this.helpIcon = new OO.ui.ButtonWidget( {
- icon: 'help',
+ icon: 'helpNotice',
framed: false,
title: mw.msg( 'rcfilters-view-tags-help-icon-tooltip' ),
classes: [ 'mw-rcfilters-ui-filterMenuHeaderWidget-helpIcon' ],
- href: 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:New_filters_for_edit_review/Advanced_filters#tags',
+ href: mw.util.getUrl( 'Special:Tags' ),
target: '_blank'
} );
this.helpIcon.toggle( this.model.getCurrentView() === 'tags' );
classes: [ 'mw-rcfilters-ui-filterMenuHeaderWidget-invertNamespacesButton' ]
} );
this.invertNamespacesButton.toggle( this.model.getCurrentView() === 'namespaces' );
- this.updateInvertButton( this.model.areNamespacesInverted() );
// Events
this.backButton.connect( this, { click: 'onBackButtonClick' } );
.connect( this, { click: 'onInvertNamespacesButtonClick' } );
this.model.connect( this, {
highlightChange: 'onModelHighlightChange',
- invertChange: 'onModelInvertChange',
- update: 'onModelUpdate'
+ searchChange: 'onModelSearchChange',
+ initialize: 'onModelInitialize'
} );
+ this.view = this.model.getCurrentView();
// Initialize
this.$element
/* Methods */
+ /**
+ * Respond to model initialization event
+ *
+ * Note: need to wait for initialization before getting the invertModel
+ * and registering its update event. Creating all the models before the UI
+ * would help with that.
+ */
+ mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.onModelInitialize = function () {
+ this.invertModel = this.model.getInvertModel();
+ this.updateInvertButton();
+ this.invertModel.connect( this, { update: 'updateInvertButton' } );
+ };
+
/**
* Respond to model update event
*/
- mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.onModelUpdate = function () {
+ mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.onModelSearchChange = function () {
var currentView = this.model.getCurrentView();
- this.setLabel( this.model.getViewTitle( currentView ) );
+ if ( this.view !== currentView ) {
+ this.setLabel( this.model.getViewTitle( currentView ) );
- this.invertNamespacesButton.toggle( currentView === 'namespaces' );
- this.backButton.toggle( currentView !== 'default' );
- this.helpIcon.toggle( currentView === 'tags' );
+ this.invertNamespacesButton.toggle( currentView === 'namespaces' );
+ this.backButton.toggle( currentView !== 'default' );
+ this.helpIcon.toggle( currentView === 'tags' );
+ this.view = currentView;
+ }
};
/**
this.highlightButton.setActive( highlightEnabled );
};
- /**
- * Respond to model invert change event
- *
- * @param {boolean} isInverted Namespaces selection is inverted
- */
- mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.onModelInvertChange = function ( isInverted ) {
- this.updateInvertButton( isInverted );
- };
-
/**
* Update the state of the invert button
- *
- * @param {boolean} isInverted Namespaces selection is inverted
*/
- mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.updateInvertButton = function ( isInverted ) {
- this.invertNamespacesButton.setActive( isInverted );
+ mw.rcfilters.ui.FilterMenuHeaderWidget.prototype.updateInvertButton = function () {
+ this.invertNamespacesButton.setActive( this.invertModel.isSelected() );
this.invertNamespacesButton.setLabel(
- isInverted ?
+ this.invertModel.isSelected() ?
mw.msg( 'rcfilters-exclude-button-on' ) :
mw.msg( 'rcfilters-exclude-button-off' )
);