From 890c9c60602f6f681f6d4e02ea0e0999b34d3d66 Mon Sep 17 00:00:00 2001 From: Moriel Schottlender Date: Tue, 27 Jun 2017 11:19:31 -0700 Subject: [PATCH] RCFilters: Move legend into results (both js and nojs output) Move the legend from the fieldset area to the results area. Bug: T168043 Change-Id: I40454b194fe3975d8d4ac13d96774bfa5b5d5a46 --- includes/specials/SpecialRecentchanges.php | 8 +++++- .../ui/mw.rcfilters.ui.FormWrapperWidget.js | 17 +------------ .../mediawiki.special.changeslist.legend.js | 25 +++++++++++-------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 5ec2064fb2..75d104bb14 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -521,6 +521,10 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' ); $rclistOutput = $list->beginRecentChangesList(); + if ( $this->isStructuredFilterUiEnabled() ) { + $rclistOutput .= $this->makeLegend(); + } + foreach ( $rows as $obj ) { if ( $limit == 0 ) { break; @@ -588,7 +592,9 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $nondefaults = $opts->getChangedValues(); $panel = []; - $panel[] = $this->makeLegend(); + if ( !$this->isStructuredFilterUiEnabled() ) { + $panel[] = $this->makeLegend(); + } $panel[] = $this->optionsPanel( $defaults, $nondefaults, $numRows ); $panel[] = '
'; diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js index 2b10cf0023..dbee65c776 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js @@ -117,8 +117,7 @@ * Clean up the old-style show/hide that we have implemented in the filter list */ mw.rcfilters.ui.FormWrapperWidget.prototype.cleanUpFieldset = function () { - var $namespaceSelect = this.$element.find( '#namespace' ), - collapseCookieName = 'changeslist-state'; + var $namespaceSelect = this.$element.find( '#namespace' ); this.$element.find( '.rcshowhideoption[data-feature-in-structured-ui=1]' ).each( function () { // HACK: Remove the text node after the span. @@ -142,19 +141,5 @@ if ( !this.$element.find( '.mw-recentchanges-table tr' ).length ) { this.$element.find( 'hr' ).detach(); } - - // Collapse legend - // see resources/src/mediawiki.special/mediawiki.special.changelist.legend.js - this.$element.find( '.mw-changeslist-legend' ) - .makeCollapsible( { - collapsed: mw.cookie.get( collapseCookieName ) === 'collapsed' - } ) - .on( 'beforeExpand.mw-collapsible', function () { - mw.cookie.set( collapseCookieName, 'expanded' ); - } ) - .on( 'beforeCollapse.mw-collapsible', function () { - mw.cookie.set( collapseCookieName, 'collapsed' ); - } ); - }; }( mediaWiki ) ); diff --git a/resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js b/resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js index f217bf59aa..ea63e394b0 100644 --- a/resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js +++ b/resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js @@ -7,18 +7,21 @@ var cookieName = 'changeslist-state', // Expanded by default - isCollapsed = mw.cookie.get( cookieName ) === 'collapsed'; + isCollapsed = mw.cookie.get( cookieName ) === 'collapsed', + doCollapsibleLegend = function ( $container ) { + $container.find( '.mw-changeslist-legend' ) + .makeCollapsible( { + collapsed: isCollapsed + } ) + .on( 'beforeExpand.mw-collapsible', function () { + mw.cookie.set( cookieName, 'expanded' ); + } ) + .on( 'beforeCollapse.mw-collapsible', function () { + mw.cookie.set( cookieName, 'collapsed' ); + } ); + }; $( function () { - $( '.mw-changeslist-legend' ) - .makeCollapsible( { - collapsed: isCollapsed - } ) - .on( 'beforeExpand.mw-collapsible', function () { - mw.cookie.set( cookieName, 'expanded' ); - } ) - .on( 'beforeCollapse.mw-collapsible', function () { - mw.cookie.set( cookieName, 'collapsed' ); - } ); + mw.hook( 'wikipage.content' ).add( doCollapsibleLegend ); } ); }( mediaWiki, jQuery ) ); -- 2.20.1