}
$( function () {
- var blockTargetWidget, anonOnlyField, enableAutoblockField, hideUserWidget, hideUserField,
- watchUserField, expiryWidget, editingWidget, editingRestrictionWidget, preventTalkPageEditWidget,
+ var blockTargetWidget, anonOnlyWidget, enableAutoblockWidget, hideUserWidget, watchUserWidget,
+ expiryWidget, editingWidget, editingRestrictionWidget, preventTalkPageEditWidget,
pageRestrictionsWidget, namespaceRestrictionsWidget, createAccountWidget, data,
enablePartialBlocks, blockAllowsUTEdit, userChangedCreateAccount, updatingBlockOptions;
editingIsSelected = editingWidget.isSelected(),
isSitewide = editingIsSelected && editingRestrictionValue === 'sitewide';
- enableAutoblockField.toggle( !isNonEmptyIp );
- anonOnlyField.toggle( isIp || isEmpty );
+ enableAutoblockWidget.setDisabled( isNonEmptyIp );
+ if ( enableAutoblockWidget.isDisabled() ) {
+ enableAutoblockWidget.setSelected( false );
+ }
+
+ anonOnlyWidget.setDisabled( !isIp && !isEmpty );
+ if ( anonOnlyWidget.isDisabled() ) {
+ anonOnlyWidget.setSelected( false );
+ }
- if ( hideUserField ) {
- hideUserField.toggle( !isNonEmptyIp && isIndefinite && isSitewide );
- if ( !hideUserField.isVisible() ) {
+ if ( hideUserWidget ) {
+ hideUserWidget.setDisabled( isNonEmptyIp || !isIndefinite || !isSitewide );
+ if ( hideUserWidget.isDisabled() ) {
hideUserWidget.setSelected( false );
}
}
- if ( watchUserField ) {
- watchUserField.toggle( !isIpRange || isEmpty );
+ if ( watchUserWidget ) {
+ watchUserWidget.setDisabled( isIpRange && !isEmpty );
+ if ( watchUserWidget.isDisabled() ) {
+ watchUserWidget.setSelected( false );
+ }
}
if ( enablePartialBlocks ) {
pageRestrictionsWidget.setDisabled( !editingIsSelected || isSitewide );
namespaceRestrictionsWidget.setDisabled( !editingIsSelected || isSitewide );
if ( blockAllowsUTEdit ) {
- // This option is disabled for partial blocks unless a namespace restriction
- // for the User_talk namespace is in place.
+ // Disable for partial blocks, unless the block is against the User_talk namespace
preventTalkPageEditWidget.setDisabled(
- editingIsSelected &&
- editingRestrictionValue === 'partial' &&
- namespaceRestrictionsWidget.getValue().indexOf(
- String( mw.config.get( 'wgNamespaceIds' ).user_talk )
- ) === -1
+ // Partial block that doesn't block editing
+ !editingIsSelected ||
+ // Partial block that blocks editing and doesn't block the User_talk namespace
+ (
+ editingRestrictionValue === 'partial' &&
+ namespaceRestrictionsWidget.getValue().indexOf(
+ String( mw.config.get( 'wgNamespaceIds' ).user_talk )
+ ) === -1
+ )
);
}
}
editingWidget = OO.ui.infuse( $( '#mw-input-wpEditing' ) );
expiryWidget = OO.ui.infuse( $( '#mw-input-wpExpiry' ) );
createAccountWidget = OO.ui.infuse( $( '#mw-input-wpCreateAccount' ) );
- enableAutoblockField = OO.ui.infuse( $( '#mw-input-wpAutoBlock' ).closest( '.oo-ui-fieldLayout' ) );
- anonOnlyField = OO.ui.infuse( $( '#mw-input-wpHardBlock' ).closest( '.oo-ui-fieldLayout' ) );
+ enableAutoblockWidget = OO.ui.infuse( $( '#mw-input-wpAutoBlock' ) );
+ anonOnlyWidget = OO.ui.infuse( $( '#mw-input-wpHardBlock' ) );
blockTargetWidget.on( 'change', updateBlockOptions );
editingWidget.on( 'change', updateBlockOptions );
expiryWidget.on( 'change', updateBlockOptions );
} );
// Present for certain rights
- watchUserField = infuseIfExists( $( '#mw-input-wpWatch' ).closest( '.oo-ui-fieldLayout' ) );
- hideUserField = infuseIfExists( $( '#mw-input-wpHideUser' ).closest( '.oo-ui-fieldLayout' ) );
+ watchUserWidget = infuseIfExists( $( '#mw-input-wpWatch' ) );
hideUserWidget = infuseIfExists( $( '#mw-input-wpHideUser' ) );
// Present for certain global configs