CoreFiles by mySites.guru
templates-default.es6.js39 lines, 1,045 bytes, from Joomla_4.0.0-alpha6-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha5
md5
f12bae74af640e51dce167b4f69eff76
sha1
8129d86be1a607333fdb7d399e01a33e42071c22
sha256
8b1d27a44558413a146780ba52294f1acb3fffb407211391cca0bb63a7f31995
/**
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
((document, submitForm) => {
  'use strict';

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

  /**
   * Submit the task
   * @param task
   * @param form
   */
  const submitTask = (task, form) => {
    if (task === 'templates.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.target.getAttribute(buttonDataSelector);
        submitTask(task, e.target.form);
      });
    });
  };

  document.addEventListener('DOMContentLoaded', () => {
    registerEvents();
  });
})(document, Joomla.submitform);

The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.