Merge "Preferences: Remove href="#" from stub threshold sample link"
[lhc/web/wiklou.git] / resources / src / mediawiki.special.block.js
index 58409b4..02e380a 100644 (file)
                        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(),
                                        ) === -1
                                );
                        }
+                       if ( !userChangedCreateAccount ) {
+                               updatingBlockOptions = true;
+                               createAccountWidget.setSelected( isSitewide );
+                               updatingBlockOptions = false;
+                       }
 
                }
 
                                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();
                }