CoreFiles by mySites.guru
modules-default.js37 lines, 1,023 bytes, from Joomla_4.4.13-Stable-Full_Package.zip
Raw History Compare with 4.4.12
md5
648a8980205b6363d0008625d175a49e
sha1
564bae775e0c0b57ad4cdf9ba9e02c407631e223
sha256
5f30a7b438e47defccfdcb680b6901f5a44755752e28ae6dd577fcafca85e2f4
/**
 * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
((document, submitForm) => {

  // Selectors used by this script
  const buttonDataSelector = 'data-submit-task';

  /**
   * Submit the task
   * @param task
   * @param form
   */
  const submitTask = (task, form) => {
    if (task === 'modules.cancel' || document.formvalidator.isValid(form)) {
      submitForm(task, form);
    }
  };

  /**
   * Register events
   */
  const registerEvents = () => {
    const buttons = [].slice.call(document.querySelectorAll(`[${buttonDataSelector}]`));
    buttons.forEach(button => {
      button.addEventListener('click', e => {
        e.preventDefault();
        const task = e.currentTarget.getAttribute(buttonDataSelector);
        submitTask(task, e.currentTarget.form);
      });
    });
  };
  document.addEventListener('DOMContentLoaded', () => {
    registerEvents();
  });
})(document, Joomla.submitform);

The same content is in 79 releases, Joomla 4.3.0-alpha1 to 5.1.0-beta1. See them all, or every version of this file.