<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[18363] branches/3.1: User Profile JS cleanup, props dd32, fixes #17910 for 3.1</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/18363">18363</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2011-06-28 16:16:45 +0000 (Tue, 28 Jun 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>User Profile JS cleanup, props dd32, fixes <a href="http://trac.wordpress.org/ticket/17910">#17910</a> for 3.1</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches31wpadminjsuserprofiledevjs">branches/3.1/wp-admin/js/user-profile.dev.js</a></li>
<li><a href="#branches31wpadminjsuserprofilejs">branches/3.1/wp-admin/js/user-profile.js</a></li>
<li><a href="#branches31wpincludesscriptloaderphp">branches/3.1/wp-includes/script-loader.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches31wpadminjsuserprofiledevjs"></a>
<div class="modfile"><h4>Modified: branches/3.1/wp-admin/js/user-profile.dev.js (18362 => 18363)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.1/wp-admin/js/user-profile.dev.js        2011-06-28 06:47:34 UTC (rev 18362)
+++ branches/3.1/wp-admin/js/user-profile.dev.js        2011-06-28 16:16:45 UTC (rev 18363)
</span><span class="lines">@@ -29,37 +29,39 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        $(document).ready( function() {
</del><ins>+        $(document).ready(function() {
</ins><span class="cx">                 $('#pass1').val('').keyup( check_pass_strength );
</span><span class="cx">                 $('#pass2').val('').keyup( check_pass_strength );
</span><span class="cx">                 $('#pass-strength-result').show();
</span><del>-                $('.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('<option id="display_nickname" value="' + str + '">' + str + '</option>');
-                        $('#'+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('<option id="display_firstname" value="' + first + '">' + first + '</option>');
-                        if ( last && ! select.children('option[value=' + last + ']').length )
-                                select.append('<option id="display_lastname" value="' + last + '">' + last + '</option>');
-                        if ( first && last ) {
-                                if ( ! select.children('option[value=' + first + ' ' + last + ']').length )
-                                        select.append('<option id="display_firstlast" value="' + first + ' ' + last + '">' + first + ' ' + last + '</option>');
-                                if ( ! select.children('option[value=' + last + ' ' + first + ']').length )
-                                        select.append('<option id="display_lastfirst" value="' + last + ' ' + first + '">' + last + ' ' + first + '</option>');
</del><ins>+                $('.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()
+                                };
+
+                        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;
</ins><span class="cx">                         }
</span><del>-                        $('#'+sel).attr('selected', 'selected');
</del><ins>+
+                        $('option', select).remove();
+                        $.each(inputs, function( id, value ) {
+                                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 );
+                                }
+                        });
</ins><span class="cx">                 });
</span><del>- });
</del><ins>+        });
</ins><span class="cx">
</span><span class="cx"> })(jQuery);
</span></span></pre></div>
<a id="branches31wpadminjsuserprofilejs"></a>
<div class="modfile"><h4>Modified: branches/3.1/wp-admin/js/user-profile.js (18362 => 18363)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.1/wp-admin/js/user-profile.js        2011-06-28 06:47:34 UTC (rev 18362)
+++ branches/3.1/wp-admin/js/user-profile.js        2011-06-28 16:16:45 UTC (rev 18363)
</span><span class="lines">@@ -1 +1 @@
</span><del>-(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);
</del><span class="cx">\ No newline at end of file
</span><ins>+(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);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="branches31wpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: branches/3.1/wp-includes/script-loader.php (18362 => 18363)</h4>
<pre class="diff"><span>
<span class="info">--- branches/3.1/wp-includes/script-loader.php        2011-06-28 06:47:34 UTC (rev 18362)
+++ branches/3.1/wp-includes/script-loader.php        2011-06-28 16:16:45 UTC (rev 18363)
</span><span class="lines">@@ -259,7 +259,7 @@
</span><span class="cx">                 'l10n_print_after' => 'try{convertEntities(pwsL10n);}catch(e){};'
</span><span class="cx">         ) );
</span><span class="cx">
</span><del>-        $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110113' );
</del><ins>+        $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), '20110628' );
</ins><span class="cx">         $scripts->add_data( 'user-profile', 'group', 1 );
</span><span class="cx">
</span><span class="cx">         $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20110131' );
</span></span></pre>
</div>
</div>
</body>
</html>