Make WordPress Core

Ticket #26016: 26016.3.diff

File 26016.3.diff, 5.6 KB (added by dougwollison, 11 years ago)

Revised declaration of globals.

  • src/wp-admin/js/user-profile.js

     
    1 (function($){
     1/* global ajaxurl, pwsL10n, svgPainter */
    22
     3(function( $ ) {
     4
    35        function check_pass_strength() {
    4                 var pass1 = $('#pass1').val(), user = $('#user_login').val(), pass2 = $('#pass2').val(), strength;
     6                var pass1 = $( '#pass1' ).val(), pass2 = $( '#pass2' ).val(), strength;
    57
    6                 $('#pass-strength-result').removeClass('short bad good strong');
     8                $( '#pass-strength-result' ).removeClass( 'short bad good strong' );
    79                if ( ! pass1 ) {
    8                         $('#pass-strength-result').html( pwsL10n.empty );
     10                        $( '#pass-strength-result' ).html( pwsL10n.empty );
    911                        return;
    1012                }
    1113
     
    1315
    1416                switch ( strength ) {
    1517                        case 2:
    16                                 $('#pass-strength-result').addClass('bad').html( pwsL10n['bad'] );
    17                                 break;
     18                                $( '#pass-strength-result' ).addClass( 'bad' ).html( pwsL10n.bad );
     19                        break;
    1820                        case 3:
    19                                 $('#pass-strength-result').addClass('good').html( pwsL10n['good'] );
    20                                 break;
     21                                $( '#pass-strength-result' ).addClass( 'good' ).html( pwsL10n.good );
     22                        break;
    2123                        case 4:
    22                                 $('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] );
    23                                 break;
     24                                $( '#pass-strength-result' ).addClass( 'strong' ).html( pwsL10n.strong );
     25                        break;
    2426                        case 5:
    25                                 $('#pass-strength-result').addClass('short').html( pwsL10n['mismatch'] );
    26                                 break;
     27                                $( '#pass-strength-result' ).addClass( 'short' ).html( pwsL10n.mismatch );
     28                        break;
    2729                        default:
    28                                 $('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
     30                                $( '#pass-strength-result' ).addClass( 'short' ).html( pwsL10n['short'] );
    2931                }
    3032        }
    3133
    32         $(document).ready( function() {
    33                 var select = $('#display_name');
     34        $( document ).ready( function() {
     35                var select = $( '#display_name'), $colorpicker, $stylesheet, user_id, current_user_id;
    3436
    35                 $('#pass1').val('').keyup( check_pass_strength );
    36                 $('#pass2').val('').keyup( check_pass_strength );
    37                 $('#pass-strength-result').show();
    38                 $('.color-palette').click( function() {
    39                         $(this).siblings('input[name="admin_color"]').prop('checked', true);
     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);
    4042                });
    4143
    4244                if ( select.length ) {
    43                         $('#first_name, #last_name, #nickname').bind( 'blur.user_profile', function() {
     45                        $( '#first_name, #last_name, #nickname' ).bind( 'blur.user_profile', function() {
    4446                                var dub = [],
    4547                                        inputs = {
    46                                                 display_nickname  : $('#nickname').val() || '',
    47                                                 display_username  : $('#user_login').val() || '',
    48                                                 display_firstname : $('#first_name').val() || '',
    49                                                 display_lastname  : $('#last_name').val() || ''
     48                                                display_nickname : $( '#nickname' ).val() || '',
     49                                                display_username : $( '#user_login' ).val() || '',
     50                                                display_firstname : $( '#first_name' ).val() || '',
     51                                                display_lastname : $( '#last_name' ).val() || ''
    5052                                        };
    5153
    5254                                if ( inputs.display_firstname && inputs.display_lastname ) {
    53                                         inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname;
    54                                         inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname;
     55                                        inputs.display_firstlast = inputs.display_firstname + ' ' + inputs.display_lastname;
     56                                        inputs.display_lastfirst = inputs.display_lastname + ' ' + inputs.display_firstname;
    5557                                }
    5658
    57                                 $.each( $('option', select), function( i, el ){
     59                                $.each( $( 'option', select ), function( i, el ) {
    5860                                        dub.push( el.value );
    5961                                });
    6062
    61                                 $.each(inputs, function( id, value ) {
    62                                         if ( ! value )
     63                                $.each( inputs, function( id, value ) {
     64                                        if ( ! value ) {
    6365                                                return;
     66                                        }
    6467
    65                                         var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
     68                                        var val = value.replace( /<\/?[a-z][^>]*>/gi, '' );
    6669
    67                                         if ( inputs[id].length && $.inArray( val, dub ) == -1 ) {
    68                                                 dub.push(val);
    69                                                 $('<option />', {
    70                                                         'text': val
     70                                        if ( inputs[ id ].length && $.inArray( val, dub ) === -1 ) {
     71                                                dub.push( val );
     72                                                $( '<option />', {
     73                                                        text: val
    7174                                                }).appendTo( select );
    7275                                        }
    7376                                });
    7477                        });
    7578                }
    7679
    77                 var $colorpicker = $( '#color-picker' ),
    78                         $stylesheet = $( '#colors-css' ),
    79                         user_id = $( 'input#user_id' ).val(),
    80                         current_user_id = $( 'input[name="checkuser_id"]' ).val();
     80                $colorpicker = $( '#color-picker' );
     81                $stylesheet = $( '#colors-css' );
     82                user_id = $( 'input#user_id' ).val();
     83                current_user_id = $( 'input[name="checkuser_id"]' ).val();
    8184
    8285                // dropdown toggle
    8386                $colorpicker.on( 'click', '.dropdown-current', function() {
     
    8992                        var color_scheme = $( this ).children( 'input[name="admin_color"]' ).val();
    9093
    9194                        // update selected
    92                         $( this ).siblings( '.selected' ).removeClass( 'selected' )
     95                        $( this ).siblings( '.selected' ).removeClass( 'selected' );
    9396                        $( this ).addClass( 'selected' );
    9497                        $( this ).find( 'input' ).prop( 'checked', true );
    9598
     
    99102                        $colorpicker.toggleClass( 'picker-expanded' );
    100103
    101104                        // preview/save color scheme
    102                         if ( user_id == current_user_id ) {
     105                        if ( user_id === current_user_id ) {
    103106
    104107                                // repaint icons
    105108                                $stylesheet.attr( 'href', $( this ).children( '.css_url' ).val() );
     
    108111
    109112                                // update user option
    110113                                $.post( ajaxurl, {
    111                                         action: 'save-user-color-scheme',
     114                                        action:       'save-user-color-scheme',
    112115                                        color_scheme: color_scheme,
    113                                         user_id: user_id
     116                                        user_id:      user_id
    114117                                });
    115118
    116119                        }