CoreFiles by mySites.guru
admin-modules-modal.es6.js47 lines, 1,755 bytes, from Joomla_4.0.0-alpha5-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha3
md5
b61ecbddcd52a4a823eca1c91b6dadc3
sha1
6b8578f5da81ff9a865e46eeb51a98a14ecdfdb8
sha256
f7d45d2d4946e3b2b53144343c285676209b2d8ff42856e1112b6d7f748c04bc
/**
 * @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.addEventListener('DOMContentLoaded', () => {
  'use strict';

  /** Get the elements * */
  const modulesLinks = [].slice.call(document.querySelectorAll('.js-module-insert'));
  const positionsLinks = [].slice.call(document.querySelectorAll('.js-position-insert'));

  /** Assign listener for click event (for single module insertion) * */
  modulesLinks.forEach((modulesLink) => {
    modulesLink.addEventListener('click', (event) => {
      event.preventDefault();
      const type = event.target.getAttribute('data-module');
      const name = event.target.getAttribute('data-title');
      const editor = event.target.getAttribute('data-editor');

      // Insert the short tag in the editor
      window.parent.Joomla.editors.instances[editor].replaceSelection(`{loadmodule ${type},${name}}`);

      // Close the modal
      if (window.parent.Joomla.Modal) {
        window.parent.Joomla.Modal.getCurrent().close();
      }
    });
  });

  /** Assign listener for click event (for position insertion) * */
  positionsLinks.forEach((positionsLink) => {
    positionsLink.addEventListener('click', (event) => {
      event.preventDefault();
      const position = event.target.getAttribute('data-position');
      const editor = event.target.getAttribute('data-editor');

      // Insert the short tag in the editor
      window.parent.Joomla.editors.instances[editor].replaceSelection(`{loadposition ${position}}`);

      // Close the modal
      if (window.parent.Joomla.Modal) {
        window.parent.Joomla.Modal.getCurrent().close();
      }
    });
  });
});

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.