CoreFiles by mySites.guru
two-factor-focus-es5.js56 lines, 2,192 bytes, from Joomla_4.4.13-Stable-Full_Package.zip
Raw History Compare with 4.4.12
md5
f1bd97251d76f8cf8d0035ad52b13d90
sha1
81da9aba2da71a083b3f19533bdd29060015033e
sha256
e8b5f8e807813777ab82242663af41aacb90cbe753f024a8cb211b205d06e60e
(function () {
  'use strict';

  /**
   * @copyright   (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   */

  (function () {
    document.addEventListener('DOMContentLoaded', function () {
      var _document$getElementB;
      var elCodeField = document.getElementById('users-mfa-code');
      var elValidateButton = document.getElementById('users-mfa-captive-button-submit');
      var elToolbarButton = (_document$getElementB = document.getElementById('toolbar-user-mfa-submit')) == null ? void 0 : _document$getElementB.querySelector('button');

      // Focus the code field. If the code field is hidden, focus the submit button (useful e.g. for WebAuthn)
      if (elCodeField && elCodeField.style.display !== 'none' && !elCodeField.classList.contains('visually-hidden') && elCodeField.type !== 'hidden') {
        elCodeField.focus();
      } else {
        if (elValidateButton) {
          elValidateButton.focus();
        }
        if (elToolbarButton) {
          elToolbarButton.focus();
        }
      }

      // Capture the admin toolbar buttons, make them click the inline buttons
      document.querySelectorAll('.button-user-mfa-submit').forEach(function (elButton) {
        elButton.addEventListener('click', function (e) {
          e.preventDefault();
          elValidateButton.click();
        });
      });
      document.querySelectorAll('.button-user-mfa-logout').forEach(function (elButton) {
        elButton.addEventListener('click', function (e) {
          e.preventDefault();
          var elLogout = document.getElementById('users-mfa-captive-button-logout');
          if (elLogout) {
            elLogout.click();
          }
        });
      });
      document.querySelectorAll('.button-user-mfa-choose-another').forEach(function (elButton) {
        elButton.addEventListener('click', function (e) {
          e.preventDefault();
          var elChooseAnother = document.getElementById('users-mfa-captive-form-choose-another');
          if (elChooseAnother) {
            elChooseAnother.click();
          }
        });
      });
    });
  })();

})();

The same content is in 44 releases, Joomla 4.3.2-rc1 to 5.0.0-alpha1. See them all, or every version of this file.