X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f9001779751f83dc8a10e478bfecb4d8dd5f964c..9e77185fafaf4e60e2b73821e0e4b9b1a11fb85f:/wp-admin/js/user-profile.js
diff --git a/wp-admin/js/user-profile.js b/wp-admin/js/user-profile.js
index e04139a1..b107d987 100644
--- a/wp-admin/js/user-profile.js
+++ b/wp-admin/js/user-profile.js
@@ -1 +1,127 @@
-(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
+/* global ajaxurl, pwsL10n */
+(function($){
+
+ function check_pass_strength() {
+ var pass1 = $('#pass1').val(), pass2 = $('#pass2').val(), strength;
+
+ $('#pass-strength-result').removeClass('short bad good strong');
+ if ( ! pass1 ) {
+ $('#pass-strength-result').html( pwsL10n.empty );
+ return;
+ }
+
+ strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 );
+
+ 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;
+ case 5:
+ $('#pass-strength-result').addClass('short').html( pwsL10n.mismatch );
+ break;
+ default:
+ $('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
+ }
+ }
+
+ $(document).ready( function() {
+ var $colorpicker, $stylesheet, user_id, current_user_id,
+ 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);
+ });
+
+ if ( select.length ) {
+ $('#first_name, #last_name, #nickname').bind( 'blur.user_profile', function() {
+ var 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;
+ }
+
+ $.each( $('option', select), function( i, el ){
+ dub.push( el.value );
+ });
+
+ $.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);
+ $('', {
+ 'text': val
+ }).appendTo( select );
+ }
+ });
+ });
+ }
+
+ $colorpicker = $( '#color-picker' );
+ $stylesheet = $( '#colors-css' );
+ user_id = $( 'input#user_id' ).val();
+ current_user_id = $( 'input[name="checkuser_id"]' ).val();
+
+ $colorpicker.on( 'click.colorpicker', '.color-option', function() {
+ var colors,
+ $this = $(this);
+
+ if ( $this.hasClass( 'selected' ) ) {
+ return;
+ }
+
+ $this.siblings( '.selected' ).removeClass( 'selected' );
+ $this.addClass( 'selected' ).find( 'input[type="radio"]' ).prop( 'checked', true );
+
+ // Set color scheme
+ if ( user_id === current_user_id ) {
+ // Load the colors stylesheet.
+ // The default color scheme won't have one, so we'll need to create an element.
+ if ( 0 === $stylesheet.length ) {
+ $stylesheet = $( '' ).appendTo( 'head' );
+ }
+ $stylesheet.attr( 'href', $this.children( '.css_url' ).val() );
+
+ // repaint icons
+ if ( typeof wp !== 'undefined' && wp.svgPainter ) {
+ try {
+ colors = $.parseJSON( $this.children( '.icon_colors' ).val() );
+ } catch ( error ) {}
+
+ if ( colors ) {
+ wp.svgPainter.setColors( colors );
+ wp.svgPainter.paint();
+ }
+ }
+
+ // update user option
+ $.post( ajaxurl, {
+ action: 'save-user-color-scheme',
+ color_scheme: $this.children( 'input[name="admin_color"]' ).val(),
+ nonce: $('#color-nonce').val()
+ });
+ }
+ });
+ });
+
+})(jQuery);