Add New User screen: don't bind to blur event on the user_name fields when the <select> doesn't exist, props SergeyBiryukov, fixes #20392
git-svn-id: http://svn.automattic.com/wordpress/trunk@20431 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
000b7a9313
commit
31b26e343a
|
@ -29,48 +29,49 @@
|
|||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready( function() {
|
||||
var select = $('#display_name');
|
||||
|
||||
$('#pass1').val('').keyup( check_pass_strength );
|
||||
$('#pass2').val('').keyup( check_pass_strength );
|
||||
$('#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, 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;
|
||||
inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname;
|
||||
}
|
||||
|
||||
$('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 ) {
|
||||
dub.push(val);
|
||||
$('<option />', {
|
||||
'id': id,
|
||||
'text': val,
|
||||
'selected': (id == current)
|
||||
}).appendTo( select );
|
||||
}
|
||||
});
|
||||
$('.color-palette').click( function() {
|
||||
$(this).siblings('input[name="admin_color"]').prop('checked', true);
|
||||
});
|
||||
|
||||
if ( select.length ) {
|
||||
$('#first_name, #last_name, #nickname').bind( 'blur.user_profile', function() {
|
||||
var 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() || ''
|
||||
};
|
||||
|
||||
if ( inputs.display_firstname && inputs.display_lastname ) {
|
||||
inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname;
|
||||
inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname;
|
||||
}
|
||||
|
||||
$('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 ) {
|
||||
dub.push(val);
|
||||
$('<option />', {
|
||||
'id': id,
|
||||
'text': val,
|
||||
'selected': (id == current)
|
||||
}).appendTo( select );
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
|
Loading…
Reference in New Issue