-( function ( mw ) {
+( function () {
/**
* List of changes
*
this.changesListViewModel = changesListViewModel;
this.controller = controller;
this.highlightClasses = null;
- this.filtersModelInitialized = false;
// Events
this.filtersViewModel.connect( this, {
itemUpdate: 'onItemUpdate',
- highlightChange: 'onHighlightChange',
- initialize: 'onFiltersModelInitialize'
+ highlightChange: 'onHighlightChange'
} );
this.changesListViewModel.connect( this, {
invalidate: 'onModelInvalidate',
OO.inheritClass( mw.rcfilters.ui.ChangesListWrapperWidget, OO.ui.Widget );
- /**
- * Respond to filters model initialize event
- */
- mw.rcfilters.ui.ChangesListWrapperWidget.prototype.onFiltersModelInitialize = function () {
- this.filtersModelInitialized = true;
- // Set up highlight containers. We need to wait for the filters model
- // to be initialized, so we can make sure we have all the css class definitions
- // we get from the server with our filters
- this.setupHighlightContainers( this.$element );
- };
-
/**
* Get all available highlight classes
*
* Respond to a filter item model update
*/
mw.rcfilters.ui.ChangesListWrapperWidget.prototype.onItemUpdate = function () {
- if ( this.filtersModelInitialized && this.filtersViewModel.isHighlightEnabled() ) {
+ if ( this.controller.isInitialized() && this.filtersViewModel.isHighlightEnabled() ) {
+ // this.controller.isInitialized() is still false during page load,
+ // we don't want to clear/apply highlights at this stage.
this.clearHighlight();
this.applyHighlight();
}
}
}
- // Set up highlight containers
- this.setupHighlightContainers( this.$element );
-
// Apply highlight
this.applyHighlight();
.fadeIn( 1000 );
};
- /**
- * Set up the highlight containers with all color circle indicators.
- *
- * @param {jQuery|string} $content The content of the updated changes list
- */
- mw.rcfilters.ui.ChangesListWrapperWidget.prototype.setupHighlightContainers = function ( $content ) {
- var $enhancedTopPageCell,
- widget = this;
-
- if ( this.inEnhancedMode() ) {
- $enhancedTopPageCell = $content.find( 'table.mw-enhanced-rc.mw-collapsible' );
- // Go over pages that have sub results
- // HACK: We really only can collect those by targetting the collapsible class
- $enhancedTopPageCell.each( function () {
- var collectedClasses,
- $table = $( this );
-
- // Go over <tr>s and pick up all recognized classes
- collectedClasses = widget.getHighlightClasses().filter( function ( className ) {
- return $table.find( 'tr' ).hasClass( className );
- } );
-
- $table.find( 'tr:first-child' )
- .addClass( collectedClasses.join( ' ' ) );
- } );
- }
- };
-
/**
* In enhanced mode, we need to check whether the grouped results all have the
* same active highlights in order to see whether the "parent" of the group should
// Turn off highlights
this.$element.removeClass( 'mw-rcfilters-ui-changesListWrapperWidget-highlighted' );
};
-}( mediaWiki ) );
+}() );