2 * JavaScript for Special:Preferences
6 $( '#prefsubmit' ).attr( 'id', 'prefcontrol' );
9 .before( $( '<ul id="preftoc"></ul>' ) )
10 .children( 'fieldset' )
12 .addClass( 'prefsection' )
14 .addClass( 'mainLegend' )
15 .each( function( i
) {
16 $(this).parent().attr( 'id', 'prefsection-' + i
);
18 $(this).parent().show();
20 $( '#preftoc' ).append(
22 .addClass( i
=== 0 ? 'selected' : null )
25 .text( $(this).text() )
26 .attr( 'href', '#prefsection-' + i
)
27 .mousedown( function( e
) {
28 $(this).parent().parent().find( 'li' ).removeClass( 'selected' );
29 $(this).parent().addClass( 'selected' );
33 .click( function( e
) {
34 $( '#preferences > fieldset' ).hide();
35 $( '#prefsection-' + i
).show();
45 * Given an email validity status (true, false, null) update the label CSS class
47 var updateMailValidityLabel = function( mail
) {
48 var isValid
= mw
.util
.validateEmail( mail
),
49 $label
= $( '#mw-emailaddress-validity' );
51 // We allow empty address
52 if( isValid
=== null ) {
53 $label
.text( '' ).removeClass( 'valid invalid' );
56 } else if ( isValid
) {
57 $label
.text( mw
.msg( 'email-address-validity-valid' ) ).addClass( 'valid' ).removeClass( 'invalid' );
61 $label
.text( mw
.msg( 'email-address-validity-invalid' ) ).addClass( 'invalid' ).removeClass( 'valid' );
65 // Lame tip to let user know if its email is valid. See bug 22449
66 // Only bind once for 'blur' so that the user can fill it in without errors
67 // After that look at every keypress for direct feedback if it was invalid onblur
68 $( '#mw-input-wpemailaddress' ).one( 'blur', function() {
69 if ( $( '#mw-emailaddress-validity' ).length
=== 0 ) {
70 $(this).after( '<label for="mw-input-wpemailaddress" id="mw-emailaddress-validity"></label>' );
72 updateMailValidityLabel( $(this).val() );
73 $(this).keyup( function() {
74 updateMailValidityLabel( $(this).val() );
77 } )( jQuery
, mediaWiki
);