Make it show email as required if you choose to email a random password.

* Use prop( 'checked' ) as recommended by jQuery.

Bug: 47686
Change-Id: Iaf789db6e49396a19decdc2e5ee5cccf155fe78d
This commit is contained in:
Matthew Flaschen 2013-04-25 20:12:49 -04:00
parent a0c6d38d22
commit 2eac57b977
2 changed files with 20 additions and 5 deletions

View file

@ -982,6 +982,7 @@ return array(
'scripts' => 'resources/mediawiki.special/mediawiki.special.createAccount.js',
'messages' => array(
'createacct-captcha',
'createacct-emailrequired',
'createacct-imgcaptcha-ph'
),
'dependencies' => 'mediawiki.jqueryMsg',

View 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.