Merge "Make it show email as required if you choose to email a random password."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 5 Jul 2013 21:35:51 +0000 (21:35 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 5 Jul 2013 21:35:51 +0000 (21:35 +0000)
resources/Resources.php
resources/mediawiki.special/mediawiki.special.createAccount.js

index 43116e4..02cde52 100644 (file)
@@ -985,6 +985,7 @@ return array(
                'scripts' => 'resources/mediawiki.special/mediawiki.special.createAccount.js',
                'messages' => array(
                        'createacct-captcha',
+                       'createacct-emailrequired',
                        'createacct-imgcaptcha-ph'
                ),
                'dependencies' => 'mediawiki.jqueryMsg',
index aa61a1e..2cd5625 100644 (file)
@@ -6,11 +6,25 @@
        // When sending password by email, hide the password input fields.
        // This function doesn't need to be loaded early by ResourceLoader, but is tiny.
        function hidePasswordOnEmail( $ ) {
-               $( '#wpCreateaccountMail' )
-                       .on( 'change', function() {
-                               $( '.mw-row-password' ).toggle( !$( this ).attr( 'checked' ) );
-                       } )
-                       .trigger( 'change' );
+               // Always required if checked, otherwise it depends, so we use the original
+               var $emailLabel = $( 'label[for="wpEmail"]' ),
+                       originalText = $emailLabel.text(),
+                       requiredText = mw.message( 'createacct-emailrequired' ).text(),
+                       $createByMailCheckbox = $( '#wpCreateaccountMail' );
+
+               function updateForCheckbox() {
+                       var checked = $createByMailCheckbox.prop( 'checked' );
+                       if ( checked ) {
+                               $( '.mw-row-password' ).hide();
+                               $emailLabel.text( requiredText );
+                       } else {
+                               $( '.mw-row-password' ).show();
+                               $emailLabel.text( originalText );
+                       }
+               }
+
+               $createByMailCheckbox.on( 'change', updateForCheckbox );
+               updateForCheckbox();
        }
 
        // Move the FancyCaptcha image into a more attractive container.