[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/plg_quickicon_overridecheck/js/ -> overridecheck.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  (() => {
   6  
   7    const checkOverride = () => {
   8      if (Joomla.getOptions('js-override-check')) {
   9        const options = Joomla.getOptions('js-override-check');
  10  
  11        const update = (type, text, linkHref) => {
  12          const link = document.getElementById('plg_quickicon_overridecheck');
  13          const linkSpans = link.querySelectorAll('span.j-links-link');
  14  
  15          if (link) {
  16            link.classList.add(type);
  17  
  18            if (linkHref) {
  19              link.setAttribute('href', linkHref);
  20            }
  21          }
  22  
  23          if (linkSpans.length) {
  24            linkSpans.forEach(span => {
  25              span.innerHTML = Joomla.sanitizeHtml(text);
  26            });
  27          }
  28        };
  29        /**
  30         * DO NOT use fetch() for QuickIcon requests. They must be queued.
  31         *
  32         * @see https://github.com/joomla/joomla-cms/issues/38001
  33         */
  34  
  35  
  36        Joomla.enqueueRequest({
  37          url: options.ajaxUrl,
  38          method: 'GET',
  39          promise: true
  40        }).then(xhr => {
  41          const response = xhr.responseText;
  42          const updateInfoList = JSON.parse(response);
  43  
  44          if (updateInfoList.installerOverride !== 'disabled') {
  45            if (Array.isArray(updateInfoList)) {
  46              if (updateInfoList.length === 0) {
  47                // No overrides found
  48                update('success', Joomla.Text._('PLG_QUICKICON_OVERRIDECHECK_UPTODATE'), '');
  49              } else {
  50                // Scroll to page top
  51                window.scrollTo(0, 0);
  52                update('danger', Joomla.Text._('PLG_QUICKICON_OVERRIDECHECK_OVERRIDEFOUND').replace('%s', `<span class="badge text-dark bg-light">$updateInfoList.length}</span>`), '');
  53              }
  54            } else {
  55              throw new Error('Override check: unexpected value type');
  56            }
  57          } else {
  58            update('danger', Joomla.Text._('PLG_QUICKICON_OVERRIDECHECK_ERROR_ENABLE'), `index.php?option=com_plugins&task=plugin.edit&extension_id=$options.pluginId}`);
  59          }
  60        }).catch(() => {
  61          // An error occurred
  62          update('danger', Joomla.Text._('PLG_QUICKICON_OVERRIDECHECK_ERROR'), '');
  63        });
  64      }
  65    }; // Give some times to the layout and other scripts to settle their stuff
  66  
  67  
  68    window.addEventListener('load', () => {
  69      setTimeout(checkOverride, 390);
  70    });
  71  })();


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