MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/74298
Change subject: Disable and dim other fields if enable-all is on
......................................................................
Disable and dim other fields if enable-all is on
Better handling of enable-all in general.
Change-Id: Ide1da701c1a47613cd9489740cb845e57752f865
---
M SpecialBetaFeatures.php
M css/betafeatures.css
M includes/HTMLBetaFeatureField.php
3 files changed, 38 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures
refs/changes/98/74298/1
diff --git a/SpecialBetaFeatures.php b/SpecialBetaFeatures.php
index f513562..2e9d81e 100644
--- a/SpecialBetaFeatures.php
+++ b/SpecialBetaFeatures.php
@@ -30,20 +30,20 @@
static function getBetaOptions( $context ) {
global $wgUser, $wgExtensionAssetsPath;
- $betaOpts = array();
+ $betaOpts = array(
+ 'enable-all-beta' => array(
+ 'type' => 'checkbox',
+ 'screenshot' => $wgExtensionAssetsPath .
'/BetaFeatures/images/all-beta.png',
+ 'description' => 'betafeatures-enable-all-desc',
+ 'label-message' => 'betafeatures-enable-all',
+ ),
+ );
wfRunHooks( 'GetBetaFeaturePreferences', array( $wgUser,
&$betaOpts ) );
foreach ( $betaOpts as $label => $opt ) {
$betaOpts[$label]['type'] = 'checkbox';
}
-
- $betaOpts['enable-all-beta'] = array(
- 'type' => 'checkbox',
- 'screenshot' => $wgExtensionAssetsPath .
'/BetaFeatures/images/all-beta.png',
- 'description' => 'betafeatures-enable-all-desc',
- 'label-message' => 'betafeatures-enable-all',
- );
return $betaOpts;
}
@@ -56,6 +56,8 @@
$betaOpts = $this->getBetaOptions( $out );
$formFields = array();
+
+ $allEnabled = $user->getOption( 'enable-all-beta' );
foreach ( $betaOpts as $label => $opt ) {
$formFields[$label] = array(
@@ -72,7 +74,14 @@
if ( array_key_exists( 'description', $opt ) ) {
$formFields[$label]['description'] =
$this->msg( $opt['description'] )->escaped();
}
+
+ if ( $allEnabled && $label !== 'enable-all-beta' ) {
+ $formFields[$label]['htmlclass'] =
'all-enabled';
+ $formFields[$label]['disabled'] = true;
+ }
}
+
+ $formFields['enable-all-beta']['default'] = $allEnabled;
$this->setHeaders();
@@ -86,13 +95,10 @@
global $wgUser;
$opts = self::getBetaOptions( $this->getOutput() );
- $enableAll = $data['enable-all-beta'];
+
+ $wgUser->setOption( 'enable-all-beta', $data['enable-all-beta']
);
foreach ( $data as $name => $val ) {
- if ( $enableAll ) {
- $val = true;
- }
-
$wgUser->setOption( 'beta-feature-' . $name, $val );
}
diff --git a/css/betafeatures.css b/css/betafeatures.css
index cc00d8f..8618101 100644
--- a/css/betafeatures.css
+++ b/css/betafeatures.css
@@ -13,7 +13,6 @@
.beta-feature-screenshot {
width: 10%;
display: inline-block;
- float: left;
}
.beta-feature-screenshot img {
@@ -21,7 +20,11 @@
}
.beta-feature-main {
+ margin-left: 1%;
width: 89%;
display: inline-block;
- float: right;
+}
+
+.beta-feature-field.all-enabled {
+ opacity: 0.3;
}
diff --git a/includes/HTMLBetaFeatureField.php
b/includes/HTMLBetaFeatureField.php
index 9873ccb..4b4a9c2 100644
--- a/includes/HTMLBetaFeatureField.php
+++ b/includes/HTMLBetaFeatureField.php
@@ -34,8 +34,21 @@
'id' => $id,
);
+ $classes = array(
+ 'beta-feature-field',
+ );
+
+ if ( array_key_exists( 'htmlclass', $this->mParams ) ) {
+ $classes[] = $this->mParams['htmlclass'];
+ }
+
+ if ( array_key_exists( 'disabled', $this->mParams ) &&
+ $this->mParams['disabled'] === true ) {
+ $attrs['disabled'] = true;
+ }
+
$htmls[] = Html::openElement( 'div', array(
- 'class' => 'beta-feature-field',
+ 'class' => implode( ' ', $classes ),
) );
$hasImage = array_key_exists( 'screenshot', $this->mParams );
--
To view, visit https://gerrit.wikimedia.org/r/74298
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ide1da701c1a47613cd9489740cb845e57752f865
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits