[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_contact/js/ -> admin-contacts-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  (() => {
   6    /**
   7      * Javascript to insert the link
   8      * View element calls jSelectContact when a contact is clicked
   9      * jSelectContact creates the link tag, sends it to the editor,
  10      * and closes the select frame.
  11      */
  12  
  13    window.jSelectContact = (id, title, catid, object, link, lang) => {
  14      let hreflang = '';
  15  
  16      if (!Joomla.getOptions('xtd-contacts')) {
  17        // Something went wrong
  18        window.parent.Joomla.Modal.getCurrent().close();
  19        return false;
  20      }
  21  
  22      const {
  23        editor
  24      } = Joomla.getOptions('xtd-contacts');
  25  
  26      if (lang !== '') {
  27        hreflang = `hreflang = "$lang}"`;
  28      }
  29  
  30      const tag = `<a $hreflang}  href="$link}">$title}</a>`;
  31      window.parent.Joomla.editors.instances[editor].replaceSelection(tag);
  32      window.parent.Joomla.Modal.getCurrent().close();
  33      return true;
  34    };
  35  
  36    document.addEventListener('DOMContentLoaded', () => {
  37      // Get the elements
  38      const elements = document.querySelectorAll('.select-link');
  39  
  40      for (let i = 0, l = elements.length; l > i; i += 1) {
  41        // Listen for click event
  42        elements[i].addEventListener('click', event => {
  43          event.preventDefault();
  44          const functionName = event.target.getAttribute('data-function');
  45  
  46          if (functionName === 'jSelectContact') {
  47            // Used in xtd_contacts
  48            window[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), null, null, event.target.getAttribute('data-uri'), event.target.getAttribute('data-language'), null);
  49          } else {
  50            // Used in com_menus
  51            window.parent[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), null, null, event.target.getAttribute('data-uri'), event.target.getAttribute('data-language'), null);
  52          }
  53  
  54          if (window.parent.Joomla.Modal) {
  55            window.parent.Joomla.Modal.getCurrent().close();
  56          }
  57        });
  58      }
  59    });
  60  })();


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