2 * JavaScript for Create account form (Special:UserLogin?type=signup).
6 // When sending password by email, hide the password input fields.
7 // This function doesn't need to be loaded early by ResourceLoader, but is tiny.
8 function hidePasswordOnEmail( $ ) {
9 $( '#wpCreateaccountMail' )
10 .on( 'change', function() {
11 $( '.mw-row-password' ).toggle( !$( this ).attr( 'checked' ) );
16 // Move the FancyCaptcha image into a more attractive container.
17 // This function does need to be run early by ResourceLoader.
18 function adjustFancyCaptcha( $, mw
) {
19 var $content
= $( '#mw-content-text' ),
20 $submit
= $content
.find( '#wpCreateaccount' ),
23 $captchaImageContainer
,
24 // JavaScript can't yet parse the message createacct-imgcaptcha-help when it
25 // contains a MediaWiki transclusion, so PHP parses it and sends the HTML.
26 helpMsg
= mw
.config
.get( 'wgCreateacctImgcaptchaHelp' ),
31 * The CAPTCHA is in a div style="captcha" at the top of the form.
32 * If it's a FancyCaptcha, then we remove it and insert it lower down,
33 * in a customized div with just what we need (e.g. no
34 * fancycaptcha-createaccount message).
36 if ( !$submit
.length
) {
39 tabIndex
= $submit
.prop( 'tabindex' ) - 1;
40 $captchaStuff
= $content
.find ( '.captcha' );
42 if ( $captchaStuff
.length
) {
44 // The FancyCaptcha has this class in the ConfirmEdit extension
46 $captchaImageContainer
= $captchaStuff
.find( '.fancycaptcha-image-container' );
47 if ( $captchaImageContainer
.length
!== 1 ) {
51 $captchaStuff
.remove();
54 helpHtml
= '<small class="mw-createacct-captcha-assisted">' + helpMsg
+ '</small>';
57 // Insert another div before the submit button that will include the
58 // repositioned FancyCaptcha div, an input field, and possible help.
59 $submit
.closest( 'div' )
62 '<label for="wpCaptchaWord">' + mw
.message( 'createacct-captcha' ).escaped() + '</label>',
63 '<div class="mw-createacct-captcha-container">',
64 '<div class="mw-createacct-captcha-and-reload" />',
65 '<input id="wpCaptchaWord" name="wpCaptchaWord" type="text" placeholder="' +
66 mw
.message( 'createacct-imgcaptcha-ph' ).escaped() +
67 '" tabindex="' + tabIndex
+ '" autocapitalize="off" autocorrect="off">',
74 // Stick the FancyCaptcha container inside our bordered and framed parents.
75 $captchaImageContainer
76 .prependTo( $content
.find( '.mw-createacct-captcha-and-reload' ) );
78 // Find the input field, add the text (if any) of the existing CAPTCHA
79 // field (although usually it's blanked out on every redisplay),
80 // and after it move over the hidden field that tells the CAPTCHA
82 $content
.find( '#wpCaptchaWord' )
83 .val( $captchaStuff
.find( '#wpCaptchaWord' ).val() )
84 .after( $captchaStuff
.find( '#wpCaptchaId' ) );
88 $( document
).ready( function( $ ) {
89 adjustFancyCaptcha( $, mw
);
90 hidePasswordOnEmail( $ );
93 }( mediaWiki
, jQuery
) );