diff --git a/src/wp-admin/js/user-profile.js b/src/wp-admin/js/user-profile.js
index 99eae64..72130f7 100644
a
|
b
|
|
22 | 22 | } else { |
23 | 23 | pw_field.val( pw_field.data( 'pw' ) ); |
24 | 24 | pw_field.trigger( 'propertychange' ); |
25 | | pw_field.attr( 'type', 'text' ).focus(); |
26 | | pw_field[0].setSelectionRange(100, 100); |
| 25 | pw_field = toggleField( pw_field, 1 ); |
| 26 | pw_field.focus(); |
| 27 | if ( 'undefined' !== typeof pw_field[0].setSelectionRange ){ |
| 28 | pw_field[0].setSelectionRange(100, 100); |
| 29 | } |
27 | 30 | } |
28 | 31 | }; |
29 | 32 | |
… |
… |
|
38 | 41 | |
39 | 42 | parentform.on('submit', function(){ |
40 | 43 | pw_field2.val( pw_field.val() ); |
41 | | pw_field.attr('type', 'password'); |
| 44 | pw_field = toggleField( pw_field, 0 ); |
42 | 45 | }); |
43 | 46 | |
44 | 47 | |
45 | | pw_field.on('input propertychange', function(){ |
| 48 | parentform.on('input keyup propertychange', '#pass1', function(){ |
46 | 49 | setTimeout( function(){ |
47 | 50 | var cssClass = pw_strength.attr('class'); |
48 | 51 | pw_field.removeClass( 'short bad good strong' ); |
… |
… |
|
79 | 82 | * This fixes the issue by copying any changes from the hidden |
80 | 83 | * pass2 field to the pass1 field. |
81 | 84 | */ |
82 | | pw_field2.on( 'input propertychange', function() { |
| 85 | pw_field2.on( 'input keyup propertychange', function() { |
83 | 86 | pw_field.val( pw_field2.val() ); |
84 | 87 | pw_field.trigger( 'propertychange' ); |
85 | 88 | } ); |
… |
… |
|
93 | 96 | pw_togglebtn.on( 'click', function() { |
94 | 97 | var show = pw_togglebtn.attr( 'data-toggle' ); |
95 | 98 | if ( show == 1 ) { |
96 | | pw_field.attr( 'type', 'text' ); |
| 99 | pw_field = toggleField( pw_field, 1 ); |
97 | 100 | pw_togglebtn.attr( 'data-toggle', 0 ) |
98 | 101 | .find( '.text' ) |
99 | 102 | .text( 'hide' ) |
100 | 103 | ; |
101 | 104 | } else { |
102 | | pw_field.attr( 'type', 'password' ); |
| 105 | pw_field = toggleField( pw_field, 0 ); |
103 | 106 | pw_togglebtn.attr( 'data-toggle', 1 ) |
104 | 107 | .find( '.text' ) |
105 | 108 | .text( 'show' ) |
106 | 109 | ; |
107 | 110 | } |
108 | 111 | pw_field.focus(); |
109 | | pw_field[0].setSelectionRange(100, 100); |
| 112 | if ( 'undefined' !== typeof pw_field[0].setSelectionRange ){ |
| 113 | pw_field[0].setSelectionRange(100, 100); |
| 114 | } |
110 | 115 | }); |
| 116 | |
111 | 117 | }); |
112 | 118 | |
| 119 | function toggleField( pw_field, show ) { |
| 120 | var newField = document.createElement( 'input' ); |
| 121 | var type = 'password'; |
| 122 | var $newField; |
| 123 | |
| 124 | if ( 1 == show ) { |
| 125 | type = 'text'; |
| 126 | } |
| 127 | |
| 128 | newField.type = type; |
| 129 | $newField = $( newField ); |
| 130 | |
| 131 | $newField |
| 132 | .attr({ |
| 133 | 'id' : 'pass1', |
| 134 | 'name' : 'pass1', |
| 135 | 'autocomplete' : 'off' |
| 136 | }) |
| 137 | .addClass( pw_field[0].className ) |
| 138 | .data( 'pw', pw_field.data( 'pw' ) ); |
| 139 | $newField.val( pw_field.val() ); |
| 140 | |
| 141 | pw_field.replaceWith( $newField ); |
| 142 | return $newField; |
| 143 | } |
| 144 | |
113 | 145 | function check_pass_strength() { |
114 | 146 | var pass1 = $('#pass1').val(), pass2 = $('#pass2').val(), strength; |
115 | 147 | |
… |
… |
|
141 | 173 | |
142 | 174 | $(document).ready( function() { |
143 | 175 | var $colorpicker, $stylesheet, user_id, current_user_id, |
144 | | select = $( '#display_name' ); |
| 176 | select = $( '#display_name' ), |
| 177 | pw_form = $('#pass1').closest('form'); |
145 | 178 | |
146 | | $('#pass1').val('').on( 'input propertychange', check_pass_strength ); |
147 | | $('#pass2').val('').on( 'input propertychange', check_pass_strength ); |
| 179 | $('#pass1').val(''); |
| 180 | $('#pass2').val(''); |
| 181 | pw_form.on( 'input keyup propertychange', '#pass1, #pass2', check_pass_strength ); |
148 | 182 | $('#pass-strength-result').show(); |
149 | 183 | $('.color-palette').click( function() { |
150 | 184 | $(this).siblings('input[name="admin_color"]').prop('checked', true); |