From ade138d7ac73f96b13adacf219b5f172734f917d Mon Sep 17 00:00:00 2001 From: azaozz Date: Fri, 1 Apr 2011 20:40:16 +0000 Subject: [PATCH] Fix display of apostrophes in the user's first and last names on the User Profile page, partial props andrewryno, see #17004 git-svn-id: http://svn.automattic.com/wordpress/trunk@17587 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/user-profile.dev.js | 51 ++++++++++++++++----------------- wp-admin/js/user-profile.js | 2 +- wp-admin/user-edit.php | 10 +++++-- wp-includes/script-loader.php | 2 +- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/wp-admin/js/user-profile.dev.js b/wp-admin/js/user-profile.dev.js index 4a2f39d618..8eefda1dd5 100644 --- a/wp-admin/js/user-profile.dev.js +++ b/wp-admin/js/user-profile.dev.js @@ -29,37 +29,36 @@ } } - $(document).ready( function() { + $(document).ready(function() { $('#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]').attr('checked', 'checked')}); - $('#nickname').blur(function(){ - var str = $(this).val() || $('#user_login').val(); - var select = $('#display_name'); - var sel = select.children('option:selected').attr('id'); - select.children('#display_nickname').remove(); - if ( ! select.children('option[value=' + str + ']').length ) - select.append(''); - $('#'+sel).attr('selected', 'selected'); - }); - $('#first_name, #last_name').blur(function(){ - var select = $('#display_name'); - var first = $('#first_name').val(), last = $('#last_name').val(); - var sel = select.children('option:selected').attr('id'); - $('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove(); - if ( first && ! select.children('option[value=' + first + ']').length ) - select.append(''); - if ( last && ! select.children('option[value=' + last + ']').length ) - select.append(''); - if ( first && last ) { - if ( ! select.children('option[value=' + first + ' ' + last + ']').length ) - select.append(''); - if ( ! select.children('option[value=' + last + ' ' + first + ']').length ) - select.append(''); + $('#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() + }; + + 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; } - $('#'+sel).attr('selected', 'selected'); + + $('option', select).remove(); + $.each(inputs, function( id, value ) { + var selected; + + if ( inputs[id].length && $.inArray( value, dub ) == -1 ) { + dub.push(value); + selected = id == current ? 'selected="selected"' : ''; + select.append(''); + } + }); }); - }); + }); })(jQuery); diff --git a/wp-admin/js/user-profile.js b/wp-admin/js/user-profile.js index e04139a131..fa9bd3fbaf 100644 --- a/wp-admin/js/user-profile.js +++ b/wp-admin/js/user-profile.js @@ -1 +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('")}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('")}if(d&&!c.children("option[value="+d+"]").length){c.append('")}if(f&&d){if(!c.children("option[value="+f+" "+d+"]").length){c.append('")}if(!c.children("option[value="+d+" "+f+"]").length){c.append('")}}a("#"+e).attr("selected","selected")})})})(jQuery); \ No newline at end of file +(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("#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,h){var g;if(d[i].length&&a.inArray(h,f)==-1){f.push(h);g=i==e?'selected="selected"':"";c.append('")}})})})})(jQuery); \ No newline at end of file diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php index c85282f71f..98d9f3aa42 100644 --- a/wp-admin/user-edit.php +++ b/wp-admin/user-edit.php @@ -281,23 +281,29 @@ if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_c