- md5
- d42d28487fc8eebf158b3f35f1251a42
- sha1
- e1c7e55cd22f80315fd1f17cbd7abaeca5fc938a
- sha256
- 84e0fd4bbd6c051b4a56e704ec8978ae8facd9ed0f7282defd782fe26a20e9e7
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
/**
* 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
*/
(Joomla => {
'use strict';
Joomla.submitbutton = (task, type) => {
if (task === 'item.setType' || task === 'item.setMenuType') {
if (task === 'item.setType') {
const list = [].slice.call(document.querySelectorAll('#item-form input[name="jform[type]"]'));
list.forEach(item => {
item.value = type;
});
document.getElementById('fieldtype').value = 'type';
} else {
const list = [].slice.call(document.querySelectorAll('#item-form input[name="jform[menutype]"]'));
list.forEach(item => {
item.value = type;
});
}
Joomla.submitform('item.setType', document.getElementById('item-form'));
} else if (task === 'item.cancel' || document.formvalidator.isValid(document.getElementById('item-form'))) {
Joomla.submitform(task, document.getElementById('item-form'));
} else {
// special case for modal popups validation response
const list = [].slice.call(document.querySelectorAll('#item-form .modal-value.invalid'));
list.forEach(field => {
const idReversed = field.getAttribute('id').split('').reverse().join('');
const separatorLocation = idReversed.indexOf('_');
const nameId = `${idReversed.substr(separatorLocation).split('').reverse().join('')}name`;
document.getElementById(nameId).classList.add('invalid');
});
}
};
const onChange = event => {
const menuType = event.target.value;
Joomla.request({
url: `index.php?option=com_menus&task=item.getParentItem&menutype=${menuType}`,
headers: {
'Content-Type': 'application/json'
},
onSuccess(response) {
const data = JSON.parse(response);
const list = [].slice.call(document.querySelectorAll('#jform_parent_id option'));
list.forEach(item => {
if (item.value !== '1') {
item.parentNode.removeChild(item);
}
});
data.forEach(value => {
const option = document.createElement('option');
option.innerText = value.title;
option.id = value.id;
document.getElementById('jform_parent_id').appendChild(option);
});
const newEvent = document.createEvent('HTMLEvents');
newEvent.initEvent('change', true, false);
document.getElementById('jform_parent_id').dispatchEvent(newEvent);
},
onError: xhr => {
Joomla.renderMessages(Joomla.ajaxErrorsMessages(xhr));
}
});
};
const onBoot = () => {
if (!Joomla || typeof Joomla.request !== 'function') {
throw new Error('core.js was not properly initialised');
}
const element = document.getElementById('jform_menutype');
if (element) {
element.addEventListener('change', onChange);
} // Cleanup
document.removeEventListener('DOMContentLoaded', onBoot);
};
document.addEventListener('DOMContentLoaded', onBoot);
})(Joomla);
No other release has this exact content. See every version of this file.