Changeset 46256 for trunk/src/js/_enqueues/admin/user-profile.js
- Timestamp:
- 09/23/2019 06:05:16 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/admin/user-profile.js
r46103 r46256 8 8 9 9 $pass1Row, 10 $pass1Wrap,11 10 $pass1, 12 $pass1Text,13 $pass1Label,14 11 $pass2, 15 12 $weakRow, … … 37 34 38 35 if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) { 39 $pass1 Wrap.addClass( 'show-password' );36 $pass1.attr( 'type', 'text' ); 40 37 } else { 41 38 $toggleButton.trigger( 'click' ); … … 48 45 function bindPass1() { 49 46 currentPass = $pass1.val(); 50 51 $pass1Wrap = $pass1.parent();52 53 $pass1Text = $( '<input type="text"/>' )54 .attr( {55 'id': 'pass1-text',56 'name': 'pass1-text',57 'autocomplete': 'off'58 } )59 .addClass( $pass1[0].className )60 .data( 'pw', $pass1.data( 'pw' ) )61 .val( $pass1.val() )62 .on( 'input', function () {63 if ( $pass1Text.val() === currentPass ) {64 return;65 }66 $pass2.val( $pass1Text.val() );67 $pass1.val( $pass1Text.val() ).trigger( 'pwupdate' );68 currentPass = $pass1Text.val();69 } );70 71 $pass1.after( $pass1Text );72 47 73 48 if ( 1 === parseInt( $pass1.data( 'reveal' ), 10 ) ) { … … 81 56 82 57 currentPass = $pass1.val(); 83 if ( $pass1Text.val() !== currentPass ) { 84 $pass1Text.val( currentPass ); 85 } 86 $pass1.add( $pass1Text ).removeClass( 'short bad good strong' ); 58 59 $pass1.removeClass( 'short bad good strong' ); 87 60 showOrHideWeakPasswordCheckbox(); 88 61 } ); 89 62 } 90 63 91 function resetToggle( ) {64 function resetToggle( show ) { 92 65 $toggleButton 93 .data( 'toggle', 0 )94 66 .attr({ 95 'aria-label': userProfileL10n.ariaHide67 'aria-label': show ? userProfileL10n.ariaShow : userProfileL10n.ariaHide 96 68 }) 97 69 .find( '.text' ) 98 .text( userProfileL10n.hide )70 .text( show ? userProfileL10n.show : userProfileL10n.hide ) 99 71 .end() 100 72 .find( '.dashicons' ) 101 .removeClass( 'dashicons-visibility' ) 102 .addClass( 'dashicons-hidden' ); 103 104 $pass1Text.focus(); 105 106 $pass1Label.attr( 'for', 'pass1-text' ); 73 .removeClass( show ? 'dashicons-hidden' : 'dashicons-visibility' ) 74 .addClass( show ? 'dashicons-visibility' : 'dashicons-hidden' ); 107 75 } 108 76 … … 110 78 $toggleButton = $pass1Row.find('.wp-hide-pw'); 111 79 $toggleButton.show().on( 'click', function () { 112 if ( 1 === parseInt( $toggleButton.data( 'toggle' ), 10 ) ) { 113 $pass1Wrap.addClass( 'show-password' ); 114 115 resetToggle(); 116 117 if ( ! _.isUndefined( $pass1Text[0].setSelectionRange ) ) { 118 $pass1Text[0].setSelectionRange( 0, 100 ); 119 } 80 if ( 'password' === $pass1.attr( 'type' ) ) { 81 $pass1.attr( 'type', 'text' ); 82 resetToggle( false ); 120 83 } else { 121 $pass1Wrap.removeClass( 'show-password' ); 122 $toggleButton 123 .data( 'toggle', 1 ) 124 .attr({ 125 'aria-label': userProfileL10n.ariaShow 126 }) 127 .find( '.text' ) 128 .text( userProfileL10n.show ) 129 .end() 130 .find( '.dashicons' ) 131 .removeClass('dashicons-hidden') 132 .addClass('dashicons-visibility'); 133 134 $pass1.focus(); 135 136 $pass1Label.attr( 'for', 'pass1' ); 137 138 if ( ! _.isUndefined( $pass1[0].setSelectionRange ) ) { 139 $pass1[0].setSelectionRange( 0, 100 ); 140 } 84 $pass1.attr( 'type', 'password' ); 85 resetToggle( true ); 86 } 87 88 $pass1.focus(); 89 90 if ( ! _.isUndefined( $pass1[0].setSelectionRange ) ) { 91 $pass1[0].setSelectionRange( 0, 100 ); 141 92 } 142 93 }); … … 148 99 $cancelButton; 149 100 150 $pass1Row = $('.user-pass1-wrap'); 151 $pass1Label = $pass1Row.find('th label').attr( 'for', 'pass1-text' ); 152 153 // hide this 101 $pass1Row = $( '.user-pass1-wrap, .user-pass-wrap' ); 102 103 // Hide the confirm password field when JavaScript support is enabled. 154 104 $('.user-pass2-wrap').hide(); 155 105 … … 169 119 if ( $pass1.length ) { 170 120 bindPass1(); 121 } else { 122 // Password field for the login form. 123 $pass1 = $( '#user_pass' ); 171 124 } 172 125 … … 190 143 $pass1.prop( 'disabled', true ); 191 144 $pass2.prop( 'disabled', true ); 192 $pass1Text.prop( 'disabled', true );193 145 } 194 146 … … 212 164 $pass1.attr( 'disabled', false ); 213 165 $pass2.attr( 'disabled', false ); 214 $pass1Text.attr( 'disabled', false ); 215 216 if ( $pass1Text.val().length === 0 ) { 166 167 if ( $pass1.val().length === 0 ) { 217 168 generatePassword(); 218 169 } 219 220 _.defer( function() {221 $pass1Text.focus();222 if ( ! _.isUndefined( $pass1Text[0].setSelectionRange ) ) {223 $pass1Text[0].setSelectionRange( 0, 100 );224 }225 }, 0 );226 170 } ); 227 171 … … 231 175 232 176 // Clear any entered password. 233 $pass1 Text.val( '' );177 $pass1.val( '' ); 234 178 235 179 // Generate a new password. … … 249 193 $pass1.prop( 'disabled', true ); 250 194 $pass2.prop( 'disabled', true ); 251 $pass1Text.prop( 'disabled', true ); 252 253 resetToggle(); 195 196 resetToggle( false ); 254 197 255 198 if ( $pass1Row.closest( 'form' ).is( '#your-profile' ) ) { … … 266 209 $pass2.prop( 'disabled', false ); 267 210 $pass2.val( $pass1.val() ); 268 $pass1Wrap.removeClass( 'show-password' );269 211 }); 270 212 } … … 306 248 307 249 if ( passStrength.className ) { 308 $pass1.add ( $pass1Text ).addClass( passStrength.className );250 $pass1.addClass( passStrength.className ); 309 251 if ( $( passStrength ).is( '.short, .bad' ) ) { 310 252 if ( ! $weakCheckbox.prop( 'checked' ) ) {
Note: See TracChangeset
for help on using the changeset viewer.