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 $captchaImageContainer
,
12 // JavaScript can't yet parse the message createacct-imgcaptcha-help when it
13 // contains a MediaWiki transclusion, so PHP parses it and sends the HTML.
14 helpMsg
= mw
.config
.get( 'wgCreateacctImgcaptchaHelp' ),
19 * The CAPTCHA is in a div style="captcha" at the top of the form.
20 * If it's a FancyCaptcha, then we remove it and insert it lower down,
21 * in a customized div with just what we need (e.g. no
22 * fancycaptcha-createaccount message).
24 if ( !$submit
.length
) {
27 tabIndex
= $submit
.prop( 'tabindex' ) - 1;
28 $captchaStuff
= $content
.find ( '.captcha' );
30 if ( $captchaStuff
.length
) {
32 // The FancyCaptcha has this class in the ConfirmEdit extension
34 $captchaImageContainer
= $captchaStuff
.find( '.fancycaptcha-image-container' );
35 if ( $captchaImageContainer
.length
!== 1 ) {
39 $captchaStuff
.remove();
42 helpHtml
= '<small class="mw-createacct-captcha-assisted">' + helpMsg
+ '</small>';
45 // Insert another div before the submit button that will include the
46 // repositioned FancyCaptcha div, an input field, and possible help.
47 $submit
.closest( 'div' )
50 '<label for="wpCaptchaWord">' + mw
.message( 'createacct-captcha' ).escaped() + '</label>',
51 '<div class="mw-createacct-captcha-container">',
52 '<div class="mw-createacct-captcha-and-reload" />',
53 '<input id="wpCaptchaWord" name="wpCaptchaWord" type="text" placeholder="' +
54 mw
.message( 'createacct-imgcaptcha-ph' ).escaped() +
55 '" tabindex="' + tabIndex
+ '" autocapitalize="off" autocorrect="off">',
62 // Stick the FancyCaptcha container inside our bordered and framed parents.
63 $captchaImageContainer
64 .prependTo( $content
.find( '.mw-createacct-captcha-and-reload' ) );
66 // Find the input field, add the text (if any) of the existing CAPTCHA
67 // field (although usually it's blanked out on every redisplay),
68 // and after it move over the hidden field that tells the CAPTCHA
70 $content
.find( '#wpCaptchaWord' )
71 .val( $captchaStuff
.find( '#wpCaptchaWord' ).val() )
72 .after( $captchaStuff
.find( '#wpCaptchaId' ) );
77 }( mediaWiki
, jQuery
) );