CoreFiles by mySites.guru
snooze.js38 lines, 1,306 bytes, from Joomla_5.4.0-Stable-Full_Package.zip
Raw History Compare with 5.3.4
md5
0bbc783f5d5034957204dd0a4c991643
sha1
bde20e34d8f058d327f0c4f8ae309b97f57915a7
sha256
8670b42d87493a42313ae827ea661e5019c7102e886b7f675302a37737b7dd24
/**
 * @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) {
  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 20 releases, Joomla 5.4.0-beta1 to 6.1.0-alpha1. See them all, or every version of this file.