[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

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

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


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