[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
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 jSelectArticle when an article is clicked 9 * jSelectArticle creates the link tag, sends it to the editor, 10 * and closes the select frame. 11 * */ 12 13 window.jSelectArticle = (id, title, catid, object, link, lang) => { 14 let hreflang = ''; 15 16 if (!Joomla.getOptions('xtd-articles')) { 17 // Something went wrong! 18 // @TODO Close the modal 19 return false; 20 } 21 22 const { 23 editor 24 } = Joomla.getOptions('xtd-articles'); 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 33 if (window.parent.Joomla.Modal) { 34 window.parent.Joomla.Modal.getCurrent().close(); 35 } 36 37 return true; 38 }; 39 40 document.addEventListener('DOMContentLoaded', () => { 41 // Get the elements 42 const elements = document.querySelectorAll('.select-link'); 43 44 for (let i = 0, l = elements.length; l > i; i += 1) { 45 // Listen for click event 46 elements[i].addEventListener('click', event => { 47 event.preventDefault(); 48 const { 49 target 50 } = event; 51 const functionName = target.getAttribute('data-function'); 52 53 if (functionName === 'jSelectArticle') { 54 // Used in xtd_contacts 55 window[functionName](target.getAttribute('data-id'), target.getAttribute('data-title'), target.getAttribute('data-cat-id'), null, target.getAttribute('data-uri'), target.getAttribute('data-language')); 56 } else { 57 // Used in com_menus 58 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')); 59 } 60 61 if (window.parent.Joomla.Modal) { 62 window.parent.Joomla.Modal.getCurrent().close(); 63 } 64 }); 65 } 66 }); 67 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |