CoreFiles by mySites.guru
passwordview.es6.js47 lines, 1,529 bytes, from Joomla_4.0.0-beta5-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta4
md5
76b9807c72d03b60b026d5cd56a2a730
sha1
93df225fece78b6aa729e230f6ef1d50671d6c40
sha256
d072b0701683bd51d90e74e4a275f1eccb57f5f0e52bfbae815838966aaa148f
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
(document => {
  'use strict';

  document.addEventListener('DOMContentLoaded', () => {
    [].slice.call(document.querySelectorAll('input[type="password"]')).forEach(input => {
      const toggleButton = input.parentNode.querySelector('.input-password-toggle');

      if (!toggleButton) {
        return;
      }

      toggleButton.addEventListener('click', () => {
        const icon = toggleButton.firstElementChild;
        const srText = toggleButton.lastElementChild;

        if (input.type === 'password') {
          // Update the icon class
          icon.classList.remove('fa-eye');
          icon.classList.add('fa-eye-slash'); // Update the input type

          input.type = 'text'; // Focus the input field

          input.focus(); // Update the text for screenreaders

          srText.innerText = Joomla.Text._('JHIDEPASSWORD');
        } else if (input.type === 'text') {
          // Update the icon class
          icon.classList.add('fa-eye');
          icon.classList.remove('fa-eye-slash'); // Update the input type

          input.type = 'password'; // Update the text for screenreaders

          srText.innerText = Joomla.Text._('JSHOWPASSWORD');
        }
      });
    });
  });
})(document);

The same content is in 3 releases, Joomla 4.0.0-beta3 to 4.0.0-beta5. See them all, or every version of this file.