first commit
This commit is contained in:
46
media/com_cpanel/joomla.asset.json
Normal file
46
media/com_cpanel/joomla.asset.json
Normal file
@ -0,0 +1,46 @@
|
||||
{
|
||||
"$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": "com_cpanel/admin-add_module.min.js",
|
||||
"dependencies": [
|
||||
"core"
|
||||
],
|
||||
"attributes": {
|
||||
"type": "module"
|
||||
},
|
||||
"version": "eed527"
|
||||
},
|
||||
{
|
||||
"name": "com_cpanel.admin-cpanel",
|
||||
"type": "script",
|
||||
"uri": "com_cpanel/admin-cpanel-default.min.js",
|
||||
"dependencies": [
|
||||
"core"
|
||||
],
|
||||
"attributes": {
|
||||
"type": "module"
|
||||
},
|
||||
"version": "433d95"
|
||||
},
|
||||
{
|
||||
"name": "com_cpanel.admin-system-loader",
|
||||
"type": "script",
|
||||
"uri": "com_cpanel/admin-system-loader.min.js",
|
||||
"dependencies": [
|
||||
"core"
|
||||
],
|
||||
"attributes": {
|
||||
"type": "module",
|
||||
"defer": true
|
||||
},
|
||||
"version": "43ff08"
|
||||
}
|
||||
]
|
||||
}
|
||||
70
media/com_cpanel/js/admin-add_module.js
Normal file
70
media/com_cpanel/js/admin-add_module.js
Normal 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);
|
||||
1
media/com_cpanel/js/admin-add_module.min.js
vendored
Normal file
1
media/com_cpanel/js/admin-add_module.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
(e=>{e.addEventListener("DOMContentLoaded",(()=>{window.jSelectModuleType=()=>{const t=e.querySelectorAll("#moduleDashboardAddModal .modal-footer .btn.hidden");t.length&&setTimeout((()=>{t.forEach((e=>{e.classList.remove("hidden")}))}),1e3)};const t=e.querySelectorAll("#moduleDashboardAddModal .modal-footer .btn"),d=[];let o=!1;t.length&&t.forEach((t=>{t.classList.contains("hidden")&&d.push(t),t.addEventListener("click",(t=>{let d=t.currentTarget;if(d||(d=t.target),d){const t=d.dataset.bsTarget;o="#saveBtn"===t,setTimeout((()=>{o=!1}),1500);const n=e.querySelector("#moduleDashboardAddModal iframe"),a=(n.contentDocument||n.contentWindow.document).querySelector(t);a&&a.click()}}))}));const n=e.querySelector("#moduleDashboardAddModal");n&&(n.addEventListener("hide.bs.modal",(()=>{d.forEach((e=>{e.classList.add("hidden")}))})),n.addEventListener("hidden.bs.modal",(()=>{o&&setTimeout((()=>{window.parent.location.reload()}),1e3)})))}))})(document);
|
||||
BIN
media/com_cpanel/js/admin-add_module.min.js.gz
Normal file
BIN
media/com_cpanel/js/admin-add_module.min.js.gz
Normal file
Binary file not shown.
104
media/com_cpanel/js/admin-cpanel-default.js
Normal file
104
media/com_cpanel/js/admin-cpanel-default.js
Normal file
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @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) {
|
||||
const links = [].slice.call(cpanelModules.querySelectorAll('.unpublish-module'));
|
||||
links.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);
|
||||
1
media/com_cpanel/js/admin-cpanel-default.min.js
vendored
Normal file
1
media/com_cpanel/js/admin-cpanel-default.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
const debounce=(e,t=250,i)=>(...o)=>clearTimeout(i,i=setTimeout(e,t,...o));((e,t,i)=>{i.unpublishModule=e=>{const t=e.getAttribute("data-module-id");i.request({url:`index.php?option=com_modules&task=modules.unpublish&format=json&cid=${t}`,method:"POST",headers:{"Content-Type":"application/json"},onSuccess:()=>{const t=e.closest(".module-wrapper");t.parentNode.removeChild(t),i.renderMessages({message:[i.Text._("COM_CPANEL_UNPUBLISH_MODULE_SUCCESS")]})},onError:()=>{i.renderMessages({error:[i.Text._("COM_CPANEL_UNPUBLISH_MODULE_ERROR")]})}})};const o=()=>{const e=t.getElementById("content");if(e){[].slice.call(e.querySelectorAll(".unpublish-module")).forEach((e=>{e.addEventListener("click",(({target:e})=>i.unpublishModule(e)))}))}t.removeEventListener("DOMContentLoaded",o)};t.addEventListener("DOMContentLoaded",o);({$gridBox:null,gridAutoRows:0,gridRowGap:10,resizeGridItem(e,t,i){const o=e.querySelector(".card");if(o){const s=o.getBoundingClientRect().height+i,r=Math.ceil(s/(t+i));e.style.gridRowEnd=`span ${r}`}},resizeAllGridItems(){[].slice.call(this.$gridBox.children).forEach((e=>{this.resizeGridItem(e,this.gridAutoRows,this.gridRowGap)}))},initialise(){this.$gridBox=t.querySelector("#cpanel-modules .card-columns");const i=e.getComputedStyle(this.$gridBox);this.gridAutoRows=parseInt(i.getPropertyValue("grid-auto-rows"),10)||this.gridAutoRows,this.gridRowGap=parseInt(i.getPropertyValue("grid-row-gap"),10)||this.gridRowGap,this.resizeAllGridItems(),e.addEventListener("load",(()=>this.resizeAllGridItems())),e.addEventListener("joomla:menu-toggle",(()=>{setTimeout((()=>this.resizeAllGridItems()),330)})),e.addEventListener("resize",debounce((()=>this.resizeAllGridItems()),50))}}).initialise()})(window,document,window.Joomla);
|
||||
BIN
media/com_cpanel/js/admin-cpanel-default.min.js.gz
Normal file
BIN
media/com_cpanel/js/admin-cpanel-default.min.js.gz
Normal file
Binary file not shown.
62
media/com_cpanel/js/admin-system-loader.js
Normal file
62
media/com_cpanel/js/admin-system-loader.js
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @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 = [].slice.call(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');
|
||||
element.classList.remove('icon-spinner');
|
||||
element.classList.add('text-danger');
|
||||
element.classList.add('icon-remove');
|
||||
} else if (response.data) {
|
||||
const elem = document.createElement('span');
|
||||
elem.classList.add('float-end');
|
||||
elem.classList.add('badge');
|
||||
elem.classList.add('bg-warning', 'text-dark');
|
||||
elem.innerHTML = Joomla.sanitizeHtml(response.data);
|
||||
element.parentNode.replaceChild(elem, element);
|
||||
} else {
|
||||
element.classList.remove('icon-spin');
|
||||
element.classList.remove('icon-spinner');
|
||||
element.classList.add('icon-check');
|
||||
element.classList.add('text-success');
|
||||
}
|
||||
}).catch(() => {
|
||||
element.classList.remove('icon-spin');
|
||||
element.classList.remove('icon-spinner');
|
||||
element.classList.add('text-danger');
|
||||
element.classList.add('icon-remove');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Give some times to the layout and other scripts to settle their stuff
|
||||
window.addEventListener('load', () => {
|
||||
setTimeout(init, 300);
|
||||
});
|
||||
})(document, Joomla);
|
||||
1
media/com_cpanel/js/admin-system-loader.min.js
vendored
Normal file
1
media/com_cpanel/js/admin-system-loader.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
((e,s)=>{const t=()=>{window.removeEventListener("load",t);const a=[].slice.call(e.querySelectorAll(".system-counter"));a.length&&a.forEach((t=>{const a=t.getAttribute("data-url");a&&s&&s.request&&"function"==typeof s.request&&s.enqueueRequest({url:a,method:"POST",promise:!0}).then((a=>{const n=a.responseText;let c;try{c=JSON.parse(n)}catch(e){throw new Error("Failed to parse JSON")}if(c.error||!c.success)t.classList.remove("icon-spin"),t.classList.remove("icon-spinner"),t.classList.add("text-danger"),t.classList.add("icon-remove");else if(c.data){const a=e.createElement("span");a.classList.add("float-end"),a.classList.add("badge"),a.classList.add("bg-warning","text-dark"),a.innerHTML=s.sanitizeHtml(c.data),t.parentNode.replaceChild(a,t)}else t.classList.remove("icon-spin"),t.classList.remove("icon-spinner"),t.classList.add("icon-check"),t.classList.add("text-success")})).catch((()=>{t.classList.remove("icon-spin"),t.classList.remove("icon-spinner"),t.classList.add("text-danger"),t.classList.add("icon-remove")}))}))};window.addEventListener("load",(()=>{setTimeout(t,300)}))})(document,Joomla);
|
||||
BIN
media/com_cpanel/js/admin-system-loader.min.js.gz
Normal file
BIN
media/com_cpanel/js/admin-system-loader.min.js.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user