2 * JavaScript for Create account form (Special:UserLogin?type=signup).
6 $( document
).ready( function( $ ) {
7 var $content
= $( '#mw-content-text' ),
8 $submit
= $content
.find( '#wpCreateaccount' ),
11 helpMsg
= mw
.config
.get( 'wgCreateacctImgcaptchaHelp' ),
16 * The CAPTCHA is in a div style="captcha" at the top of the form.
17 * If it's a FancyCaptcha, then we remove it and insert it lower down,
18 * in a customized div with just what we need (e.g. no
19 * fancycaptcha-createaccount message).
21 if ( !$submit
.length
) {
24 tabIndex
= $submit
.prop( 'tabindex' ) - 1;
25 $captchaStuff
= $content
.find ( '.captcha' );
27 if ( $captchaStuff
.length
) {
29 // The FancyCaptcha image has this class in the ConfirmEdit extension
31 captchaImage
= $captchaStuff
.find( 'img.fancycaptcha-image' );
32 if ( captchaImage
.length
!== 1 ) {
36 $captchaStuff
.remove();
38 // Insert another div before the submit button.
39 $submit
.closest( 'div' )
42 '<label for="wpCaptchaWord">' + mw
.message( 'createacct-captcha' ).escaped() + '</label>',
43 '<div class="mw-createacct-captcha-container">',
44 '<div class="mw-createacct-captcha-and-reload">',
45 '<div class="mw-createacct-captcha-image-container">',
46 '<img id="mw-createacct-captcha" alt="PLACEHOLDER">',
49 '<input id="wpCaptchaWord" name="wpCaptchaWord" type="text" placeholder="' +
50 mw
.message( 'createacct-imgcaptcha-ph' ).escaped() +
51 '" tabindex="' + tabIndex
+ '" autocapitalize="off" autocorrect="off">',
52 '<small class="mw-createacct-captcha-assisted">' + helpMsg
+ '</small>',
58 // Replace the placeholder img with the img from the old CAPTCHA.
59 captchaImage
.replaceAll( $content
.find( '#mw-createacct-captcha' ) );
61 // Append CAPTCHA reload, if any.
62 $( '.mw-createacct-captcha-and-reload' ).append( $captchaStuff
.find( '.confirmedit-captcha-reload' ) );
64 // Find the input field, add the text (if any) of the existing CAPTCHA
65 // field (although usually it's blanked out on every redisplay),
66 // and after it move over the hidden field that tells the CAPTCHA
68 $content
.find( '#wpCaptchaWord' )
69 .val( $captchaStuff
.find( '#wpCaptchaWord' ).val() )
70 .after( $captchaStuff
.find( '#wpCaptchaId' ) );
75 }( mediaWiki
, jQuery
) );