X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.special.userlogin.signup.js;h=fff2d4e61a32c2367f55c33cda167f1e56775744;hb=f17f841a9dfa1bee3f8ed47a09f06d1226452573;hp=8a61afbe6ad3f8a68a566967b46e7924ac00eaf3;hpb=e03b96c9a474831fb1b1d1fc1e6cd2de496dc251;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.special.userlogin.signup.js b/resources/src/mediawiki.special.userlogin.signup.js index 8a61afbe6a..fff2d4e61a 100644 --- a/resources/src/mediawiki.special.userlogin.signup.js +++ b/resources/src/mediawiki.special.userlogin.signup.js @@ -1,7 +1,7 @@ /*! * JavaScript for signup form. */ -( function ( mw, $ ) { +( function () { // When sending password by email, hide the password input fields. $( function () { // Always required if checked, otherwise it depends, so we use the original @@ -30,7 +30,7 @@ updateForCheckbox(); } ); - // Check if the username is invalid or already taken + // Check if the username is invalid or already taken; show username normalisation warning mw.hook( 'htmlform.enhance' ).add( function ( $root ) { var $usernameInput = $root.find( '#wpName2' ), $passwordInput = $root.find( '#wpPassword2' ), @@ -43,6 +43,10 @@ // We could just use .then() if we didn't have to pass on .abort()… var d, apiPromise; + // Leading/trailing/multiple whitespace characters are always stripped in usernames, + // this should not require a warning. We do warn about underscores. + username = username.replace( / +/g, ' ' ).trim(); + d = $.Deferred(); apiPromise = api.get( { action: 'query', @@ -68,6 +72,10 @@ return m.html; } ) : [] } ); + } else if ( userinfo.name !== username ) { + d.resolve( { valid: true, messages: [ + mw.message( 'createacct-normalization', username, userinfo.name ).parseDom() + ] } ); } else { d.resolve( { valid: true, messages: [] } ); } @@ -119,4 +127,4 @@ passwordChecker = new mw.htmlform.Checker( $passwordInput, checkPassword ); passwordChecker.attach( $usernameInput.add( $emailInput ).add( $realNameInput ) ); } ); -}( mediaWiki, jQuery ) ); +}() );