CoreFiles by mySites.guru
passwordview.js47 lines, 1,551 bytes, from Joomla_4.0.0-beta3-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta2
md5
04bebd6ca9e760988087fd5ecbd32ff1
sha1
7c5411150bb1daba19d124d142e0c6894a1847d3
sha256
2de9fd7c11180db6881f49544c70b0fd2ffb12e981e6ec5f6677964dc9edc484
/**
* 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
 */
(function (document) {
  'use strict';

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

      if (!toggleButton) {
        return;
      }

      toggleButton.addEventListener('click', function () {
        var icon = toggleButton.firstElementChild;
        var 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.