11 |
12 |
12 strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 ); |
13 strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass2 ); |
13 |
14 |
14 switch ( strength ) { |
15 switch ( strength ) { |
15 case 2: |
16 case 2: |
16 $('#pass-strength-result').addClass('bad').html( pwsL10n['bad'] ); |
17 $('#pass-strength-result').addClass('bad').html( pwsL10n.bad ); |
17 break; |
18 break; |
18 case 3: |
19 case 3: |
19 $('#pass-strength-result').addClass('good').html( pwsL10n['good'] ); |
20 $('#pass-strength-result').addClass('good').html( pwsL10n.good ); |
20 break; |
21 break; |
21 case 4: |
22 case 4: |
22 $('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] ); |
23 $('#pass-strength-result').addClass('strong').html( pwsL10n.strong ); |
23 break; |
24 break; |
24 case 5: |
25 case 5: |
25 $('#pass-strength-result').addClass('short').html( pwsL10n['mismatch'] ); |
26 $('#pass-strength-result').addClass('short').html( pwsL10n.mismatch ); |
26 break; |
27 break; |
27 default: |
28 default: |
28 $('#pass-strength-result').addClass('short').html( pwsL10n['short'] ); |
29 $('#pass-strength-result').addClass('short').html( pwsL10n['short'] ); |
29 } |
30 } |
30 } |
31 } |
31 |
32 |
32 $(document).ready( function() { |
33 $(document).ready( function() { |
33 var select = $('#display_name'); |
34 var $colorpicker, $stylesheet, user_id, current_user_id, |
|
35 select = $( '#display_name' ); |
34 |
36 |
35 $('#pass1').val('').keyup( check_pass_strength ); |
37 $('#pass1').val('').on( 'input propertychange', check_pass_strength ); |
36 $('#pass2').val('').keyup( check_pass_strength ); |
38 $('#pass2').val('').on( 'input propertychange', check_pass_strength ); |
37 $('#pass-strength-result').show(); |
39 $('#pass-strength-result').show(); |
38 $('.color-palette').click( function() { |
40 $('.color-palette').click( function() { |
39 $(this).siblings('input[name="admin_color"]').prop('checked', true); |
41 $(this).siblings('input[name="admin_color"]').prop('checked', true); |
40 }); |
42 }); |
41 |
43 |
48 display_firstname : $('#first_name').val() || '', |
50 display_firstname : $('#first_name').val() || '', |
49 display_lastname : $('#last_name').val() || '' |
51 display_lastname : $('#last_name').val() || '' |
50 }; |
52 }; |
51 |
53 |
52 if ( inputs.display_firstname && inputs.display_lastname ) { |
54 if ( inputs.display_firstname && inputs.display_lastname ) { |
53 inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname; |
55 inputs.display_firstlast = inputs.display_firstname + ' ' + inputs.display_lastname; |
54 inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname; |
56 inputs.display_lastfirst = inputs.display_lastname + ' ' + inputs.display_firstname; |
55 } |
57 } |
56 |
58 |
57 $.each( $('option', select), function( i, el ){ |
59 $.each( $('option', select), function( i, el ){ |
58 dub.push( el.value ); |
60 dub.push( el.value ); |
59 }); |
61 }); |
60 |
62 |
61 $.each(inputs, function( id, value ) { |
63 $.each(inputs, function( id, value ) { |
62 if ( ! value ) |
64 if ( ! value ) { |
63 return; |
65 return; |
|
66 } |
64 |
67 |
65 var val = value.replace(/<\/?[a-z][^>]*>/gi, ''); |
68 var val = value.replace(/<\/?[a-z][^>]*>/gi, ''); |
66 |
69 |
67 if ( inputs[id].length && $.inArray( val, dub ) == -1 ) { |
70 if ( inputs[id].length && $.inArray( val, dub ) === -1 ) { |
68 dub.push(val); |
71 dub.push(val); |
69 $('<option />', { |
72 $('<option />', { |
70 'text': val |
73 'text': val |
71 }).appendTo( select ); |
74 }).appendTo( select ); |
72 } |
75 } |
73 }); |
76 }); |
74 }); |
77 }); |
75 } |
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 // The default color scheme won't have one, so we'll need to create an element. |
|
100 if ( 0 === $stylesheet.length ) { |
|
101 $stylesheet = $( '<link rel="stylesheet" />' ).appendTo( 'head' ); |
|
102 } |
|
103 $stylesheet.attr( 'href', $this.children( '.css_url' ).val() ); |
|
104 |
|
105 // repaint icons |
|
106 if ( typeof wp !== 'undefined' && wp.svgPainter ) { |
|
107 try { |
|
108 colors = $.parseJSON( $this.children( '.icon_colors' ).val() ); |
|
109 } catch ( error ) {} |
|
110 |
|
111 if ( colors ) { |
|
112 wp.svgPainter.setColors( colors ); |
|
113 wp.svgPainter.paint(); |
|
114 } |
|
115 } |
|
116 |
|
117 // update user option |
|
118 $.post( ajaxurl, { |
|
119 action: 'save-user-color-scheme', |
|
120 color_scheme: $this.children( 'input[name="admin_color"]' ).val(), |
|
121 nonce: $('#color-nonce').val() |
|
122 }).done( function( response ) { |
|
123 if ( response.success ) { |
|
124 $( 'body' ).removeClass( response.data.previousScheme ).addClass( response.data.currentScheme ); |
|
125 } |
|
126 }); |
|
127 } |
|
128 }); |
|
129 }); |
|
130 |
|
131 $( '#destroy-sessions' ).on( 'click', function( e ) { |
|
132 var $this = $(this); |
|
133 |
|
134 wp.ajax.post( 'destroy-sessions', { |
|
135 nonce: $( '#_wpnonce' ).val(), |
|
136 user_id: $( '#user_id' ).val() |
|
137 }).done( function( response ) { |
|
138 $this.prop( 'disabled', true ); |
|
139 $this.siblings( '.notice' ).remove(); |
|
140 $this.before( '<div class="notice notice-success inline"><p>' + response.message + '</p></div>' ); |
|
141 }).fail( function( response ) { |
|
142 $this.siblings( '.notice' ).remove(); |
|
143 $this.before( '<div class="notice notice-error inline"><p>' + response.message + '</p></div>' ); |
|
144 }); |
|
145 |
|
146 e.preventDefault(); |
76 }); |
147 }); |
77 |
148 |
78 })(jQuery); |
149 })(jQuery); |