[ Index ] |
WordPress Cross Reference |
[Summary view] [Print] [Text view]
1 /* global ajaxurl, pwsL10n */ 2 (function($){ 3 4 function check_pass_strength() { 5 var pass1 = $('#pass1').val(), pass2 = $('#pass2').val(), strength; 6 7 $('#pass-strength-result').removeClass('short bad good strong'); 8 if ( ! pass1 ) { 9 $('#pass-strength-result').html( pwsL10n.empty ); 10 return; 11 } 12 13 strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 ); 14 15 switch ( strength ) { 16 case 2: 17 $('#pass-strength-result').addClass('bad').html( pwsL10n.bad ); 18 break; 19 case 3: 20 $('#pass-strength-result').addClass('good').html( pwsL10n.good ); 21 break; 22 case 4: 23 $('#pass-strength-result').addClass('strong').html( pwsL10n.strong ); 24 break; 25 case 5: 26 $('#pass-strength-result').addClass('short').html( pwsL10n.mismatch ); 27 break; 28 default: 29 $('#pass-strength-result').addClass('short').html( pwsL10n['short'] ); 30 } 31 } 32 33 $(document).ready( function() { 34 var $colorpicker, $stylesheet, user_id, current_user_id, 35 select = $( '#display_name' ); 36 37 $('#pass1').val('').keyup( check_pass_strength ); 38 $('#pass2').val('').keyup( check_pass_strength ); 39 $('#pass-strength-result').show(); 40 $('.color-palette').click( function() { 41 $(this).siblings('input[name="admin_color"]').prop('checked', true); 42 }); 43 44 if ( select.length ) { 45 $('#first_name, #last_name, #nickname').bind( 'blur.user_profile', function() { 46 var dub = [], 47 inputs = { 48 display_nickname : $('#nickname').val() || '', 49 display_username : $('#user_login').val() || '', 50 display_firstname : $('#first_name').val() || '', 51 display_lastname : $('#last_name').val() || '' 52 }; 53 54 if ( inputs.display_firstname && inputs.display_lastname ) { 55 inputs.display_firstlast = inputs.display_firstname + ' ' + inputs.display_lastname; 56 inputs.display_lastfirst = inputs.display_lastname + ' ' + inputs.display_firstname; 57 } 58 59 $.each( $('option', select), function( i, el ){ 60 dub.push( el.value ); 61 }); 62 63 $.each(inputs, function( id, value ) { 64 if ( ! value ) { 65 return; 66 } 67 68 var val = value.replace(/<\/?[a-z][^>]*>/gi, ''); 69 70 if ( inputs[id].length && $.inArray( val, dub ) === -1 ) { 71 dub.push(val); 72 $('<option />', { 73 'text': val 74 }).appendTo( select ); 75 } 76 }); 77 }); 78 } 79 80 $colorpicker = $( '#color-picker' ); 81 $stylesheet = $( '#colors-css' ); 82 user_id = $( 'input#user_id' ).val(); 83 current_user_id = $( 'input[name="checkuser_id"]' ).val(); 84 85 $colorpicker.on( 'click.colorpicker', '.color-option', function() { 86 var colors, 87 $this = $(this); 88 89 if ( $this.hasClass( 'selected' ) ) { 90 return; 91 } 92 93 $this.siblings( '.selected' ).removeClass( 'selected' ); 94 $this.addClass( 'selected' ).find( 'input[type="radio"]' ).prop( 'checked', true ); 95 96 // Set color scheme 97 if ( user_id === current_user_id ) { 98 // Load the colors stylesheet 99 $stylesheet.attr( 'href', $this.children( '.css_url' ).val() ); 100 101 // repaint icons 102 if ( typeof wp !== 'undefined' && wp.svgPainter ) { 103 try { 104 colors = $.parseJSON( $this.children( '.icon_colors' ).val() ); 105 } catch ( error ) {} 106 107 if ( colors ) { 108 wp.svgPainter.setColors( colors ); 109 wp.svgPainter.paint(); 110 } 111 } 112 113 // update user option 114 $.post( ajaxurl, { 115 action: 'save-user-color-scheme', 116 color_scheme: $this.children( 'input[name="admin_color"]' ).val(), 117 nonce: $('#color-nonce').val() 118 }); 119 } 120 }); 121 }); 122 123 })(jQuery);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 25 01:41:18 2014 | WordPress honlapkészítés: online1.hu |