diff --git a/build/media_source/com_templates/joomla.asset.json b/build/media_source/com_templates/joomla.asset.json index 3bba1c93d46f2..3e663870697d0 100644 --- a/build/media_source/com_templates/joomla.asset.json +++ b/build/media_source/com_templates/joomla.asset.json @@ -5,6 +5,30 @@ "description": "Joomla CMS", "license": "GPL-2.0-or-later", "assets": [ + { + "name": "com_templates.admin-template-compare.es5", + "type": "script", + "uri": "com_templates/admin-template-compare-es5.min.js", + "dependencies": [ + "core", + "diff" + ], + "attributes": { + "nomodule": true, + "defer": true + } + }, + { + "name": "com_templates.admin-template-compare", + "type": "script", + "uri": "com_templates/admin-template-compare.min.js", + "dependencies": [ + "com_templates.admin-template-compare.es5" + ], + "attributes": { + "type": "module" + } + }, { "name": "com_templates.admin-template-toggle-assignment.es5", "type": "script", diff --git a/build/media_source/com_templates/js/admin-template-compare.es6.js b/build/media_source/com_templates/js/admin-template-compare.es6.js new file mode 100644 index 0000000000000..8a1c3db0a2339 --- /dev/null +++ b/build/media_source/com_templates/js/admin-template-compare.es6.js @@ -0,0 +1,63 @@ +/** + * @copyright (C) 2018 Open Source Matters, Inc. + * @license GNU General Public License version 2 or later; see LICENSE.txt + * + * @deprecated This file is deprecated and will be removed with Joomla 5.0 + */ +(() => { + 'use strict'; + + document.addEventListener('DOMContentLoaded', () => { + const decodeHtmlspecialChars = (text) => { + const map = { + '&': '&', + '&': '&', + '<': '<', + '>': '>', + '"': '"', + ''': "'", + '’': '’', + '‘': '‘', + '–': '–', + '—': '—', + '…': '…', + '”': '”', + }; + + /* eslint-disable */ + return text.replace(/\&[\w\d\#]{2,5}\;/g, (m) => { const n = map[m]; return n; }); + }; + + const compare = (original, changed) => { + const display = changed.nextElementSibling; + let color = ''; + let pre = null; + const diff = Diff.diffLines(original.innerHTML, changed.innerHTML); + const fragment = document.createDocumentFragment(); + + /* eslint-enable */ + + diff.forEach((part) => { + if (part.added) { + color = '#a6f3a6'; + } else if (part.removed) { + color = '#f8cbcb'; + } else { + color = ''; + } + pre = document.createElement('pre'); + pre.style.backgroundColor = color; + pre.className = 'diffview'; + pre.appendChild(document.createTextNode(decodeHtmlspecialChars(part.value))); + fragment.appendChild(pre); + }); + + display.appendChild(fragment); + }; + + const diffs = [].slice.call(document.querySelectorAll('#original')); + for (let i = 0, l = diffs.length; i < l; i += 1) { + compare(diffs[i], diffs[i].nextElementSibling); + } + }); +})(); diff --git a/build/media_source/com_users/js/admin-users-mail.es6.js b/build/media_source/com_users/js/admin-users-mail.es6.js new file mode 100644 index 0000000000000..ac12fcee51984 --- /dev/null +++ b/build/media_source/com_users/js/admin-users-mail.es6.js @@ -0,0 +1,36 @@ +/** + * @copyright (C) 2018 Open Source Matters, Inc. + * @license GNU General Public License version 2 or later; see LICENSE.txt + * + * @deprecated This file is deprecated and will be removed with Joomla 5.0 + */ + +(() => { + 'use strict'; + + document.addEventListener('DOMContentLoaded', () => { + Joomla.submitbutton = (pressbutton) => { + const form = document.adminForm; + const html = document.createElement('joomla-alert'); + + if (pressbutton === 'mail.cancel') { + Joomla.submitform(pressbutton); + return; + } + + // do field validation + if (form.jform_subject.value === '') { + html.innerText = Joomla.Text._('COM_USERS_MAIL_PLEASE_FILL_IN_THE_SUBJECT'); + form.insertAdjacentElement('afterbegin', html); + } else if (form.jform_group.value < 0) { + html.innerText = Joomla.Text._('COM_USERS_MAIL_PLEASE_SELECT_A_GROUP'); + form.insertAdjacentElement('afterbegin', html); + } else if (form.jform_message.value === '') { + html.innerText = Joomla.Text._('COM_USERS_MAIL_PLEASE_FILL_IN_THE_MESSAGE'); + form.insertAdjacentElement('afterbegin', html); + } else { + Joomla.submitform(pressbutton); + } + }; + }); +})();