- md5
- 5db0c92e8e7d3bf9729a45b12c9679ca
- sha1
- 45fbfe757d0dddf857ed5cf530f54c2c9567dcbb
- sha256
- 407d5402f883573633112553948cbdae749dcaeb1e5d8264c25c2b5e2e7d83c5
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/
/**
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
((window, document, Joomla) => {
let matchesFn = 'matches';
const closest = (element, selector) => {
let parent;
let el = element; // Traverse parents
while (el) {
parent = el.parentElement;
if (parent && parent[matchesFn](selector)) {
return parent;
}
el = parent;
}
return null;
};
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: "".concat(baseUrl, "&cid=").concat(id),
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
onSuccess: () => {
const wrapper = closest(element, '.module-wrapper');
wrapper.parentNode.removeChild(wrapper);
Joomla.renderMessages({
message: [Joomla.JText._('COM_CPANEL_UNPUBLISH_MODULE_SUCCESS')]
});
},
onError: () => {
Joomla.renderMessages({
error: [Joomla.JText._('COM_CPANEL_UNPUBLISH_MODULE_ERROR')]
});
}
});
};
const onBoot = () => {
// Find matchesFn with vendor prefix
['matches', 'msMatchesSelector'].some(fn => {
if (typeof document.body[fn] === 'function') {
matchesFn = fn;
return true;
}
return false;
});
const cpanelModules = document.getElementById('cpanel-modules');
if (cpanelModules) {
const links = [].slice.call(cpanelModules.querySelectorAll('.unpublish-module'));
links.forEach(link => {
link.addEventListener('click', event => Joomla.unpublishModule(event.target));
});
} // Cleanup
document.removeEventListener('DOMContentLoaded', onBoot);
}; // Initialise
document.addEventListener('DOMContentLoaded', onBoot);
})(window, document, window.Joomla);
The same content is in 5 releases, Joomla 4.0.0-alpha8 to 4.0.0-alpha12. See them all, or every version of this file.