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

Change subject: Enable/disable related preference field with local exception 
checkbox.
......................................................................

Enable/disable related preference field with local exception checkbox.

When the local-exception checkbox is changed, enable or disable
the related preference field. Also takes into account OOUI fields
such as is used by BetaFeatures.

Bug: T178267
Change-Id: I3dcd540a29635614aaa9404b8482d1493fda0c3c
---
M resources/ext.GlobalPreferences.local.js
1 file changed, 26 insertions(+), 1 deletion(-)


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

diff --git a/resources/ext.GlobalPreferences.local.js 
b/resources/ext.GlobalPreferences.local.js
index 5f68fbe..e36b1b3 100644
--- a/resources/ext.GlobalPreferences.local.js
+++ b/resources/ext.GlobalPreferences.local.js
@@ -1 +1,26 @@
-// @TODO re-enable global preferences. T178267
+( function ( mw, $ ) {
+       'use strict';
+
+       /**
+        * Enable and disable the related preference field when selecting the 
local exception checkbox.
+        */
+       $( ':input.mw-globalprefs-local-exception' ).on( 'change', function () {
+               var localExName, prefName, enabled, $prefInput, oouiWidget;
+               // Figure out what the preference name is by stripping the 
local exception suffix.
+               localExName = $( this ).attr( 'name' );
+               prefName = localExName.substr( 0, localExName.length - 
'-local-exception'.length );
+               enabled = $( this ).prop( 'checked' );
+               $prefInput = $( ':input[name="' + prefName + '"]' );
+
+               if ( $prefInput.parent( '.oo-ui-widget' ).length > 0 ) {
+                       // First see if this is a OOUI field.
+                       oouiWidget = OO.ui.infuse( $prefInput.parent( 
'.oo-ui-widget' ) );
+                       oouiWidget.setDisabled( !enabled );
+
+               } else {
+                       // Otherwise treat it as a normal form input.
+                       $prefInput.prop( 'disabled', !enabled );
+               }
+       } );
+
+}( mediaWiki, jQuery ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3dcd540a29635614aaa9404b8482d1493fda0c3c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalPreferences
Gerrit-Branch: master
Gerrit-Owner: Samwilson <s...@samwilson.id.au>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to