Merge "AllMessagesTablePager: Simplify language handling"
[lhc/web/wiklou.git] / resources / src / mediawiki.special.block.js
index 89bbbc8..b6d9b48 100644 (file)
@@ -19,6 +19,7 @@
                        hideUserField = infuseIfExists( $( '#mw-input-wpHideUser' ).closest( '.oo-ui-fieldLayout' ) ),
                        watchUserField = infuseIfExists( $( '#mw-input-wpWatch' ).closest( '.oo-ui-fieldLayout' ) ),
                        expiryWidget = infuseIfExists( $( '#mw-input-wpExpiry' ) ),
+                       editingWidget = infuseIfExists( $( '#mw-input-wpEditing' ) ),
                        editingRestrictionWidget = infuseIfExists( $( '#mw-input-wpEditingRestriction' ) ),
                        preventTalkPageEdit = infuseIfExists( $( '#mw-input-wpDisableUTEdit' ) ),
                        pageRestrictionsWidget = infuseIfExists( $( '#mw-input-wpPageRestrictions' ) );
                                isIpRange = isIp && blocktarget.match( /\/\d+$/ ),
                                isNonEmptyIp = isIp && !isEmpty,
                                expiryValue = expiryWidget.getValue(),
-                               // infinityValues  are the values the SpecialBlock class accepts as infinity (sf. wfIsInfinity)
+                               // infinityValues are the values the SpecialBlock class accepts as infinity (sf. wfIsInfinity)
                                infinityValues = [ 'infinite', 'indefinite', 'infinity', 'never' ],
                                isIndefinite = infinityValues.indexOf( expiryValue ) !== -1,
-                               editingRestrictionValue = editingRestrictionWidget ? editingRestrictionWidget.getValue() : undefined;
+                               editingRestrictionValue = editingRestrictionWidget ? editingRestrictionWidget.getValue() : undefined,
+                               editingIsSelected = editingWidget ? editingWidget.isSelected() : false;
 
                        if ( enableAutoblockField ) {
-                               enableAutoblockField.toggle( !( isNonEmptyIp ) );
+                               enableAutoblockField.toggle( !isNonEmptyIp );
                        }
                        if ( hideUserField ) {
-                               hideUserField.toggle( !( isNonEmptyIp || !isIndefinite ) );
+                               hideUserField.toggle( !isNonEmptyIp && isIndefinite );
                        }
                        if ( anonOnlyField ) {
-                               anonOnlyField.toggle( !( !isIp && !isEmpty ) );
+                               anonOnlyField.toggle( isIp || isEmpty );
                        }
                        if ( watchUserField ) {
-                               watchUserField.toggle( !( isIpRange && !isEmpty ) );
+                               watchUserField.toggle( !isIpRange || isEmpty );
                        }
                        if ( pageRestrictionsWidget ) {
-                               pageRestrictionsWidget.setDisabled( editingRestrictionValue === 'sitewide' );
+                               editingRestrictionWidget.setDisabled( !editingIsSelected );
+                               pageRestrictionsWidget.setDisabled( !editingIsSelected || editingRestrictionValue === 'sitewide' );
                        }
                        if ( preventTalkPageEdit ) {
                                // TODO: (T210475) this option is disabled for partial blocks unless
                                // a namespace restriction for User_talk namespace is in place.
                                // This needs to be updated once Namespace restrictions is available
-                               if ( editingRestrictionValue === 'partial' ) {
-                                       preventTalkPageEdit.setDisabled( true );
-                               } else {
-                                       preventTalkPageEdit.setDisabled( false );
-                               }
+                               preventTalkPageEdit.setDisabled( editingRestrictionValue === 'partial' && editingIsSelected );
                        }
 
                }
@@ -70,6 +69,9 @@
                        if ( editingRestrictionWidget ) {
                                editingRestrictionWidget.on( 'change', updateBlockOptions );
                        }
+                       if ( editingWidget ) {
+                               editingWidget.on( 'change', updateBlockOptions );
+                       }
 
                        // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
                        updateBlockOptions();