[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/com_content/js/ -> admin-articles-modal-es5.js (source)

   1  (function () {
   2    'use strict';
   3  
   4    /**
   5     * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   6     * @license    GNU General Public License version 2 or later; see LICENSE.txt
   7     */
   8    (function () {
   9      /**
  10        * Javascript to insert the link
  11        * View element calls jSelectArticle when an article is clicked
  12        * jSelectArticle creates the link tag, sends it to the editor,
  13        * and closes the select frame.
  14        * */
  15      window.jSelectArticle = function (id, title, catid, object, link, lang) {
  16        var hreflang = '';
  17  
  18        if (!Joomla.getOptions('xtd-articles')) {
  19          // Something went wrong!
  20          // @TODO Close the modal
  21          return false;
  22        }
  23  
  24        var _Joomla$getOptions = Joomla.getOptions('xtd-articles'),
  25            editor = _Joomla$getOptions.editor;
  26  
  27        if (lang !== '') {
  28          hreflang = "hreflang=\"" + lang + "\"";
  29        }
  30  
  31        var tag = "<a " + hreflang + " href=\"" + link + "\">" + title + "</a>";
  32        window.parent.Joomla.editors.instances[editor].replaceSelection(tag);
  33  
  34        if (window.parent.Joomla.Modal) {
  35          window.parent.Joomla.Modal.getCurrent().close();
  36        }
  37  
  38        return true;
  39      };
  40  
  41      document.addEventListener('DOMContentLoaded', function () {
  42        // Get the elements
  43        var elements = document.querySelectorAll('.select-link');
  44  
  45        for (var i = 0, l = elements.length; l > i; i += 1) {
  46          // Listen for click event
  47          elements[i].addEventListener('click', function (event) {
  48            event.preventDefault();
  49            var target = event.target;
  50            var functionName = target.getAttribute('data-function');
  51  
  52            if (functionName === 'jSelectArticle') {
  53              // Used in xtd_contacts
  54              window[functionName](target.getAttribute('data-id'), target.getAttribute('data-title'), target.getAttribute('data-cat-id'), null, target.getAttribute('data-uri'), target.getAttribute('data-language'));
  55            } else {
  56              // Used in com_menus
  57              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'));
  58            }
  59  
  60            if (window.parent.Joomla.Modal) {
  61              window.parent.Joomla.Modal.getCurrent().close();
  62            }
  63          });
  64        }
  65      });
  66    })();
  67  
  68  })();


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