[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/plg_user_token/js/ -> token-es5.js (source)

   1  (function () {
   2    'use strict';
   3  
   4    /**
   5     * @copyright  (C) 2020 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, Joomla) {
   9      var copyToClipboardFallback = function copyToClipboardFallback(input) {
  10        input.focus();
  11        input.select();
  12  
  13        try {
  14          var copy = document.execCommand('copy');
  15  
  16          if (copy) {
  17            Joomla.renderMessages({
  18              message: [Joomla.Text._('PLG_USER_TOKEN_COPY_SUCCESS')]
  19            });
  20          } else {
  21            Joomla.renderMessages({
  22              error: [Joomla.Text._('PLG_USER_TOKEN_COPY_FAIL')]
  23            });
  24          }
  25        } catch (err) {
  26          Joomla.renderMessages({
  27            error: [err]
  28          });
  29        }
  30      };
  31  
  32      var copyToClipboard = function copyToClipboard() {
  33        var button = document.getElementById('token-copy');
  34        button.addEventListener('click', function (_ref) {
  35          var currentTarget = _ref.currentTarget;
  36          var input = currentTarget.previousElementSibling;
  37  
  38          if (!navigator.clipboard) {
  39            copyToClipboardFallback(input);
  40            return;
  41          }
  42  
  43          navigator.clipboard.writeText(input.value).then(function () {
  44            Joomla.renderMessages({
  45              message: [Joomla.Text._('PLG_USER_TOKEN_COPY_SUCCESS')]
  46            });
  47          }, function () {
  48            Joomla.renderMessages({
  49              error: [Joomla.Text._('PLG_USER_TOKEN_COPY_FAIL')]
  50            });
  51          });
  52        });
  53      };
  54  
  55      var onBoot = function onBoot() {
  56        copyToClipboard();
  57        document.removeEventListener('DOMContentLoaded', onBoot);
  58      };
  59  
  60      document.addEventListener('DOMContentLoaded', onBoot);
  61    })(document, Joomla);
  62  
  63  })();


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