SpecialWatchlist: Conditionally hide the namespace checkboxes
authorFomafix <fomafix@googlemail.com>
Sun, 17 Feb 2019 18:07:12 +0000 (19:07 +0100)
committerFomafix <fomafix@googlemail.com>
Tue, 5 Mar 2019 05:13:52 +0000 (06:13 +0100)
This changes hides the namespace checkboxes like on
SpecialRecentchanges.

Load the module 'mediawiki.special.recentchanges' which shows/hides the
checkboxes on change of the namespace selector.

Set the initial state of the visibility of the checkboxes already in the
HTML to prevent a flash of the checkboxes while loading.

Bug: T38317
Change-Id: I7ceb55088165c3c9bb17f6cfd4bfc6e800da9cc7

includes/specials/SpecialWatchlist.php

index 7772ef7..3b595e4 100644 (file)
@@ -63,6 +63,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $this->addHelpLink( 'Help:Watching pages' );
                $output->addModuleStyles( [ 'mediawiki.special' ] );
                $output->addModules( [
+                       'mediawiki.special.recentchanges',
                        'mediawiki.special.watchlist',
                ] );
 
@@ -655,14 +656,15 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                                'class' => 'namespaceselector',
                        ]
                ) . "\n";
-               $namespaceForm .= '<span class="mw-input-with-label">' . Xml::checkLabel(
+               $hidden = $opts['namespace'] === '' ? ' mw-input-hidden' : '';
+               $namespaceForm .= '<span class="mw-input-with-label' . $hidden . '">' . Xml::checkLabel(
                        $this->msg( 'invert' )->text(),
                        'invert',
                        'nsinvert',
                        $opts['invert'],
                        [ 'title' => $this->msg( 'tooltip-invert' )->text() ]
                ) . "</span>\n";
-               $namespaceForm .= '<span class="mw-input-with-label">' . Xml::checkLabel(
+               $namespaceForm .= '<span class="mw-input-with-label' . $hidden . '">' . Xml::checkLabel(
                        $this->msg( 'namespace_association' )->text(),
                        'associated',
                        'nsassociated',