jenkins-bot has submitted this change and it was merged. ( 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 Depends-On: Ib04701464e4869c0b89387b7291d2eb6326e3fc0 Change-Id: I3dcd540a29635614aaa9404b8482d1493fda0c3c --- M .eslintrc.json M extension.json M resources/ext.GlobalPreferences.local.js 3 files changed, 30 insertions(+), 3 deletions(-) Approvals: MaxSem: Looks good to me, approved jenkins-bot: Verified diff --git a/.eslintrc.json b/.eslintrc.json index 4843240..a29fd88 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,6 +5,7 @@ "jquery": true }, "globals": { - "mediaWiki": false + "mediaWiki": false, + "OO": false } } diff --git a/extension.json b/extension.json index dcc2d9c..ced4d65 100644 --- a/extension.json +++ b/extension.json @@ -60,7 +60,8 @@ }, "ext.GlobalPreferences.local": { "styles": "ext.GlobalPreferences.local.css", - "scripts": "ext.GlobalPreferences.local.js" + "scripts": "ext.GlobalPreferences.local.js", + "dependencies": [ "oojs-ui-core" ] }, "ext.GlobalPreferences.local-nojs": { "styles": "ext.GlobalPreferences.local-nojs.css" diff --git a/resources/ext.GlobalPreferences.local.js b/resources/ext.GlobalPreferences.local.js index 5f68fbe..e2c40cf 100644 --- a/resources/ext.GlobalPreferences.local.js +++ b/resources/ext.GlobalPreferences.local.js @@ -1 +1,26 @@ -// @TODO re-enable global preferences. T178267 +( function ( mw, $, OO ) { + '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, OO ) ); -- To view, visit https://gerrit.wikimedia.org/r/403582 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I3dcd540a29635614aaa9404b8482d1493fda0c3c Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/GlobalPreferences Gerrit-Branch: master Gerrit-Owner: Samwilson <s...@samwilson.id.au> Gerrit-Reviewer: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: Samwilson <s...@samwilson.id.au> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits