Form improvements when creating another's account
authorS Page <spage@wikimedia.org>
Tue, 9 Jul 2013 04:35:43 +0000 (21:35 -0700)
committerS Page <spage@wikimedia.org>
Wed, 17 Jul 2013 22:03:37 +0000 (15:03 -0700)
Detect a logged-in user creating an account for someone else and change
messages:
* heading is "Enter the new account information below."
* username placeholder is "Enter the username", not "Enter your username"
* email field placeholder is "Enter email address" not "Enter your ..."
* submit button is "Create another account"

Also improve JS when e-mail password is checked to remove the password
fields (otherwise the form still submits them and browser prompts to
remember password).

Bug: 47792
Change-Id: I00e0d21d63bf32ad691ea3a27523298478e2d45c

includes/specials/SpecialUserlogin.php
includes/templates/Usercreate.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc
resources/mediawiki.special/mediawiki.special.createAccount.js

index b1a123e..6e557f3 100644 (file)
@@ -1153,6 +1153,12 @@ class LoginForm extends SpecialPage {
                $template->set( 'cansecurelogin', ( $wgSecureLogin === true ) );
                $template->set( 'stickHTTPS', $this->mStickHTTPS );
 
+               if ( $this->mType === 'signup' && $user->isLoggedIn() ) {
+                       $template->set( 'createAnother', true );
+               } else {
+                       $template->set( 'createAnother', false );
+               }
+
                if ( $this->mType == 'signup' ) {
                        if ( !self::getCreateaccountToken() ) {
                                self::setCreateaccountToken();
index c066da9..c7a0014 100644 (file)
@@ -56,7 +56,12 @@ class UsercreateTemplate extends BaseTemplate {
        }
        ?>
 <div id="userloginForm">
-<h2 class="createaccount-join"><?php $this->msg( 'createacct-join' ); ?></h2>
+<h2 class="createaccount-join">
+       <?php
+       $this->msg( $this->data['createAnother'] ?
+               'createacct-another-join' : 'createacct-join' );
+       ?>
+</h2>
 <form name="userlogin2" id="userlogin2" class="mw-ui-vform" method="post" action="<?php $this->text( 'action' ); ?>">
        <section class="mw-form-header">
                <?php $this->html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
@@ -77,15 +82,17 @@ class UsercreateTemplate extends BaseTemplate {
 
                                <span class="mw-ui-flush-right"><?php echo $this->getMsg( 'createacct-helpusername' )->parse(); ?></span>
                        </label>
-                       <?php echo Html::input( 'wpName', $this->data['name'], 'text', array(
+                       <?php
+                       echo Html::input( 'wpName', $this->data['name'], 'text', array(
                                'class' => 'mw-input loginText',
                                'id' => 'wpName2',
                                'tabindex' => '1',
                                'size' => '20',
                                'required',
-                               'placeholder' => $this->getMsg( 'userlogin-yourname-ph' )->text(),
-                               'autofocus'
-                       ) ); ?>
+                               'placeholder' => $this->getMsg( $this->data['createAnother'] ?
+                                       'createacct-another-username-ph' : 'userlogin-yourname-ph' )->text(),
+                       ) );
+                       ?>
                </div>
                <div>
                <?php if ( $this->data['createemail'] ) { ?>
@@ -155,7 +162,8 @@ class UsercreateTemplate extends BaseTemplate {
                                        'id' => 'wpEmail',
                                        'tabindex' => '6',
                                        'size' => '20',
-                                       'placeholder' => $this->getMsg( 'createacct-email-ph' )->text()
+                                       'placeholder' => $this->getMsg( $this->data['createAnother'] ?
+                                               'createacct-another-email-ph' : 'createacct-email-ph' )->text()
                                ) + ( $this->data['emailrequired'] ? array() : array( 'required' => '' ) ) );
                        ?>
                <?php } ?>
@@ -243,9 +251,17 @@ class UsercreateTemplate extends BaseTemplate {
                $tabIndex++;
                ?>
                <div class="mw-submit">
-                       <input type='submit' class="mw-ui-button mw-ui-big mw-ui-block mw-ui-primary" name="wpCreateaccount" id="wpCreateaccount"
-                               tabindex="<?php echo $tabIndex++; ?>"
-                               value="<?php $this->msg( 'createacct-submit' ); ?>" />
+                       <?php
+                       echo Html::input( 'wpCreateaccount',
+                               $this->getMsg( $this->data['createAnother'] ?
+                                       'createacct-another-submit' : 'createacct-submit' ),
+                               'submit',
+                               array(
+                                       'class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-primary",
+                                       'id' => 'wpCreateaccount',
+                                       'tabindex' => $tabIndex++
+                               ) );
+                       ?>
                </div>
 <?php if ( $this->haveData( 'uselang' ) ) { ?><input type="hidden" name="uselang" value="<?php $this->text( 'uselang' ); ?>" /><?php } ?>
 <?php if ( $this->haveData( 'token' ) ) { ?><input type="hidden" name="wpCreateaccountToken" value="<?php $this->text( 'token' ); ?>" /><?php } ?>
index 6926036..29a4333 100644 (file)
@@ -1099,6 +1099,7 @@ Do not forget to change your [[Special:Preferences|{{SITENAME}} preferences]].',
 'yourname'                        => 'Username:',
 'userlogin-yourname'              => 'Username',
 'userlogin-yourname-ph'           => 'Enter your username',
+'createacct-another-username-ph'  => 'Enter the username',
 'createacct-helpusername'         => '', # do not translate or duplicate this message to other languages
 'yourpassword'                    => 'Password:',
 'userlogin-yourpassword'          => 'Password',
@@ -1135,9 +1136,11 @@ Do not forget to change your [[Special:Preferences|{{SITENAME}} preferences]].',
 'helplogin-url'                   => 'Help:Logging in',
 'userlogin-helplink'              => '[[{{MediaWiki:helplogin-url}}|Help with logging in]]',
 'createacct-join'                 => 'Enter your information below.',
+'createacct-another-join'         => 'Enter the new account\'s information below.',
 'createacct-emailrequired'        => 'Email address',
 'createacct-emailoptional'        => 'Email address (optional)',
 'createacct-email-ph'             => 'Enter your email address',
+'createacct-another-email-ph'     => 'Enter email address',
 'createaccountmail'               => 'Use a temporary random password and send it to the email address specified below',
 'createacct-realname'             => 'Real name (optional)',
 'createaccountreason'             => 'Reason:',
@@ -1147,6 +1150,7 @@ Do not forget to change your [[Special:Preferences|{{SITENAME}} preferences]].',
 'createacct-imgcaptcha-help'      => '', # do not translate or duplicate this message to other languages
 'createacct-imgcaptcha-ph'        => 'Enter the text you see above',
 'createacct-submit'               => 'Create your account',
+'createacct-another-submit'       => 'Create another account',
 'createacct-benefit-heading'      => '{{SITENAME}} is made by people like you.',
 'createacct-benefit-icon1'        => 'icon-edits', # do not translate or duplicate this message to other languages
 'createacct-benefit-head1'        => '{{NUMBEROFEDITS}}', # do not translate or duplicate this message to other languages
index 0145b00..d8919c1 100644 (file)
@@ -1074,6 +1074,7 @@ See examples: [[Special:UserLogin]] and [{{canonicalurl:Special:UserLogin|type=s
 'userlogin-yourname-ph' => 'Placeholder text in login & create account form field.
 
 See example: [[Special:UserLogin]] and [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]',
+'createacct-another-username-ph' => 'Placeholder text in create account form field when one user creates an account for another.',
 'yourpassword' => 'In user preferences
 
 {{Identical|Password}}',
@@ -1178,7 +1179,8 @@ See also:
 'createacct-join' => 'Subheading of vertical-layout create account form encouraging user to join the wiki.
 
 See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]',
-'createacct-emailrequired' => 'Label in vertical-layout create account form for email field when it is required.
+'createacct-another-join' => 'Subheading of create account form when one user creates an account for another.',
+'createacct-emailrequired' => 'Label in create account form for email field when it is required.
 
 See also:
 * {{msg-mw|Createacct-emailoptional}}
@@ -1192,6 +1194,7 @@ See also:
 'createacct-email-ph' => 'Placeholder in vertical-layout create account form for email field.
 
 See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]',
+'createacct-another-email-ph' => 'Placeholder in create account form for email field when one user creates an account for another.',
 'createaccountmail' => 'The label for the checkbox for creating a new account and sending the new password to the specified e-mail address directly, as used on [[Special:UserLogin/signup]] when one user creates an account for another (if creating accounts by e-mail is allowed).
 
 See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]',
@@ -1211,6 +1214,7 @@ See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?t
 'createacct-submit' => 'Submit button on vertical-layout create account form.
 
 See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]',
+'createacct-another-submit' => 'Submit button on create account form when one user creates an account for another.',
 'createacct-benefit-heading' => 'In vertical-layout create account form, the heading for the section describing the benefits of creating an account.
 
 See example: [{{canonicalurl:Special:UserLogin|type=signup}} Special:UserLogin?type=signup]',
index 23e48ca..21025fd 100644 (file)
@@ -447,6 +447,7 @@ $wgMessageStructure = array(
                'yourname',
                'userlogin-yourname',
                'userlogin-yourname-ph',
+               'createacct-another-username-ph',
                'createacct-helpusername',
                'yourpassword',
                'userlogin-yourpassword',
@@ -483,9 +484,11 @@ $wgMessageStructure = array(
                'helplogin-url',
                'userlogin-helplink',
                'createacct-join',
+               'createacct-another-join',
                'createacct-emailrequired',
                'createacct-emailoptional',
                'createacct-email-ph',
+               'createacct-another-email-ph',
                'createaccountmail',
                'createacct-realname',
                'createaccountreason',
@@ -495,6 +498,7 @@ $wgMessageStructure = array(
                'createacct-imgcaptcha-help',
                'createacct-imgcaptcha-ph',
                'createacct-submit',
+               'createacct-another-submit',
                'createacct-benefit-heading',
                'createacct-benefit-icon1',
                'createacct-benefit-head1',
index 2cd5625..f67615b 100644 (file)
                var $emailLabel = $( 'label[for="wpEmail"]' ),
                        originalText = $emailLabel.text(),
                        requiredText = mw.message( 'createacct-emailrequired' ).text(),
-                       $createByMailCheckbox = $( '#wpCreateaccountMail' );
+                       $createByMailCheckbox = $( '#wpCreateaccountMail' ),
+                       $beforePwds = $( '.mw-row-password:first' ).prev(),
+                       $pwds;
 
                function updateForCheckbox() {
                        var checked = $createByMailCheckbox.prop( 'checked' );
                        if ( checked ) {
-                               $( '.mw-row-password' ).hide();
+                               $pwds = $( '.mw-row-password' ).detach();
                                $emailLabel.text( requiredText );
                        } else {
-                               $( '.mw-row-password' ).show();
+                               if ( $pwds ) {
+                                       $beforePwds.after( $pwds );
+                                       $pwds = null;
+                               }
                                $emailLabel.text( originalText );
                        }
                }