Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 0 additions & 107 deletions build/media/com_modules/js/admin-module-edit.js

This file was deleted.

25 changes: 0 additions & 25 deletions build/media/com_modules/js/admin-module-edit_assignment.js

This file was deleted.

43 changes: 0 additions & 43 deletions build/media/com_modules/js/admin-modules-modal.js

This file was deleted.

105 changes: 105 additions & 0 deletions build/media_src/com_modules/js/admin-module-edit.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
Joomla = window.Joomla || {};

((Joomla) => {
'use strict';

Joomla.submitbutton = (task) => {
if (task === 'module.cancel' || document.formvalidator.isValid(document.getElementById('module-form'))) {
Joomla.submitform(task, document.getElementById('module-form'));

const options = Joomla.getOptions('module-edit');

if (window.self !== window.top) {
if (window.parent.viewLevels) {
// @todo remove the chosen!!!
const updPosition = window.jQuery('#jform_position').chosen().val();
const updTitle = document.getElementById('jform_title').value;
const updMenus = document.querySelector('#jform_assignment').value;
const updStatus = document.querySelector('#jform_published').value;
const updAccess = document.querySelector('#jform_access').value;
const tmpMenu = window.parent.document.getElementById(`menus-${options.itemId}`);
const tmpRow = window.parent.document.getElementById(`tr-${options.itemId}`);
const tmpStatus = window.parent.document.getElementById(`status-${options.itemId}`);
window.parent.inMenus = [];
window.parent.numMenus = [].slice.call(document.querySelectorAll('input[name="jform[assigned][]"]')).length;

[].slice.call(document.querySelectorAll('input[name="jform[assigned][]"]')).forEach((element) => {
if (updMenus > 0) {
if (element.checked) {
window.parent.inMenus.push(parseInt(element.value, 10));
}
}
if (updMenus < 0) {
if (!element.checked) {
window.parent.inMenus.push(parseInt(element.value, 10));
}
}
});
if (updMenus === '-') {
tmpMenu.innerHTML = `<span class="badge badge-danger">${Joomla.JText._('JNO')}</span>`;
if (!tmpRow.classList.contains('no') || tmpRow.classList.length === 0) { tmpRow.classList.add('no'); }
}
if (parseInt(updMenus, 10) === 0) {
tmpMenu.innerHTML = `<span class="badge badge-info">${Joomla.JText._('JALL')}</span>`;
if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no'); }
}
if (parseInt(updMenus, 10) > 0) {
if (window.parent.inMenus.indexOf(window.parent.menuId) >= 0) {
if (window.parent.numMenus === window.parent.inMenus.length) {
tmpMenu.innerHTML = `<span class="badge badge-info">${Joomla.JText._('JALL')}</span>`;
if (tmpRow.classList.contains('no') || tmpRow.classList.length === 0) { tmpRow.classList.remove('no'); }
} else {
tmpMenu.innerHTML = `<span class="badge badge-success">${Joomla.JText._('JYES')}</span>`;
if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no'); }
}
}
if (window.parent.inMenus.indexOf(window.parent.menuId) < 0) {
tmpMenu.innerHTML = `<span class="badge badge-danger">${Joomla.JText._('JNO')}</span>`;
if (!tmpRow.classList.contains('no')) { tmpRow.classList.add('no'); }
}
}
if (parseInt(updMenus, 10) < 0) {
if (window.parent.inMenus.indexOf(window.parent.menuId) >= 0) {
if (window.parent.numMenus === window.parent.inMenus.length) {
tmpMenu.innerHTML = `<span class="badge badge-info">${Joomla.JText._('JALL')}</span>`;
if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no'); }
} else {
tmpMenu.innerHTML = `<span class="badge badge-success">${Joomla.JText._('JYES')}</span>`;
if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no'); }
}
}
if (window.parent.inMenus.indexOf(window.parent.menuId) < 0) {
tmpMenu.innerHTML = `<span class="badge badge-danger">${Joomla.JText._('JNO')}</span>`;
if (!tmpRow.classList.contains('no') || tmpRow.classList.length === 0) { tmpRow.classList.add('no'); }
}
}
if (parseInt(updStatus, 10) === 1) {
tmpStatus.innerHTML = `<span class="badge badge-success">${Joomla.JText._('JYES')}</span>`;
if (tmpRow.classList.contains('unpublished')) { tmpRow.classList.remove('unpublished'); }
}
if (parseInt(updStatus, 10) === 0) {
tmpStatus.innerHTML = `<span class="badge badge-danger">${Joomla.JText._('JNO')}</span>`;
if (!tmpRow.classList.contains('unpublished') || tmpRow.classList.length === 0) { tmpRow.classList.add('unpublished'); }
}
if (parseInt(updStatus, 10) === -2) {
tmpStatus.innerHTML = `<span class="badge badge-default">${Joomla.JText._('JTRASHED')}</span>`;
if (!tmpRow.classList.contains('unpublished') || tmpRow.classList.length === 0) { tmpRow.classList.add('unpublished'); }
}
if (document.formvalidator.isValid(document.getElementById('module-form'))) {
window.parent.document.querySelector(`#title-${options.itemId}`).innerText = updTitle;
window.parent.document.querySelector(`#position-${options.itemId}`).innerText = updPosition;
window.parent.document.querySelector(`#access-${options.itemId}`).innerHTML = window.parent.viewLevels[updAccess];
}
}
}

if (task !== 'module.apply') {
window.parent.Joomla.Modal.getCurrent().close();
}
}
};
})(Joomla);
30 changes: 30 additions & 0 deletions build/media_src/com_modules/js/admin-module-edit_assignment.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
(() => {
'use strict';

const onChange = (value) => {
if (value === '-' || parseInt(value, 10) === 0) {
document.getElementById('menuselect-group').style.display = 'none';
} else {
document.getElementById('menuselect-group').style.display = 'block';
}
};

const onBoot = () => {
const element = document.getElementById('jform_assignment');

if (element) {
// Initialise the state
onChange(element.value);

// Check for changes in the state
element.addEventListener('change', (event) => { onChange(event.target.value); });
}

document.removeEventListener('DOMContentLoaded', onBoot);
};
document.addEventListener('DOMContentLoaded', onBoot);
})();
47 changes: 47 additions & 0 deletions build/media_src/com_modules/js/admin-modules-modal.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

document.addEventListener('DOMContentLoaded', () => {
'use strict';

/** Get the elements * */
const modulesLinks = [].slice.call(document.querySelectorAll('.js-module-insert'));
const positionsLinks = [].slice.call(document.querySelectorAll('.js-position-insert'));

/** Assign listener for click event (for single module insertion) * */
modulesLinks.forEach((modulesLink) => {
modulesLink.addEventListener('click', (event) => {
event.preventDefault();
const type = event.target.getAttribute('data-module');
const name = event.target.getAttribute('data-title');
const editor = event.target.getAttribute('data-editor');

// Insert the short tag in the editor
window.parent.Joomla.editors.instances[editor].replaceSelection(`{loadmodule ${type},${name}}`);

// Close the modal
if (window.parent.Joomla.Modal) {
window.parent.Joomla.Modal.getCurrent().close();
}
});
});

/** Assign listener for click event (for position insertion) * */
positionsLinks.forEach((positionsLink) => {
positionsLink.addEventListener('click', (event) => {
event.preventDefault();
const position = event.target.getAttribute('data-position');
const editor = event.target.getAttribute('data-editor');

// Insert the short tag in the editor
window.parent.Joomla.editors.instances[editor].replaceSelection(`{loadposition ${position}}`);

// Close the modal
if (window.parent.Joomla.Modal) {
window.parent.Joomla.Modal.getCurrent().close();
}
});
});
});