| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /** 2 * @output wp-admin/js/password-toggle.js 3 */ 4 5 /** 6 * Adds functionality for password visibility buttons to toggle between text and password input types. 7 * 8 * @since 6.3.0 9 */ 10 ( function () { 11 var toggleElements, status, input, icon, label, __ = wp.i18n.__; 12 13 toggleElements = document.querySelectorAll( '.pwd-toggle' ); 14 15 toggleElements.forEach( function ( toggle ) { 16 toggle.classList.remove( 'hide-if-no-js' ); 17 toggle.addEventListener( 'click', togglePassword ); 18 } ); 19 20 /** 21 * Toggles the password input field visibility. 22 * 23 * @this {HTMLElement} 24 */ 25 function togglePassword() { 26 status = this.getAttribute( 'data-toggle' ); 27 input = this.parentElement ? this.parentElement.children.namedItem( 'pwd' ) : null; 28 icon = this.getElementsByClassName( 'dashicons' )[ 0 ]; 29 label = this.getElementsByClassName( 'text' )[ 0 ]; 30 31 if ( ! input || ! icon || ! label ) { 32 return; 33 } 34 35 if ( 0 === parseInt( status || '', 10 ) ) { 36 this.setAttribute( 'data-toggle', '1' ); 37 this.setAttribute( 'aria-label', __( 'Hide password' ) ); 38 input.setAttribute( 'type', 'text' ); 39 label.innerHTML = __( 'Hide' ); 40 icon.classList.remove( 'dashicons-visibility' ); 41 icon.classList.add( 'dashicons-hidden' ); 42 } else { 43 this.setAttribute( 'data-toggle', '0' ); 44 this.setAttribute( 'aria-label', __( 'Show password' ) ); 45 input.setAttribute( 'type', 'password' ); 46 label.innerHTML = __( 'Show' ); 47 icon.classList.remove( 'dashicons-hidden' ); 48 icon.classList.add( 'dashicons-visibility' ); 49 } 50 } 51 } )();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Tue Dec 1 08:20:01 2026 | Cross-referenced by PHPXref |