WordPress.org

Make WordPress Core

Changeset 18363


Ignore:
Timestamp:
06/28/11 16:16:45 (3 years ago)
Author:
azaozz
Message:

User Profile JS cleanup, props dd32, fixes #17910 for 3.1

Location:
branches/3.1
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/wp-admin/js/user-profile.dev.js

    r15998 r18363  
    3030    } 
    3131 
    32     $(document).ready( function() { 
     32    $(document).ready(function() { 
    3333        $('#pass1').val('').keyup( check_pass_strength ); 
    3434        $('#pass2').val('').keyup( check_pass_strength ); 
    3535        $('#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'); 
     36        $('.color-palette').click(function(){$(this).siblings('input[name="admin_color"]').prop('checked', true)}); 
     37        $('#first_name, #last_name, #nickname').blur(function(){ 
     38            var select = $('#display_name'), current = select.find('option:selected').attr('id'), dub = [], 
     39                inputs = { 
     40                    display_nickname : $('#nickname').val(), 
     41                    display_username : $('#user_login').val(), 
     42                    display_firstname : $('#first_name').val(), 
     43                    display_lastname : $('#last_name').val() 
     44                }; 
     45 
     46            if ( inputs.display_firstname && inputs.display_lastname ) { 
     47                inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname; 
     48                inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname; 
     49            } 
     50 
     51            $('option', select).remove(); 
     52            $.each(inputs, function( id, value ) { 
     53                var val = value.replace(/<\/?[a-z][^>]*>/gi, '');  
     54 
     55                if ( inputs[id].length && $.inArray( val, dub ) == -1 ) { 
     56                    dub.push(val); 
     57                    $('<option />', { 
     58                        'id': id, 
     59                        'text': val, 
     60                        'selected': (id == current) 
     61                    }).appendTo( select ); 
     62                } 
     63            }); 
    4564        }); 
    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     }); 
     65    }); 
    6466 
    6567})(jQuery); 
  • branches/3.1/wp-admin/js/user-profile.js

    r17286 r18363  
    1 (function(a){function b(){var e=a("#pass1").val(),d=a("#user_login").val(),c=a("#pass2").val(),f;a("#pass-strength-result").removeClass("short bad good strong");if(!e){a("#pass-strength-result").html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a("#pass2").val("").keyup(b);a("#pass-strength-result").show();a(".color-palette").click(function(){a(this).siblings("input[name=admin_color]").attr("checked","checked")});a("#nickname").blur(function(){var e=a(this).val()||a("#user_login").val();var c=a("#display_name");var d=c.children("option:selected").attr("id");c.children("#display_nickname").remove();if(!c.children("option[value="+e+"]").length){c.append('<option id="display_nickname" value="'+e+'">'+e+"</option>")}a("#"+d).attr("selected","selected")});a("#first_name, #last_name").blur(function(){var c=a("#display_name");var f=a("#first_name").val(),d=a("#last_name").val();var e=c.children("option:selected").attr("id");a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(f&&!c.children("option[value="+f+"]").length){c.append('<option id="display_firstname" value="'+f+'">'+f+"</option>")}if(d&&!c.children("option[value="+d+"]").length){c.append('<option id="display_lastname" value="'+d+'">'+d+"</option>")}if(f&&d){if(!c.children("option[value="+f+" "+d+"]").length){c.append('<option id="display_firstlast" value="'+f+" "+d+'">'+f+" "+d+"</option>")}if(!c.children("option[value="+d+" "+f+"]").length){c.append('<option id="display_lastfirst" value="'+d+" "+f+'">'+d+" "+f+"</option>")}}a("#"+e).attr("selected","selected")})})})(jQuery); 
     1(function(a){function b(){var e=a("#pass1").val(),d=a("#user_login").val(),c=a("#pass2").val(),f;a("#pass-strength-result").removeClass("short bad good strong");if(!e){a("#pass-strength-result").html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;case 5:a("#pass-strength-result").addClass("short").html(pwsL10n.mismatch);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a("#pass2").val("").keyup(b);a("#pass-strength-result").show();a(".color-palette").click(function(){a(this).siblings('input[name="admin_color"]').prop("checked",true)});a("#first_name, #last_name, #nickname").blur(function(){var c=a("#display_name"),e=c.find("option:selected").attr("id"),f=[],d={display_nickname:a("#nickname").val(),display_username:a("#user_login").val(),display_firstname:a("#first_name").val(),display_lastname:a("#last_name").val()};if(d.display_firstname&&d.display_lastname){d.display_firstlast=d.display_firstname+" "+d.display_lastname;d.display_lastfirst=d.display_lastname+" "+d.display_firstname}a("option",c).remove();a.each(d,function(i,g){var h=g.replace(/<\/?[a-z][^>]*>/gi,"");if(d[i].length&&a.inArray(h,f)==-1){f.push(h);a("<option />",{id:i,text:h,selected:(i==e)}).appendTo(c)}})})})})(jQuery); 
  • branches/3.1/wp-includes/script-loader.php

    r17559 r18363  
    260260    ) ); 
    261261 
    262     $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110113' ); 
     262    $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110628' ); 
    263263    $scripts->add_data( 'user-profile', 'group', 1 ); 
    264264 
Note: See TracChangeset for help on using the changeset viewer.