primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,45 @@
{
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
"name": "com_cpanel",
"version": "4.0.0",
"description": "Joomla CMS",
"license": "GPL-2.0-or-later",
"assets": [
{
"name": "com_cpanel.admin-addmodule",
"type": "script",
"uri": "",
"dependencies": [
"core"
],
"attributes": {
"type": "module"
},
"deprecated": true
},
{
"name": "com_cpanel.admin-cpanel",
"type": "script",
"uri": "com_cpanel/admin-cpanel-default.min.js",
"dependencies": [
"core"
],
"attributes": {
"type": "module"
},
"version": "5ca2c9"
},
{
"name": "com_cpanel.admin-system-loader",
"type": "script",
"uri": "com_cpanel/admin-system-loader.min.js",
"dependencies": [
"core"
],
"attributes": {
"type": "module"
},
"version": "70012e"
}
]
}

View File

@ -0,0 +1,70 @@
/**
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
(document => {
document.addEventListener('DOMContentLoaded', () => {
window.jSelectModuleType = () => {
const elements = document.querySelectorAll('#moduleDashboardAddModal .modal-footer .btn.hidden');
if (elements.length) {
setTimeout(() => {
elements.forEach(button => {
button.classList.remove('hidden');
});
}, 1000);
}
};
const buttons = document.querySelectorAll('#moduleDashboardAddModal .modal-footer .btn');
const hideButtons = [];
let isSaving = false;
if (buttons.length) {
buttons.forEach(button => {
if (button.classList.contains('hidden')) {
hideButtons.push(button);
}
button.addEventListener('click', event => {
let elem = event.currentTarget;
// There is some bug with events in iframe where currentTarget is "null"
// => prevent this here by bubble up
if (!elem) {
elem = event.target;
}
if (elem) {
const clickTarget = elem.dataset.bsTarget;
// We remember to be in the saving process
isSaving = clickTarget === '#saveBtn';
// Reset saving process, if e.g. the validation of the form fails
setTimeout(() => {
isSaving = false;
}, 1500);
const iframe = document.querySelector('#moduleDashboardAddModal iframe');
const content = iframe.contentDocument || iframe.contentWindow.document;
const targetBtn = content.querySelector(clickTarget);
if (targetBtn) {
targetBtn.click();
}
}
});
});
}
const elementH = document.querySelector('#moduleDashboardAddModal');
if (elementH) {
elementH.addEventListener('hide.bs.modal', () => {
hideButtons.forEach(button => {
button.classList.add('hidden');
});
});
elementH.addEventListener('hidden.bs.modal', () => {
if (isSaving) {
setTimeout(() => {
window.parent.location.reload();
}, 1000);
}
});
}
});
})(document);

View File

@ -0,0 +1,4 @@
/**
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/(t=>{t.addEventListener("DOMContentLoaded",()=>{window.jSelectModuleType=()=>{const e=t.querySelectorAll("#moduleDashboardAddModal .modal-footer .btn.hidden");e.length&&setTimeout(()=>{e.forEach(o=>{o.classList.remove("hidden")})},1e3)};const s=t.querySelectorAll("#moduleDashboardAddModal .modal-footer .btn"),l=[];let n=!1;s.length&&s.forEach(e=>{e.classList.contains("hidden")&&l.push(e),e.addEventListener("click",o=>{let d=o.currentTarget;if(d||(d=o.target),d){const i=d.dataset.bsTarget;n=i==="#saveBtn",setTimeout(()=>{n=!1},1500);const r=t.querySelector("#moduleDashboardAddModal iframe"),c=(r.contentDocument||r.contentWindow.document).querySelector(i);c&&c.click()}})});const a=t.querySelector("#moduleDashboardAddModal");a&&(a.addEventListener("hide.bs.modal",()=>{l.forEach(e=>{e.classList.add("hidden")})}),a.addEventListener("hidden.bs.modal",()=>{n&&setTimeout(()=>{window.parent.location.reload()},1e3)}))})})(document);

Binary file not shown.

View File

@ -0,0 +1,101 @@
/**
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* Debounce
* https://gist.github.com/nmsdvid/8807205
*
* @param { function } callback The callback function to be executed
* @param { int } time The time to wait before firing the callback
* @param { int } interval The interval
*/
// eslint-disable-next-line no-param-reassign, no-return-assign, default-param-last
const debounce = (callback, time = 250, interval) => (...args) => clearTimeout(interval, interval = setTimeout(callback, time, ...args));
((window, document, Joomla) => {
Joomla.unpublishModule = element => {
// Get variables
const baseUrl = 'index.php?option=com_modules&task=modules.unpublish&format=json';
const id = element.getAttribute('data-module-id');
Joomla.request({
url: `${baseUrl}&cid=${id}`,
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
onSuccess: () => {
const wrapper = element.closest('.module-wrapper');
wrapper.parentNode.removeChild(wrapper);
Joomla.renderMessages({
message: [Joomla.Text._('COM_CPANEL_UNPUBLISH_MODULE_SUCCESS')]
});
},
onError: () => {
Joomla.renderMessages({
error: [Joomla.Text._('COM_CPANEL_UNPUBLISH_MODULE_ERROR')]
});
}
});
};
const onBoot = () => {
const cpanelModules = document.getElementById('content');
if (cpanelModules) {
cpanelModules.querySelectorAll('.unpublish-module').forEach(link => {
link.addEventListener('click', ({
target
}) => Joomla.unpublishModule(target));
});
}
// Cleanup
document.removeEventListener('DOMContentLoaded', onBoot);
};
// Initialise
document.addEventListener('DOMContentLoaded', onBoot);
// Masonry layout for cpanel cards
const MasonryLayout = {
$gridBox: null,
gridAutoRows: 0,
gridRowGap: 10,
// Calculate "grid-row-end" property
resizeGridItem($cell, rowHeight, rowGap) {
const $content = $cell.querySelector('.card');
if ($content) {
const contentHeight = $content.getBoundingClientRect().height + rowGap;
const rowSpan = Math.ceil(contentHeight / (rowHeight + rowGap));
$cell.style.gridRowEnd = `span ${rowSpan}`;
}
},
// Check a size of every cell in the grid
resizeAllGridItems() {
const $gridCells = [].slice.call(this.$gridBox.children);
$gridCells.forEach($cell => this.resizeGridItem($cell, this.gridAutoRows, this.gridRowGap));
},
initialise() {
this.$gridBox = document.querySelector('#cpanel-modules .card-columns');
const gridStyle = window.getComputedStyle(this.$gridBox);
this.gridAutoRows = parseInt(gridStyle.getPropertyValue('grid-auto-rows'), 10) || this.gridAutoRows;
this.gridRowGap = parseInt(gridStyle.getPropertyValue('grid-row-gap'), 10) || this.gridRowGap;
this.resizeAllGridItems();
// Recheck the layout after all content (fonts and images) is loaded.
window.addEventListener('load', () => this.resizeAllGridItems());
// Recheck the layout when the menu is toggled
window.addEventListener('joomla:menu-toggle', () => {
// 300ms is animation time, need to wait for the animation to end
setTimeout(() => this.resizeAllGridItems(), 330);
});
// Watch on window resize
window.addEventListener('resize', debounce(() => this.resizeAllGridItems(), 50));
}
};
// Initialise Masonry layout at the very beginning, to avoid jumping.
// We can do this because the script is deferred.
MasonryLayout.initialise();
})(window, document, window.Joomla);

View File

@ -0,0 +1,4 @@
/**
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/const debounce=(i,r=250,t)=>(...d)=>clearTimeout(t,t=setTimeout(i,r,...d));((i,r,t)=>{t.unpublishModule=e=>{const s="index.php?option=com_modules&task=modules.unpublish&format=json",o=e.getAttribute("data-module-id");t.request({url:`${s}&cid=${o}`,method:"POST",headers:{"Content-Type":"application/json"},onSuccess:()=>{const n=e.closest(".module-wrapper");n.parentNode.removeChild(n),t.renderMessages({message:[t.Text._("COM_CPANEL_UNPUBLISH_MODULE_SUCCESS")]})},onError:()=>{t.renderMessages({error:[t.Text._("COM_CPANEL_UNPUBLISH_MODULE_ERROR")]})}})};const d=()=>{const e=r.getElementById("content");e&&e.querySelectorAll(".unpublish-module").forEach(s=>{s.addEventListener("click",({target:o})=>t.unpublishModule(o))}),r.removeEventListener("DOMContentLoaded",d)};r.addEventListener("DOMContentLoaded",d),{$gridBox:null,gridAutoRows:0,gridRowGap:10,resizeGridItem(e,s,o){const n=e.querySelector(".card");if(n){const l=n.getBoundingClientRect().height+o,a=Math.ceil(l/(s+o));e.style.gridRowEnd=`span ${a}`}},resizeAllGridItems(){[].slice.call(this.$gridBox.children).forEach(s=>this.resizeGridItem(s,this.gridAutoRows,this.gridRowGap))},initialise(){this.$gridBox=r.querySelector("#cpanel-modules .card-columns");const e=i.getComputedStyle(this.$gridBox);this.gridAutoRows=parseInt(e.getPropertyValue("grid-auto-rows"),10)||this.gridAutoRows,this.gridRowGap=parseInt(e.getPropertyValue("grid-row-gap"),10)||this.gridRowGap,this.resizeAllGridItems(),i.addEventListener("load",()=>this.resizeAllGridItems()),i.addEventListener("joomla:menu-toggle",()=>{setTimeout(()=>this.resizeAllGridItems(),330)}),i.addEventListener("resize",debounce(()=>this.resizeAllGridItems(),50))}}.initialise()})(window,document,window.Joomla);

Binary file not shown.

View File

@ -0,0 +1,54 @@
/**
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
((document, Joomla) => {
const init = () => {
// Cleanup
window.removeEventListener('load', init);
// Get the elements
const elements = document.querySelectorAll('.system-counter');
if (elements.length) {
elements.forEach(element => {
const badgeurl = element.getAttribute('data-url');
if (badgeurl && Joomla && Joomla.request && typeof Joomla.request === 'function') {
Joomla.enqueueRequest({
url: badgeurl,
method: 'POST',
promise: true
}).then(xhr => {
const resp = xhr.responseText;
let response;
try {
response = JSON.parse(resp);
} catch (error) {
throw new Error('Failed to parse JSON');
}
if (response.error || !response.success) {
element.classList.remove('icon-spin', 'icon-spinner');
element.classList.add('text-danger', 'icon-remove');
} else if (response.data) {
const elem = document.createElement('span');
elem.classList.add('float-end', 'badge', 'bg-warning', 'text-dark');
elem.innerHTML = Joomla.sanitizeHtml(response.data);
element.parentNode.replaceChild(elem, element);
} else {
element.classList.remove('icon-spin', 'icon-spinner');
element.classList.add('icon-check', 'text-success');
}
}).catch(() => {
element.classList.remove('icon-spin', 'icon-spinner');
element.classList.add('text-danger', 'icon-remove');
});
}
});
}
};
// Give some times to the layout and other scripts to settle their stuff
window.addEventListener('load', () => {
setTimeout(init, 300);
});
})(document, Joomla);

View File

@ -0,0 +1,4 @@
/**
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/((n,s)=>{const i=()=>{window.removeEventListener("load",i);const c=n.querySelectorAll(".system-counter");c.length&&c.forEach(e=>{const a=e.getAttribute("data-url");a&&s&&s.request&&typeof s.request=="function"&&s.enqueueRequest({url:a,method:"POST",promise:!0}).then(o=>{const d=o.responseText;let t;try{t=JSON.parse(d)}catch{throw new Error("Failed to parse JSON")}if(t.error||!t.success)e.classList.remove("icon-spin","icon-spinner"),e.classList.add("text-danger","icon-remove");else if(t.data){const r=n.createElement("span");r.classList.add("float-end","badge","bg-warning","text-dark"),r.innerHTML=s.sanitizeHtml(t.data),e.parentNode.replaceChild(r,e)}else e.classList.remove("icon-spin","icon-spinner"),e.classList.add("icon-check","text-success")}).catch(()=>{e.classList.remove("icon-spin","icon-spinner"),e.classList.add("text-danger","icon-remove")})})};window.addEventListener("load",()=>{setTimeout(i,300)})})(document,Joomla);

Binary file not shown.