CoreFiles by mySites.guru
snooze.js39 lines, 1,357 bytes, from Joomla_4.4.7-Stable-Full_Package.zip
Raw History Compare with 4.4.6
md5
5994fff6924957c31e253b0117a78d8f
sha1
b03994b13ac1b46658e2594a5608739e8e32287f
sha256
920d8ede107f3f685b46be708d3e830609400c6443f78a35b715318842de325d
/**
 * @package     Joomla.Plugin
 * @subpackage  Quickicon.eos
 * @copyright  (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
if (!Joomla) {
  throw new Error('Joomla API is not properly initialised');
}
const url = new URL(`${Joomla.getOptions('system.paths').baseFull}index.php?option=com_ajax&group=quickicon&plugin=eos&format=json`);
async function onMutatedMessagesContainer(mutationList, observer) {
  // eslint-disable-next-line no-restricted-syntax
  for (const mutation of mutationList) {
    const nodes = Array.from(mutation.addedNodes);
    if (!nodes.length) {
      return;
    }
    const alerts = nodes.filter(node => node.querySelector('.eosnotify-snooze-btn'));
    if (!alerts.length) {
      return;
    }
    observer.disconnect();
    alerts[0].querySelector('.eosnotify-snooze-btn').addEventListener('click', () => fetch(url, {
      headers: {
        'X-CSRF-Token': Joomla.getOptions('csrf.token') || ''
      }
    }).then(response => {
      if (response.ok) {
        alerts[0].closest('joomla-alert').close();
      }
    }));
  }
}
const observer = new MutationObserver(onMutatedMessagesContainer);
observer.observe(document.querySelector('#system-message-container'), {
  attributes: false,
  childList: true,
  subtree: true
});

The same content is in 119 releases, Joomla 4.4.0-alpha1 to 6.0.0-alpha3. See them all, or every version of this file.