CoreFiles by mySites.guru
config-default.js36 lines, 978 bytes, from Joomla_5.2.3-Stable-Full_Package.zip
Raw History Compare with 5.2.2
md5
13169f214185598ffbfd23fa36a4c922
sha1
fb5c5951cc87fca7a3042d73a44b1ec4f299ac1b
sha256
147c0f239d142ab65cc7e912867553bf90ef2c41c6217bb47cefcbfb5d3a0d8a
/**
 * @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 === 'config.cancel' || document.formvalidator.isValid(form)) {
      submitForm(task, form);
    }
  };

  /**
   * Register events
   */
  const registerEvents = () => {
    document.querySelectorAll(`[${buttonDataSelector}]`).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 135 releases, Joomla 5.1.0-beta2 to 6.3.0-alpha1. See them all, or every version of this file.