[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/system/js/fields/ -> passwordview.js (source)

   1  /**
   2   * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   3   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   4   */
   5  (document => {
   6  
   7    document.addEventListener('DOMContentLoaded', () => {
   8      [].slice.call(document.querySelectorAll('input[type="password"]')).forEach(input => {
   9        const toggleButton = input.parentNode.querySelector('.input-password-toggle');
  10  
  11        if (toggleButton) {
  12          toggleButton.addEventListener('click', () => {
  13            const icon = toggleButton.firstElementChild;
  14            const srText = toggleButton.lastElementChild;
  15  
  16            if (input.type === 'password') {
  17              // Update the icon class
  18              icon.classList.remove('icon-eye');
  19              icon.classList.add('icon-eye-slash'); // Update the input type
  20  
  21              input.type = 'text'; // Focus the input field
  22  
  23              input.focus(); // Update the text for screenreaders
  24  
  25              srText.innerText = Joomla.Text._('JHIDEPASSWORD');
  26            } else if (input.type === 'text') {
  27              // Update the icon class
  28              icon.classList.add('icon-eye');
  29              icon.classList.remove('icon-eye-slash'); // Update the input type
  30  
  31              input.type = 'password'; // Focus the input field
  32  
  33              input.focus(); // Update the text for screenreaders
  34  
  35              srText.innerText = Joomla.Text._('JSHOWPASSWORD');
  36            }
  37          });
  38        }
  39  
  40        const modifyButton = input.parentNode.querySelector('.input-password-modify');
  41  
  42        if (modifyButton) {
  43          modifyButton.addEventListener('click', () => {
  44            const lock = !modifyButton.classList.contains('locked');
  45  
  46            if (lock === true) {
  47              // Add lock
  48              modifyButton.classList.add('locked'); // Reset value to empty string
  49  
  50              input.value = ''; // Disable the field
  51  
  52              input.setAttribute('disabled', ''); // Update the text
  53  
  54              modifyButton.innerText = Joomla.Text._('JMODIFY');
  55            } else {
  56              // Remove lock
  57              modifyButton.classList.remove('locked'); // Enable the field
  58  
  59              input.removeAttribute('disabled'); // Focus the input field
  60  
  61              input.focus(); // Update the text
  62  
  63              modifyButton.innerText = Joomla.Text._('JCANCEL');
  64            }
  65          });
  66        }
  67      });
  68    });
  69  })(document);


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer