[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_modules/js/ -> admin-modules-modal.js (source)

   1  /**
   2    * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   3    * @license    GNU General Public License version 2 or later; see LICENSE.txt
   4    */
   5  document.addEventListener('DOMContentLoaded', () => {
   6  
   7    const modulesLinks = [].slice.call(document.querySelectorAll('.js-module-insert'));
   8    const positionsLinks = [].slice.call(document.querySelectorAll('.js-position-insert')); // Assign listener for click event (for single module id insertion)
   9  
  10    modulesLinks.forEach(element => {
  11      element.addEventListener('click', event => {
  12        event.preventDefault();
  13        const modid = event.target.getAttribute('data-module');
  14        const editor = event.target.getAttribute('data-editor'); // Use the API
  15  
  16        if (window.parent.Joomla && window.parent.Joomla.editors && window.parent.Joomla.editors.instances && Object.prototype.hasOwnProperty.call(window.parent.Joomla.editors.instances, editor)) {
  17          window.parent.Joomla.editors.instances[editor].replaceSelection(`{loadmoduleid $modid}}`);
  18        }
  19  
  20        if (window.parent.Joomla.Modal) {
  21          window.parent.Joomla.Modal.getCurrent().close();
  22        }
  23      });
  24    }); // Assign listener for click event (for position insertion)
  25  
  26    positionsLinks.forEach(element => {
  27      element.addEventListener('click', event => {
  28        event.preventDefault();
  29        const position = event.target.getAttribute('data-position');
  30        const editor = event.target.getAttribute('data-editor'); // Use the API
  31  
  32        if (window.Joomla && window.Joomla.editors && Joomla.editors.instances && Object.prototype.hasOwnProperty.call(window.parent.Joomla.editors.instances, editor)) {
  33          window.parent.Joomla.editors.instances[editor].replaceSelection(`{loadposition $position}}`);
  34        }
  35  
  36        if (window.parent.Joomla.Modal) {
  37          window.parent.Joomla.Modal.getCurrent().close();
  38        }
  39      });
  40    });
  41  });


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer