Merge "Make Language::fetchLanguageName lowercase its first argument."
[lhc/web/wiklou.git] / resources / mediawiki.special / mediawiki.special.userlogin.signup.js
1 /**
2 * JavaScript for signup form.
3 */
4 ( function ( mw, $ ) {
5 // When sending password by email, hide the password input fields.
6 function hidePasswordOnEmail() {
7 // Always required if checked, otherwise it depends, so we use the original
8 var $emailLabel = $( 'label[for="wpEmail"]' ),
9 originalText = $emailLabel.text(),
10 requiredText = mw.message( 'createacct-emailrequired' ).text(),
11 $createByMailCheckbox = $( '#wpCreateaccountMail' ),
12 $beforePwds = $( '.mw-row-password:first' ).prev(),
13 $pwds;
14
15 function updateForCheckbox() {
16 var checked = $createByMailCheckbox.prop( 'checked' );
17 if ( checked ) {
18 $pwds = $( '.mw-row-password' ).detach();
19 $emailLabel.text( requiredText );
20 } else {
21 if ( $pwds ) {
22 $beforePwds.after( $pwds );
23 $pwds = null;
24 }
25 $emailLabel.text( originalText );
26 }
27 }
28
29 $createByMailCheckbox.on( 'change', updateForCheckbox );
30 updateForCheckbox();
31 }
32
33 $( hidePasswordOnEmail );
34 }( mediaWiki, jQuery ) );