]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/user-profile.dev.js
Wordpress 3.1
[autoinstalls/wordpress.git] / wp-admin / js / user-profile.dev.js
1 (function($){
2
3         function check_pass_strength() {
4                 var pass1 = $('#pass1').val(), user = $('#user_login').val(), pass2 = $('#pass2').val(), strength;
5
6                 $('#pass-strength-result').removeClass('short bad good strong');
7                 if ( ! pass1 ) {
8                         $('#pass-strength-result').html( pwsL10n.empty );
9                         return;
10                 }
11
12                 strength = passwordStrength(pass1, user, pass2);
13
14                 switch ( strength ) {
15                         case 2:
16                                 $('#pass-strength-result').addClass('bad').html( pwsL10n['bad'] );
17                                 break;
18                         case 3:
19                                 $('#pass-strength-result').addClass('good').html( pwsL10n['good'] );
20                                 break;
21                         case 4:
22                                 $('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] );
23                                 break;
24                         case 5:
25                                 $('#pass-strength-result').addClass('short').html( pwsL10n['mismatch'] );
26                                 break;
27                         default:
28                                 $('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
29                 }
30         }
31
32         $(document).ready( function() {
33                 $('#pass1').val('').keyup( check_pass_strength );
34                 $('#pass2').val('').keyup( check_pass_strength );
35                 $('#pass-strength-result').show();
36                 $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
37                 $('#nickname').blur(function(){
38                         var str = $(this).val() || $('#user_login').val();
39                         var select = $('#display_name');
40                         var sel = select.children('option:selected').attr('id');
41                         select.children('#display_nickname').remove();
42                         if ( ! select.children('option[value=' + str + ']').length )
43                                 select.append('<option id="display_nickname" value="' + str + '">' + str + '</option>');
44                         $('#'+sel).attr('selected', 'selected');
45                 });
46                 $('#first_name, #last_name').blur(function(){
47                         var select = $('#display_name');
48                         var first = $('#first_name').val(), last = $('#last_name').val();
49                         var sel = select.children('option:selected').attr('id');
50                         $('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove();
51                         if ( first && ! select.children('option[value=' + first + ']').length )
52                                 select.append('<option id="display_firstname" value="' + first + '">' + first + '</option>');
53                         if ( last && ! select.children('option[value=' + last + ']').length )
54                                 select.append('<option id="display_lastname" value="' + last + '">' + last + '</option>');
55                         if ( first && last ) {
56                                 if ( ! select.children('option[value=' + first + ' ' + last + ']').length )
57                                         select.append('<option id="display_firstlast" value="' + first + ' ' + last + '">' + first + ' ' + last + '</option>');
58                                 if ( ! select.children('option[value=' + last + ' ' + first + ']').length )
59                                         select.append('<option id="display_lastfirst" value="' + last + ' ' + first + '">' + last + ' ' + first + '</option>');
60                         }
61                         $('#'+sel).attr('selected', 'selected');
62                 });
63     });
64
65 })(jQuery);