[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 /** 2 * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> 3 * @license GNU General Public License version 2 or later; see LICENSE.txt 4 */ 5 ((Joomla, document) => { 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.jSelectMenuItem = (id, title, uri, object, link, lang) => { 14 let thislang = ''; 15 16 if (!Joomla.getOptions('xtd-menus')) { 17 // Something went wrong! 18 window.parent.Joomla.Modal.getCurrent().close(); 19 throw new Error('core.js was not properly initialised'); 20 } // eslint-disable-next-line prefer-destructuring 21 22 23 const editor = Joomla.getOptions('xtd-menus').editor; 24 25 if (lang !== '') { 26 thislang = '&lang='; 27 } 28 29 const tag = `<a href="$uri + thislang + lang}">$title}</a>`; // Insert the link in the editor 30 31 if (window.parent.Joomla.editors.instances[editor].getSelection()) { 32 window.parent.Joomla.editors.instances[editor].replaceSelection(`<a href="$uri + thislang + lang}">$window.parent.Joomla.editors.instances[editor].getSelection()}</a>`); 33 } else { 34 window.parent.Joomla.editors.instances[editor].replaceSelection(tag); 35 } // Close the modal 36 37 38 if (window.parent.Joomla && window.parent.Joomla.Modal) { 39 window.parent.Joomla.Modal.getCurrent().close(); 40 } 41 }; // Get the elements 42 43 44 const elements = [].slice.call(document.querySelectorAll('.select-link')); 45 elements.forEach(element => { 46 // Listen for click event 47 element.addEventListener('click', event => { 48 event.preventDefault(); 49 const functionName = event.target.getAttribute('data-function'); 50 51 if (functionName === 'jSelectMenuItem') { 52 // Used in xtd_contacts 53 window[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), event.target.getAttribute('data-uri'), null, null, event.target.getAttribute('data-language')); 54 } else { 55 // Used in com_menus 56 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); 57 } // Close the modal 58 59 60 if (window.parent.Joomla.Modal) { 61 window.parent.Joomla.Modal.getCurrent().close(); 62 } 63 }); 64 }); 65 })(Joomla, document);
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 |