CoreFiles by mySites.guru
admin-articles-modal.js48 lines, 1,925 bytes, from Joomla_4.4.13-Stable-Full_Package.zip
Raw History Compare with 4.4.12
md5
c26e92bf2b37c679f82532249459b4ee
sha1
2045aa6ec616e25222da77cc918287f4a950a778
sha256
c2e8cc9b3156abf973fed289fdbf149316d30d65c865f52790ddf30dda595086
/**
 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
(() => {

  /**
    * Javascript to insert the link
    * View element calls jSelectArticle when an article is clicked
    * jSelectArticle creates the link tag, sends it to the editor,
    * and closes the select frame.
    * */
  window.jSelectArticle = (id, title, catid, object, link, lang) => {
    if (!Joomla.getOptions('xtd-articles')) {
      if (window.parent.Joomla.Modal) {
        window.parent.Joomla.Modal.getCurrent().close();
      }
    }
    const {
      editor
    } = Joomla.getOptions('xtd-articles');
    const tag = `<a href="${link}"${lang !== '' ? ` hreflang="${lang}"` : ''}>${title}</a>`;
    window.parent.Joomla.editors.instances[editor].replaceSelection(tag);
    if (window.parent.Joomla.Modal) {
      window.parent.Joomla.Modal.getCurrent().close();
    }
  };
  document.querySelectorAll('.select-link').forEach(element => {
    // Listen for click event
    element.addEventListener('click', event => {
      event.preventDefault();
      const {
        target
      } = event;
      const functionName = target.getAttribute('data-function');
      if (functionName === 'jSelectArticle') {
        // Used in xtd_contacts
        window[functionName](target.getAttribute('data-id'), target.getAttribute('data-title'), target.getAttribute('data-cat-id'), null, target.getAttribute('data-uri'), target.getAttribute('data-language'));
      } else {
        // Used in com_menus
        window.parent[functionName](target.getAttribute('data-id'), target.getAttribute('data-title'), target.getAttribute('data-cat-id'), null, target.getAttribute('data-uri'), target.getAttribute('data-language'));
      }
      if (window.parent.Joomla.Modal) {
        window.parent.Joomla.Modal.getCurrent().close();
      }
    });
  });
})();

The same content is in 53 releases, Joomla 4.3.0-rc1 to 5.0.0-alpha4. See them all, or every version of this file.