Samwilson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/367874 )

Change subject: Disable prefs in GlobalPreferences unless they're enabled
......................................................................

Disable prefs in GlobalPreferences unless they're enabled

Also highlight the relevant preference labels on hover over
the global checkbox.

Bug: T68869
Change-Id: Icde9ffbda6209fd866415b29774247396119166f
---
M SpecialGlobalPreferences.php
M extension.json
M resources/ext.GlobalPreferences.special.css
A resources/ext.GlobalPreferences.special.js
4 files changed, 44 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalPreferences 
refs/changes/74/367874/1

diff --git a/SpecialGlobalPreferences.php b/SpecialGlobalPreferences.php
index 9d317e0..dd6e888 100644
--- a/SpecialGlobalPreferences.php
+++ b/SpecialGlobalPreferences.php
@@ -16,7 +16,7 @@
                        $this->setHeaders();
                        throw new ErrorPageError( 'globalprefs-error-header', 
'globalprefs-notglobal' );
                }
-               $this->getOutput()->addModuleStyles( 
'ext.GlobalPreferences.special' );
+               $this->getOutput()->addModules( 'ext.GlobalPreferences.special' 
);
                parent::execute( $par );
        }
 
diff --git a/extension.json b/extension.json
index 58a4dd7..31434a0 100644
--- a/extension.json
+++ b/extension.json
@@ -50,7 +50,8 @@
        },
        "ResourceModules": {
                "ext.GlobalPreferences.special": {
-                       "styles": "ext.GlobalPreferences.special.css"
+                       "styles": "ext.GlobalPreferences.special.css",
+                       "scripts": "ext.GlobalPreferences.special.js"
                }
        },
        "manifest_version": 1
diff --git a/resources/ext.GlobalPreferences.special.css 
b/resources/ext.GlobalPreferences.special.css
index 7510123..a67ee78 100644
--- a/resources/ext.GlobalPreferences.special.css
+++ b/resources/ext.GlobalPreferences.special.css
@@ -1,6 +1,12 @@
 input.mw-globalprefs-global-check {
-       margin-left: 20px;
+       margin-left: 2em;
 }
 tr.mw-globalprefs-global-check {
-       font-size: 13px;
+       font-size: smaller;
+}
+.globalprefs-disabled {
+       opacity: 0.5;
+}
+.globalprefs-hover {
+       background-color: rgba(255, 224, 97, 0.5);
 }
diff --git a/resources/ext.GlobalPreferences.special.js 
b/resources/ext.GlobalPreferences.special.js
new file mode 100644
index 0000000..a7623dc
--- /dev/null
+++ b/resources/ext.GlobalPreferences.special.js
@@ -0,0 +1,33 @@
+( function ( mw, $ ) {
+       'use strict';
+
+       $("input.mw-globalprefs-global-check").on('change', function() {
+
+               // Find the name (without the '-global' suffix, but with the 
'wp' prefix).
+               var fullName = $(this).attr( "name" );
+               var name = fullName.substr( 0, fullName.length - 
"-global".length );
+
+               // Is this preferenced enabled globally?
+               var enabled = $(this).prop( "checked" );
+
+               // Disable or enable the related preferences inputs.
+               $( ":input[name='"+name+"']" ).prop( "disabled", !enabled );
+               var labels = $( "label[for^='mw-input-" + name + 
"']:not([for$='-global'])" );
+               if (enabled) {
+                       labels.removeClass("globalprefs-disabled");
+               } else {
+                       labels.addClass("globalprefs-disabled");
+               }
+
+               // Add a class on hover, to highlight the related labels.
+               $(this).add( "label[for='" + $(this).attr("id") + "']" ).hover( 
function() {
+                       // Hover on.
+                       $( "label[for^='mw-input-" + name + "']" ).addClass( 
"globalprefs-hover" );
+               }, function() {
+                       // Hover off.
+                       $( "label[for^='mw-input-" + name + "']" ).removeClass( 
"globalprefs-hover");
+               } );
+
+       } ).change();
+
+}( mediaWiki, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/367874
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icde9ffbda6209fd866415b29774247396119166f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to