From 0dddebc82db2d4046167b2c6a02f21cb8e68405d Mon Sep 17 00:00:00 2001 From: Thalia Date: Wed, 13 Feb 2019 13:08:22 +0000 Subject: [PATCH] Uncheck "create account" on Special:Block for partial blocks Set the default state for the checkbox for preventing a user from creating an account to unchecked, if the block is set to partial. However, if the user has already interacted with the checkbox, do not change its state just because the block type changes. Bug: T208510 Change-Id: If17b82b03553810508f22070865719bd1926949d --- resources/src/mediawiki.special.block.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/resources/src/mediawiki.special.block.js b/resources/src/mediawiki.special.block.js index 58409b45c5..02e380ae59 100644 --- a/resources/src/mediawiki.special.block.js +++ b/resources/src/mediawiki.special.block.js @@ -24,7 +24,10 @@ editingRestrictionWidget = infuseIfExists( $( '#mw-input-wpEditingRestriction' ) ), preventTalkPageEdit = infuseIfExists( $( '#mw-input-wpDisableUTEdit' ) ), pageRestrictionsWidget = infuseIfExists( $( '#mw-input-wpPageRestrictions' ) ), - namespaceRestrictionsWidget = infuseIfExists( $( '#mw-input-wpNamespaceRestrictions' ) ); + namespaceRestrictionsWidget = infuseIfExists( $( '#mw-input-wpNamespaceRestrictions' ) ), + createAccountWidget = infuseIfExists( $( '#mw-input-wpCreateAccount' ) ), + userChangedCreateAccount = false, + updatingBlockOptions = false; function updateBlockOptions() { var blocktarget = blockTargetWidget.getValue().trim(), @@ -76,6 +79,11 @@ ) === -1 ); } + if ( !userChangedCreateAccount ) { + updatingBlockOptions = true; + createAccountWidget.setSelected( isSitewide ); + updatingBlockOptions = false; + } } @@ -93,6 +101,12 @@ namespaceRestrictionsWidget.on( 'change', updateBlockOptions ); } + createAccountWidget.on( 'change', function () { + if ( !updatingBlockOptions ) { + userChangedCreateAccount = true; + } + } ); + // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours) updateBlockOptions(); } -- 2.20.1