[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_users/js/ -> two-factor-focus.js (source)

   1  /**
   2   * @copyright   (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
   3   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   4   */
   5  (() => {
   6  
   7    document.addEventListener('DOMContentLoaded', () => {
   8      const elCodeField = document.getElementById('users-mfa-code');
   9      const elValidateButton = document.getElementById('users-mfa-captive-button-submit');
  10      const elToolbarButton = document.getElementById('toolbar-user-mfa-submit').querySelector('button'); // Focus the code field. If the code field is hidden, focus the submit button (useful e.g. for WebAuthn)
  11  
  12      if (elCodeField && elCodeField.style.display !== 'none' && !elCodeField.classList.contains('visually-hidden') && elCodeField.type !== 'hidden') {
  13        elCodeField.focus();
  14      } else {
  15        if (elValidateButton) {
  16          elValidateButton.focus();
  17        }
  18  
  19        if (elToolbarButton) {
  20          elToolbarButton.focus();
  21        }
  22      } // Capture the admin toolbar buttons, make them click the inline buttons
  23  
  24  
  25      document.querySelectorAll('.button-user-mfa-submit').forEach(elButton => {
  26        elButton.addEventListener('click', e => {
  27          e.preventDefault();
  28          elValidateButton.click();
  29        });
  30      });
  31      document.querySelectorAll('.button-user-mfa-logout').forEach(elButton => {
  32        elButton.addEventListener('click', e => {
  33          e.preventDefault();
  34          const elLogout = document.getElementById('users-mfa-captive-button-logout');
  35  
  36          if (elLogout) {
  37            elLogout.click();
  38          }
  39        });
  40      });
  41      document.querySelectorAll('.button-user-mfa-choose-another').forEach(elButton => {
  42        elButton.addEventListener('click', e => {
  43          e.preventDefault();
  44          const elChooseAnother = document.getElementById('users-mfa-captive-form-choose-another');
  45  
  46          if (elChooseAnother) {
  47            elChooseAnother.click();
  48          }
  49        });
  50      });
  51    });
  52  })();


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