RCFilters: Move legend into results (both js and nojs output)
authorMoriel Schottlender <moriel@gmail.com>
Tue, 27 Jun 2017 18:19:31 +0000 (11:19 -0700)
committerMoriel Schottlender <moriel@gmail.com>
Tue, 27 Jun 2017 19:18:34 +0000 (12:18 -0700)
Move the legend from the fieldset area to the results area.

Bug: T168043
Change-Id: I40454b194fe3975d8d4ac13d96774bfa5b5d5a46

includes/specials/SpecialRecentchanges.php
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js
resources/src/mediawiki.special/mediawiki.special.changeslist.legend.js

index 5ec2064..75d104b 100644 (file)
@@ -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[] = '<hr />';
 
index 2b10cf0..dbee65c 100644 (file)
         * 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.
                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 ) );
index f217bf5..ea63e39 100644 (file)
@@ -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 ) );