first commit
This commit is contained in:
45
media/com_contenthistory/joomla.asset.json
Normal file
45
media/com_contenthistory/joomla.asset.json
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
|
||||
"name": "com_contenthistory",
|
||||
"version": "4.0.0",
|
||||
"description": "Joomla CMS",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"assets": [
|
||||
{
|
||||
"name": "com_contenthistory.admin-history-versions",
|
||||
"type": "script",
|
||||
"uri": "",
|
||||
"deprecated": true,
|
||||
"dependencies": [
|
||||
"core"
|
||||
],
|
||||
"attributes": {
|
||||
"type": "module"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "com_contenthistory.admin-compare-compare",
|
||||
"type": "script",
|
||||
"uri": "com_contenthistory/admin-compare-compare.min.js",
|
||||
"dependencies": [
|
||||
"core"
|
||||
],
|
||||
"attributes": {
|
||||
"type": "module"
|
||||
},
|
||||
"version": "75ba63"
|
||||
},
|
||||
{
|
||||
"name": "com_contenthistory.admin-history-modal",
|
||||
"type": "script",
|
||||
"uri": "com_contenthistory/admin-history-modal.min.js",
|
||||
"dependencies": [
|
||||
"core"
|
||||
],
|
||||
"attributes": {
|
||||
"type": "module"
|
||||
},
|
||||
"version": "fbc6a9"
|
||||
}
|
||||
]
|
||||
}
|
||||
45
media/com_contenthistory/js/admin-compare-compare.js
Normal file
45
media/com_contenthistory/js/admin-compare-compare.js
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
(() => {
|
||||
|
||||
// This method is used to decode HTML entities
|
||||
const decodeHtml = html => {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.innerHTML = Joomla.sanitizeHtml(html);
|
||||
return textarea.value;
|
||||
};
|
||||
const compare = (original, changed) => {
|
||||
const display = changed.nextElementSibling;
|
||||
const diff = window.Diff.diffWords(original.innerHTML, changed.innerHTML);
|
||||
const fragment = document.createDocumentFragment();
|
||||
diff.forEach(part => {
|
||||
let color = '';
|
||||
if (part.added) {
|
||||
color = '#a6f3a6';
|
||||
}
|
||||
if (part.removed) {
|
||||
color = '#f8cbcb';
|
||||
}
|
||||
|
||||
// @todo use the tag MARK here not SPAN
|
||||
const span = document.createElement('span');
|
||||
span.style.backgroundColor = color;
|
||||
span.style.borderRadius = '.2rem';
|
||||
span.appendChild(document.createTextNode(decodeHtml(part.value)));
|
||||
fragment.appendChild(span);
|
||||
});
|
||||
display.appendChild(fragment);
|
||||
};
|
||||
const onBoot = () => {
|
||||
const diffs = [].slice.call(document.querySelectorAll('.original'));
|
||||
diffs.forEach(fragment => {
|
||||
compare(fragment, fragment.nextElementSibling);
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
document.removeEventListener('DOMContentLoaded', onBoot);
|
||||
};
|
||||
document.addEventListener('DOMContentLoaded', onBoot);
|
||||
})();
|
||||
1
media/com_contenthistory/js/admin-compare-compare.min.js
vendored
Normal file
1
media/com_contenthistory/js/admin-compare-compare.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
(()=>{const e=(e,n)=>{const t=n.nextElementSibling,o=window.Diff.diffWords(e.innerHTML,n.innerHTML),d=document.createDocumentFragment();o.forEach((e=>{let n="";e.added&&(n="#a6f3a6"),e.removed&&(n="#f8cbcb");const t=document.createElement("span");t.style.backgroundColor=n,t.style.borderRadius=".2rem",t.appendChild(document.createTextNode((e=>{const n=document.createElement("textarea");return n.innerHTML=Joomla.sanitizeHtml(e),n.value})(e.value))),d.appendChild(t)})),t.appendChild(d)},n=()=>{[].slice.call(document.querySelectorAll(".original")).forEach((n=>{e(n,n.nextElementSibling)})),document.removeEventListener("DOMContentLoaded",n)};document.addEventListener("DOMContentLoaded",n)})();
|
||||
BIN
media/com_contenthistory/js/admin-compare-compare.min.js.gz
Normal file
BIN
media/com_contenthistory/js/admin-compare-compare.min.js.gz
Normal file
Binary file not shown.
72
media/com_contenthistory/js/admin-history-modal.js
Normal file
72
media/com_contenthistory/js/admin-history-modal.js
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
((document, Joomla) => {
|
||||
|
||||
if (!Joomla || typeof Joomla.Text._ !== 'function') {
|
||||
throw new Error('core.js was not properly initialised');
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.getElementById('toolbar-load').addEventListener('click', () => {
|
||||
const toolbarLoad = document.getElementById('toolbar-load');
|
||||
if (!toolbarLoad.disabled) {
|
||||
const ids = document.querySelectorAll('input[id*="cb"]:checked');
|
||||
if (ids.length === 1) {
|
||||
// Add version item id to URL
|
||||
const url = `${toolbarLoad.childNodes[1].getAttribute('data-url')}&version_id=${ids[0].value}`;
|
||||
if (window.parent && url) {
|
||||
window.parent.location = url;
|
||||
}
|
||||
} else {
|
||||
Joomla.renderMessages({
|
||||
error: [Joomla.Text._('COM_CONTENTHISTORY_BUTTON_SELECT_ONE_VERSION')]
|
||||
});
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
document.getElementById('toolbar-preview').addEventListener('click', () => {
|
||||
const toolbarPreview = document.getElementById('toolbar-preview');
|
||||
if (!toolbarPreview.disabled) {
|
||||
const windowSizeArray = ['width=800, height=600, resizable=yes, scrollbars=yes'];
|
||||
const ids = document.querySelectorAll('input[id*="cb"]:checked');
|
||||
if (ids.length === 1) {
|
||||
// Add version item id to URL
|
||||
const url = `${toolbarPreview.childNodes[1].getAttribute('data-url')}&version_id=${ids[0].value}`;
|
||||
if (window.parent && url) {
|
||||
window.open(url, '', windowSizeArray.toString());
|
||||
}
|
||||
} else {
|
||||
Joomla.renderMessages({
|
||||
error: [Joomla.Text._('COM_CONTENTHISTORY_BUTTON_SELECT_ONE_VERSION')]
|
||||
});
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
document.getElementById('toolbar-compare').addEventListener('click', () => {
|
||||
const toolbarCompare = document.getElementById('toolbar-compare');
|
||||
if (!toolbarCompare.disabled) {
|
||||
const windowSizeArray = ['width=1000, height=600, resizable=yes, scrollbars=yes'];
|
||||
const ids = document.querySelectorAll('input[id*="cb"]:checked');
|
||||
if (ids.length === 0) {
|
||||
Joomla.renderMessages({
|
||||
error: [Joomla.Text._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')]
|
||||
});
|
||||
} else if (ids.length === 2) {
|
||||
// Add version item ids to URL
|
||||
const url = `${toolbarCompare.childNodes[1].getAttribute('data-url')}&id1=${ids[0].value}&id2=${ids[1].value}`;
|
||||
if (window.parent && url) {
|
||||
window.open(url, '', windowSizeArray.toString());
|
||||
}
|
||||
} else {
|
||||
Joomla.renderMessages({
|
||||
error: [Joomla.Text._('COM_CONTENTHISTORY_BUTTON_SELECT_TWO_VERSIONS')]
|
||||
});
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
})(document, Joomla);
|
||||
1
media/com_contenthistory/js/admin-history-modal.min.js
vendored
Normal file
1
media/com_contenthistory/js/admin-history-modal.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
((e,t)=>{if(!t||"function"!=typeof t.Text._)throw new Error("core.js was not properly initialised");e.addEventListener("DOMContentLoaded",(()=>{e.getElementById("toolbar-load").addEventListener("click",(()=>{const r=e.getElementById("toolbar-load");if(!r.disabled){const o=e.querySelectorAll('input[id*="cb"]:checked');if(1===o.length){const e=`${r.childNodes[1].getAttribute("data-url")}&version_id=${o[0].value}`;window.parent&&e&&(window.parent.location=e)}else t.renderMessages({error:[t.Text._("COM_CONTENTHISTORY_BUTTON_SELECT_ONE_VERSION")]})}return!1})),e.getElementById("toolbar-preview").addEventListener("click",(()=>{const r=e.getElementById("toolbar-preview");if(!r.disabled){const o=["width=800, height=600, resizable=yes, scrollbars=yes"],n=e.querySelectorAll('input[id*="cb"]:checked');if(1===n.length){const e=`${r.childNodes[1].getAttribute("data-url")}&version_id=${n[0].value}`;window.parent&&e&&window.open(e,"",o.toString())}else t.renderMessages({error:[t.Text._("COM_CONTENTHISTORY_BUTTON_SELECT_ONE_VERSION")]})}return!1})),e.getElementById("toolbar-compare").addEventListener("click",(()=>{const r=e.getElementById("toolbar-compare");if(!r.disabled){const o=["width=1000, height=600, resizable=yes, scrollbars=yes"],n=e.querySelectorAll('input[id*="cb"]:checked');if(0===n.length)t.renderMessages({error:[t.Text._("JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST")]});else if(2===n.length){const e=`${r.childNodes[1].getAttribute("data-url")}&id1=${n[0].value}&id2=${n[1].value}`;window.parent&&e&&window.open(e,"",o.toString())}else t.renderMessages({error:[t.Text._("COM_CONTENTHISTORY_BUTTON_SELECT_TWO_VERSIONS")]})}return!1}))}))})(document,Joomla);
|
||||
BIN
media/com_contenthistory/js/admin-history-modal.min.js.gz
Normal file
BIN
media/com_contenthistory/js/admin-history-modal.min.js.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user