SpecialContributions: Conditionally hide the namespace checkboxes
authorFomafix <fomafix@googlemail.com>
Sun, 17 Feb 2019 19:02:22 +0000 (20:02 +0100)
committerFomafix <fomafix@googlemail.com>
Tue, 5 Mar 2019 05:14:59 +0000 (06:14 +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: T134556
Change-Id: I84198472307532ab89c499cb75f946aeb471405f

includes/specials/SpecialContributions.php

index 84121b2..d9e76be 100644 (file)
@@ -45,6 +45,7 @@ class SpecialContributions extends IncludableSpecialPage {
                        'mediawiki.special',
                        'mediawiki.special.changeslist',
                ] );
+               $out->addModules( 'mediawiki.special.recentchanges' );
                $this->addHelpLink( 'Help:User contributions' );
 
                $this->opts = [];
@@ -606,6 +607,7 @@ class SpecialContributions extends IncludableSpecialPage {
                        $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' '
                );
 
+               $hidden = $this->opts['namespace'] === '' ? ' mw-input-hidden' : '';
                $namespaceSelection = Xml::tags(
                        'div',
                        [],
@@ -624,11 +626,11 @@ class SpecialContributions extends IncludableSpecialPage {
                        ) . "\u{00A0}" .
                                Html::rawElement(
                                        'span',
-                                       [ 'class' => 'mw-input-with-label' ],
+                                       [ 'class' => 'mw-input-with-label' . $hidden ],
                                        Xml::checkLabel(
                                                $this->msg( 'invert' )->text(),
                                                'nsInvert',
-                                               'nsInvert',
+                                               'nsinvert',
                                                $this->opts['nsInvert'],
                                                [
                                                        'title' => $this->msg( 'tooltip-invert' )->text(),
@@ -636,11 +638,11 @@ class SpecialContributions extends IncludableSpecialPage {
                                                ]
                                        ) . "\u{00A0}"
                                ) .
-                               Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ],
+                               Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' . $hidden ],
                                        Xml::checkLabel(
                                                $this->msg( 'namespace_association' )->text(),
                                                'associated',
-                                               'associated',
+                                               'nsassociated',
                                                $this->opts['associated'],
                                                [
                                                        'title' => $this->msg( 'tooltip-namespace_association' )->text(),