Don't display empty values in the user display name drop-down, props Simek, fix js to add newly entered First Name and Last Name, fixes #9813

git-svn-id: https://develop.svn.wordpress.org/trunk@11330 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2009-05-14 17:01:04 +00:00
parent 734685397b
commit ecc46022b2
8 changed files with 99 additions and 95 deletions

View File

@ -247,11 +247,11 @@ jQuery(document).ready( function($) {
gf = new GearsFactory();
} else {
try {
gf = new ActiveXObject('Gears.Factory');
if ( factory.getBuildInfo().indexOf('ie_mobile') != -1 )
gf.privateSetGlobalObject(this);
} catch (e) {
if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
if ( window.ActiveXObject ) {
gf = new ActiveXObject('Gears.Factory');
if ( gf && gf.getBuildInfo().indexOf('ie_mobile') != -1 )
gf.privateSetGlobalObject(this);
} else if ( ( 'undefined' != typeof navigator.mimeTypes ) && navigator.mimeTypes['application/x-googlegears'] ) {
gf = document.createElement("object");
gf.style.display = "none";
gf.width = 0;
@ -259,7 +259,7 @@ jQuery(document).ready( function($) {
gf.type = "application/x-googlegears";
document.documentElement.appendChild(gf);
}
}
} catch(e){}
}
if ( gf && gf.hasPermission )
return;

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,52 @@
(function($){
function check_pass_strength() {
var pass = $('#pass1').val(), user = $('#user_login').val(), strength;
$('#pass-strength-result').removeClass('short bad good strong');
if ( ! pass ) {
$('#pass-strength-result').html( pwsL10n.empty );
return;
}
strength = passwordStrength(pass, user);
switch ( strength ) {
case 2:
$('#pass-strength-result').addClass('bad').html( pwsL10n['bad'] );
break;
case 3:
$('#pass-strength-result').addClass('good').html( pwsL10n['good'] );
break;
case 4:
$('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] );
break;
default:
$('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
}
}
$(document).ready( function() {
$('#pass1').val('').keyup( check_pass_strength );
$('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
$('#nickname').blur(function(){
var str = $(this).val() || $('#user_login').val();
$('#display_name #display_nickname').val(str).html(str);
});
$('#first_name, #last_name').blur(function(){
var first = $('#first_name').val(), last = $('#last_name').val();
$('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove();
if ( first && last ) {
$('#display_name').append('<option id="display_firstname" value="' + first + '">' + first + '</option>' +
'<option id="display_lastname" value="' + last + '">' + last + '</option>' +
'<option id="display_firstlast" value="' + first + ' ' + last + '">' + first + ' ' + last + '</option>' +
'<option id="display_lastfirst" value="' + last + ' ' + first + '">' + last + ' ' + first + '</option>');
} else if ( first && !last ) {
$('#display_name').append('<option id="display_firstname" value="' + first + '">' + first + '</option>');
} else if ( !first && last ) {
$('#display_name').append('<option id="display_lastname" value="' + last + '">' + last + '</option>');
}
});
});
})(jQuery);

View File

@ -0,0 +1 @@
(function(a){function b(){var d=a("#pass1").val(),c=a("#user_login").val(),e;a("#pass-strength-result").removeClass("short bad good strong");if(!d){a("#pass-strength-result").html(pwsL10n.empty);return}e=passwordStrength(d,c);switch(e){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;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a(".color-palette").click(function(){a(this).siblings("input[name=admin_color]").attr("checked","checked")});a("#nickname").blur(function(){var c=a(this).val()||a("#user_login").val();a("#display_name #display_nickname").val(c).html(c)});a("#first_name, #last_name").blur(function(){var d=a("#first_name").val(),c=a("#last_name").val();a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(d&&c){a("#display_name").append('<option id="display_firstname" value="'+d+'">'+d+'</option><option id="display_lastname" value="'+c+'">'+c+'</option><option id="display_firstlast" value="'+d+" "+c+'">'+d+" "+c+'</option><option id="display_lastfirst" value="'+c+" "+d+'">'+c+" "+d+"</option>")}else{if(d&&!c){a("#display_name").append('<option id="display_firstname" value="'+d+'">'+d+"</option>")}else{if(!d&&c){a("#display_name").append('<option id="display_lastname" value="'+c+'">'+c+"</option>")}}}})})})(jQuery);

View File

@ -14,74 +14,8 @@ if ( defined('IS_PROFILE_PAGE') && IS_PROFILE_PAGE )
else
$is_profile_page = false;
/**
* Display JavaScript for profile page.
*
* @since 2.5.0
*/
function profile_js ( ) {
?>
<script type="text/javascript">
(function($){
function check_pass_strength () {
var pass = $('#pass1').val();
var user = $('#user_login').val();
$('#pass-strength-result').removeClass('short bad good strong');
if ( ! pass ) {
$('#pass-strength-result').html( pwsL10n.empty );
return;
}
var strength = passwordStrength(pass, user);
if ( 2 == strength )
$('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
else if ( 3 == strength )
$('#pass-strength-result').addClass('good').html( pwsL10n.good );
else if ( 4 == strength )
$('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
else
// this catches 'Too short' and the off chance anything else comes along
$('#pass-strength-result').addClass('short').html( pwsL10n.short );
}
$(document).ready( function() {
$('#pass1').val('').keyup( check_pass_strength );
$('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
$('#nickname').change(function(){
$('#display_name').fadeOut('normal',function(){
$(this).fadeIn();
$('#display_nickname').html($('#nickname').val()).val($('#nickname').val());
});
});
$('#first_name').change(function(){
$('#display_name').fadeOut('normal',function(){
$('#display_firstname').html($('#first_name').val()).val($('#first_name').val());
$('#display_firstlast').html($('#first_name').val()+' '+$('#last_name').val()).val($('#first_name').val()+' '+$('#last_name').val());
$('#display_lastfirst').html($('#last_name').val()+' '+$('#first_name').val()).val($('#last_name').val()+' '+$('#first_name').val());
$(this).fadeIn();
});
});
$('#last_name').change(function(){
$('#display_name').fadeOut('normal',function(){
$('#display_firstlast').html($('#first_name').val()+' '+$('#last_name').val()).val($('#first_name').val()+' '+$('#last_name').val());
$('#display_lastfirst').html($('#last_name').val()+' '+$('#first_name').val()).val($('#last_name').val()+' '+$('#first_name').val());
$(this).fadeIn();
});
});
});
})(jQuery);
</script>
<?php
}
if ( $is_profile_page ) {
add_action('admin_head', 'profile_js');
wp_enqueue_script('jquery');
wp_enqueue_script('user-profile');
wp_enqueue_script('password-strength-meter');
}
@ -248,7 +182,7 @@ do_action('personal_options', $profileuser);
<table class="form-table">
<tr>
<th><label for="user_login"><?php _e('Username'); ?></label></th>
<td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <?php _e('Your username cannot be changed.'); ?></td>
<td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Your username cannot be changed.'); ?></span></td>
</tr>
<?php if ( !$is_profile_page ): ?>
@ -283,21 +217,26 @@ else
</tr>
<tr>
<th><label for="nickname"><?php _e('Nickname') ?></label></th>
<th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
<td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
</tr>
<tr>
<th><label for="display_name"><?php _e('Display name publicly&nbsp;as') ?></label></th>
<th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
<td>
<select name="display_name" id="display_name">
<?php
$public_display = array();
$public_display['display_nickname'] = $profileuser->nickname;
$public_display['display_username'] = $profileuser->user_login;
$public_display['display_firstname'] = $profileuser->first_name;
$public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
$public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
if ( !empty($profileuser->first_name) )
$public_display['display_firstname'] = $profileuser->first_name;
if ( !empty($profileuser->last_name) )
$public_display['display_lastname'] = $profileuser->last_name;
if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
$public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
$public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
}
if ( !in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere
$public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
$public_display = array_map( 'trim', $public_display );
@ -316,8 +255,8 @@ else
<table class="form-table">
<tr>
<th><label for="email"><?php _e('E-mail') ?></label></th>
<td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" /> <?php _e('Required.');?></td>
<th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
<td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" /></td>
</tr>
<tr>
@ -346,7 +285,8 @@ else
<table class="form-table">
<tr>
<th><label for="description"><?php _e('Biographical Info'); ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea><br /><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></td>
<td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea><br />
<span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
</tr>
<?php
@ -355,13 +295,12 @@ if ( $show_password_fields ) :
?>
<tr id="password">
<th><label for="pass1"><?php _e('New Password'); ?></label></th>
<td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?><br />
<input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <?php _e("Type your new password again."); ?><br />
<td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?></span><br />
<input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("Type your new password again."); ?></span><br />
<?php if ( $is_profile_page ): ?>
<div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
<p><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
<?php endif; ?>
</td>
<p class="description indicator-hint"><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
<?php endif; ?></td>
</tr>
<?php endif; ?>
</table>

View File

@ -91,8 +91,9 @@ $new_user_send_password = !$_POST || isset($_POST['send_password']);
?>
<table class="form-table">
<tr class="form-field form-required">
<th scope="row"><label for="user_login"><?php _e('Username (required)') ?></label><input name="action" type="hidden" id="action" value="adduser" /></th>
<td ><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr($new_user_login); ?>" aria-required="true" /></td>
<th scope="row"><label for="user_login"><?php _e('Username'); ?> <span class="description"><?php _e('(required)'); ?></span></label>
<input name="action" type="hidden" id="action" value="adduser" /></th>
<td><input name="user_login" type="text" id="user_login" value="<?php echo esc_attr($new_user_login); ?>" aria-required="true" /></td>
</tr>
<tr class="form-field">
<th scope="row"><label for="first_name"><?php _e('First Name') ?> </label></th>
@ -103,7 +104,7 @@ $new_user_send_password = !$_POST || isset($_POST['send_password']);
<td><input name="last_name" type="text" id="last_name" value="<?php echo esc_attr($new_user_lastname); ?>" /></td>
</tr>
<tr class="form-field form-required">
<th scope="row"><label for="email"><?php _e('E-mail (required)') ?></label></th>
<th scope="row"><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
<td><input name="email" type="text" id="email" value="<?php echo esc_attr($new_user_email); ?>" /></td>
</tr>
<tr class="form-field">
@ -113,7 +114,7 @@ $new_user_send_password = !$_POST || isset($_POST['send_password']);
<?php if ( apply_filters('show_password_fields', true) ) : ?>
<tr class="form-field form-required">
<th scope="row"><label for="pass1"><?php _e('Password (twice)') ?> </label></th>
<th scope="row"><label for="pass1"><?php _e('Password'); ?> <span class="description"><?php _e('(twice, required)'); ?></span></label></th>
<td><input name="pass1" type="password" id="pass1" autocomplete="off" />
<br />
<input name="pass2" type="password" id="pass2" autocomplete="off"/></td>
@ -144,4 +145,4 @@ $new_user_send_password = !$_POST || isset($_POST['send_password']);
</div>
<?php
include('admin-footer.php');
?>
?>

View File

@ -1371,12 +1371,12 @@ table.form-table td .updated {
p.description,
.form-wrap p {
margin: 2px 0 5px;
font-size: 11px;
}
p.help,
.description,
.form-wrap p {
font-size: 12px;
font-style: italic;
font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif;
}
@ -2136,6 +2136,14 @@ body.wp-admin {
text-decoration: none;
}
.indicator-hint {
padding-top: 8px;
}
#display_name {
width: 15em;
}
.tablenav .delete {
margin-right: 20px;
}

View File

@ -60,7 +60,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'utils', "/wp-admin/js/utils$suffix.js", false, '20090102' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090428' );
$scripts->add( 'common', "/wp-admin/js/common$suffix.js", array('jquery', 'hoverIntent', 'utils'), '20090514' );
$scripts->add_data( 'common', 'group', 1 );
$scripts->localize( 'common', 'commonL10n', array(
'warnDelete' => __("You are about to delete the selected items.\n 'Cancel' to stop, 'OK' to delete."),
@ -238,6 +238,9 @@ function wp_default_scripts( &$scripts ) {
'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
) );
$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array('jquery'), '20090514' );
$scripts->add_data( 'user-profile', 'group', 1 );
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20090209' );
$scripts->add_data( 'admin-comments', 'group', 1 );
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(