1 /* global ajaxurl, pwsL10n */
4 function check_pass_strength() {
5 var pass1 = $('#pass1').val(), pass2 = $('#pass2').val(), strength;
7 $('#pass-strength-result').removeClass('short bad good strong');
9 $('#pass-strength-result').html( pwsL10n.empty );
13 strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 );
17 $('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
20 $('#pass-strength-result').addClass('good').html( pwsL10n.good );
23 $('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
26 $('#pass-strength-result').addClass('short').html( pwsL10n.mismatch );
29 $('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
33 $(document).ready( function() {
34 var $colorpicker, $stylesheet, user_id, current_user_id,
35 select = $( '#display_name' );
37 $('#pass1').val('').keyup( check_pass_strength );
38 $('#pass2').val('').keyup( check_pass_strength );
39 $('#pass-strength-result').show();
40 $('.color-palette').click( function() {
41 $(this).siblings('input[name="admin_color"]').prop('checked', true);
44 if ( select.length ) {
45 $('#first_name, #last_name, #nickname').bind( 'blur.user_profile', function() {
48 display_nickname : $('#nickname').val() || '',
49 display_username : $('#user_login').val() || '',
50 display_firstname : $('#first_name').val() || '',
51 display_lastname : $('#last_name').val() || ''
54 if ( inputs.display_firstname && inputs.display_lastname ) {
55 inputs.display_firstlast = inputs.display_firstname + ' ' + inputs.display_lastname;
56 inputs.display_lastfirst = inputs.display_lastname + ' ' + inputs.display_firstname;
59 $.each( $('option', select), function( i, el ){
63 $.each(inputs, function( id, value ) {
68 var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
70 if ( inputs[id].length && $.inArray( val, dub ) === -1 ) {
74 }).appendTo( select );
80 $colorpicker = $( '#color-picker' );
81 $stylesheet = $( '#colors-css' );
82 user_id = $( 'input#user_id' ).val();
83 current_user_id = $( 'input[name="checkuser_id"]' ).val();
85 $colorpicker.on( 'click.colorpicker', '.color-option', function() {
89 if ( $this.hasClass( 'selected' ) ) {
93 $this.siblings( '.selected' ).removeClass( 'selected' );
94 $this.addClass( 'selected' ).find( 'input[type="radio"]' ).prop( 'checked', true );
97 if ( user_id === current_user_id ) {
98 // Load the colors stylesheet
99 $stylesheet.attr( 'href', $this.children( '.css_url' ).val() );
102 if ( typeof wp !== 'undefined' && wp.svgPainter ) {
104 colors = $.parseJSON( $this.children( '.icon_colors' ).val() );
108 wp.svgPainter.setColors( colors );
109 wp.svgPainter.paint();
113 // update user option
115 action: 'save-user-color-scheme',
116 color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
117 nonce: $('#color-nonce').val()