$classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns' .
$rc->mAttribs['rc_namespace'] . '-' . $rc->mAttribs['rc_title'] );
}
- $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
- $rc->mAttribs['rc_namespace'] );
// Indicate watched status on the line to allow for more
// comprehensive styling.
}
/**
- * Get an array of CSS classes attributed to filters for this row
+ * Get an array of CSS classes attributed to filters for this row. Used for highlighting
+ * in the front-end.
*
* @param RecentChange $rc
* @return array Array of CSS classes
protected function getHTMLClassesForFilters( $rc ) {
$classes = [];
+ $classes[] = Sanitizer::escapeClass( self::CSS_CLASS_PREFIX . 'ns-' .
+ $rc->mAttribs['rc_namespace'] );
+
if ( $this->filterGroups !== null ) {
foreach ( $this->filterGroups as $filterGroup ) {
foreach ( $filterGroup->getFilters() as $filter ) {
# Sub-entries
$lines = [];
+ $filterClasses = [];
foreach ( $block as $i => $rcObj ) {
$line = $this->getLineData( $block, $rcObj, $queryParams );
if ( !$line ) {
}
}
+ // Roll up filter-based CSS classes
+ $filterClasses = array_merge( $filterClasses, $this->getHTMLClassesForFilters( $rcObj ) );
+ // Add classes for change tags separately, getHTMLClassesForFilters() doesn't add them
+ $this->getTags( $rcObj, $filterClasses );
+ $filterClasses = array_unique( $filterClasses );
+
$lines[] = $line;
}
// Further down are some assumptions that $block is a 0-indexed array
// with (count-1) as last key. Let's make sure it is.
$block = array_values( $block );
+ $filterClasses = array_values( $filterClasses );
if ( empty( $block ) || !$lines ) {
// if we can't show anything, don't display this block altogether
'articleLink' => $articleLink,
'charDifference' => $charDifference,
'collectedRcFlags' => $this->recentChangesFlags( $collectedRcFlags ),
+ 'filterClasses' => $filterClasses,
'languageDirMark' => $this->getLanguage()->getDirMark(),
'lines' => $lines,
'logText' => $logText,
<table class="{{# tableClasses }}{{ . }} {{/ tableClasses }}" data-mw-ts="{{{ fullTimestamp }}}">
- <tr class="mw-rcfilters-ui-highlights-enhanced-toplevel">
+ <tr class="mw-rcfilters-ui-highlights-enhanced-toplevel {{# filterClasses }}{{ . }} {{/ filterClasses }}">
<td>
<div class="mw-rcfilters-ui-highlights">
<div class="mw-rcfilters-ui-highlights-color-none" data-color="none"></div>
*/
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 );
};
/**
}
}
- // 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