Don't try to append "Display Name" options when on the Add New User screen (the <select> doesn't exist there), props pbiron, SergeyBiryukov, fixes #20392

git-svn-id: http://svn.automattic.com/wordpress/trunk@20407 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2012-04-09 18:46:36 +00:00
parent a312778602
commit 04f6979a13
1 changed files with 16 additions and 7 deletions

View File

@ -35,13 +35,19 @@
$('#pass-strength-result').show();
$('.color-palette').click(function(){$(this).siblings('input[name="admin_color"]').prop('checked', true)});
$('#first_name, #last_name, #nickname').blur(function(){
var select = $('#display_name'), current = select.find('option:selected').attr('id'), dub = [],
inputs = {
display_nickname : $('#nickname').val(),
display_username : $('#user_login').val(),
display_firstname : $('#first_name').val(),
display_lastname : $('#last_name').val()
};
var select = $('#display_name'), current, dub = [], inputs;
if ( !select.length )
return;
current = select.find('option:selected').attr('id');
inputs = {
display_nickname : $('#nickname').val() || '',
display_username : $('#user_login').val() || '',
display_firstname : $('#first_name').val() || '',
display_lastname : $('#last_name').val() || ''
};
if ( inputs.display_firstname && inputs.display_lastname ) {
inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname;
@ -50,6 +56,9 @@
$('option', select).remove();
$.each(inputs, function( id, value ) {
if ( !value )
return;
var val = value.replace(/<\/?[a-z][^>]*>/gi, '');
if ( inputs[id].length && $.inArray( val, dub ) == -1 ) {