diff options
Diffstat (limited to 'resources/mediawiki.special/mediawiki.special.changeemail.js')
-rw-r--r-- | resources/mediawiki.special/mediawiki.special.changeemail.js | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/resources/mediawiki.special/mediawiki.special.changeemail.js b/resources/mediawiki.special/mediawiki.special.changeemail.js index 6b4ed81d..cab0bbd3 100644 --- a/resources/mediawiki.special/mediawiki.special.changeemail.js +++ b/resources/mediawiki.special/mediawiki.special.changeemail.js @@ -1,12 +1,12 @@ /* * JavaScript for Special:ChangeEmail */ -( function( $, mw ) { +( function ( mw, $ ) { /** * Given an email validity status (true, false, null) update the label CSS class */ -var updateMailValidityLabel = function( mail ) { +function updateMailValidityLabel( mail ) { var isValid = mw.util.validateEmail( mail ), $label = $( '#mw-emailaddress-validity' ); @@ -22,19 +22,21 @@ var updateMailValidityLabel = function( mail ) { } else { $label.text( mw.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' ); } -}; +} -// Lame tip to let user know if its email is valid. See bug 22449 -// Only bind once for 'blur' so that the user can fill it in without errors -// After that look at every keypress for direct feedback if it was invalid onblur -$( '#wpNewEmail' ).one( 'blur', function() { - if ( $( '#mw-emailaddress-validity' ).length === 0 ) { - $(this).after( '<label for="wpNewEmail" id="mw-emailaddress-validity"></label>' ); - } - updateMailValidityLabel( $(this).val() ); - $(this).keyup( function() { +$( document ).ready( function () { + // Lame tip to let user know if its email is valid. See bug 22449 + // Only bind once for 'blur' so that the user can fill it in without errors + // After that look at every keypress for direct feedback if it was invalid onblur + $( '#wpNewEmail' ).one( 'blur', function () { + if ( $( '#mw-emailaddress-validity' ).length === 0 ) { + $(this).after( '<label for="wpNewEmail" id="mw-emailaddress-validity"></label>' ); + } updateMailValidityLabel( $(this).val() ); + $(this).keyup( function () { + updateMailValidityLabel( $(this).val() ); + } ); } ); } ); -} )( jQuery, mediaWiki ); +}( mediaWiki, jQuery ) ); |