diff --git a/build/media/com_modules/js/admin-module-edit.js b/build/media/com_modules/js/admin-module-edit.js
deleted file mode 100644
index baeac8fab7a2b..0000000000000
--- a/build/media/com_modules/js/admin-module-edit.js
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * @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 || {};
-
-(function(Joomla) {
- "use strict";
-
- Joomla.submitbutton = function(task) {
- if (task == 'module.cancel' || document.formvalidator.isValid(document.getElementById('module-form')))
- {
- Joomla.submitform(task, document.getElementById('module-form'));
-
- var options = Joomla.getOptions('module-edit');
-
- if (self != top)
- {
- if (parent.viewLevels)
- {
- var updPosition = jQuery('#jform_position').chosen().val(),
- updTitle = document.getElementById('jform_title').value,
- updMenus = jQuery('#jform_assignment').chosen().val(),
- updStatus = jQuery('#jform_published').chosen().val(),
- updAccess = jQuery('#jform_access').chosen().val(),
- tmpMenu = parent.document.getElementById('menus-' + options.itemId),
- tmpRow = parent.document.getElementById('tr-' + options.itemId),
- tmpStatus = parent.document.getElementById('status-' + options.itemId);
- window.parent.inMenus = [];
- window.parent.numMenus = document.querySelectorAll('input[name="jform[assigned][]"]').length;
-
- jQuery('input[name="jform[assigned][]"]').each(function(){
- if (updMenus > 0 ) {
- if (jQuery(this).is(':checked')) {
- window.parent.inMenus.push(parseInt(jQuery(this).val()));
- }
- }
- if (updMenus < 0 ) {
- if (!jQuery(this).is(':checked')) {
- window.parent.inMenus.push(parseInt(jQuery(this).val()));
- }
- }
- });
- if (updMenus == 0) {
- tmpMenu.innerHTML = '' + Joomla.JText._('JALL') + '';
- if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no') }
- }
- if (updMenus == '-') {
- tmpMenu.innerHTML = '' + Joomla.JText._('JNO') + '';
- if (!tmpRow.classList.contains('no') || tmpRow.classList.length === 0) { tmpRow.classList.add('no') }
- }
- if (updMenus > 0) {
- if (window.parent.inMenus.indexOf(parent.menuId) >= 0) {
- if (window.parent.numMenus == window.parent.inMenus.length) {
- tmpMenu.innerHTML = '' + Joomla.JText._('JALL') + '';
- if (tmpRow.classList.contains('no') || tmpRow.classList.length === 0) { tmpRow.classList.remove('no') }
- } else {
- tmpMenu.innerHTML = '' + Joomla.JText._('JYES') + '';
- if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no') }
- }
- }
- if (window.parent.inMenus.indexOf(parent.menuId) < 0) {
- tmpMenu.innerHTML = '' + Joomla.JText._('JNO') + '';
- if (!tmpRow.classList.contains('no')) { tmpRow.classList.add('no') }
- }
- }
- if (updMenus < 0) {
- if (window.parent.inMenus.indexOf(parent.menuId) >= 0) {
- if (window.parent.numMenus == window.parent.inMenus.length) {
- tmpMenu.innerHTML = '' + Joomla.JText._('JALL') + '';
- if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no') }
- } else {
- tmpMenu.innerHTML = '' + Joomla.JText._('JYES') + '';
- if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no') }
- }
- }
- if (window.parent.inMenus.indexOf(parent.menuId) < 0) {
- tmpMenu.innerHTML = '' + Joomla.JText._('JNO') + '';
- if (!tmpRow.classList.contains('no') || tmpRow.classList.length === 0) { tmpRow.classList.add('no') }
- }
- }
- if (updStatus == 1) {
- tmpStatus.innerHTML = '' + Joomla.JText._('JYES') + '';
- if (tmpRow.classList.contains('unpublished')) { tmpRow.classList.remove('unpublished') }
- }
- if (updStatus == 0) {
- tmpStatus.innerHTML = '' + Joomla.JText._('JNO') + '';
- if (!tmpRow.classList.contains('unpublished') || tmpRow.classList.length === 0) { tmpRow.classList.add('unpublished') }
- }
- if (updStatus == -2) {
- tmpStatus.innerHTML = '' + Joomla.JText._('JTRASHED') + '';
- if (!tmpRow.classList.contains('unpublished') || tmpRow.classList.length === 0) { tmpRow.classList.add('unpublished') }
- }
- if (document.formvalidator.isValid(document.getElementById('module-form'))) {
- jQuery('#title-' + options.itemId, parent.document).text(updTitle);
- jQuery('#position-' + options.itemId, parent.document).text(updPosition);
- jQuery('#access-' + options.itemId, parent.document).innerHTML = parent.viewLevels[updAccess];
- }
- }
- }
-
- if (task !== 'module.apply') {
- window.parent.Joomla.Modal.getCurrent().close();
- }
- }
- };
-})(Joomla);
diff --git a/build/media/com_modules/js/admin-module-edit_assignment.js b/build/media/com_modules/js/admin-module-edit_assignment.js
deleted file mode 100644
index 8551f471e2592..0000000000000
--- a/build/media/com_modules/js/admin-module-edit_assignment.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * @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 || {};
-
-(function(Joomla) {
- "use strict";
-
- Joomla.menuHide = function(value) {
- if (value == 0 || value == '-') {
- document.getElementById('menuselect-group').style.display = 'none';
- } else {
- document.getElementById('menuselect-group').style.display = 'block';
- }
- };
-
- document.addEventListener('DOMContentLoaded', function() {
- Joomla.menuHide(document.getElementById('jform_assignment').value);
-
- document.getElementById('jform_assignment').addEventListener('change', function(event) {
- Joomla.menuHide(event.target.value);
- });
- });
-})(Joomla);
diff --git a/build/media/com_modules/js/admin-modules-modal.js b/build/media/com_modules/js/admin-modules-modal.js
deleted file mode 100644
index 0a6e12e2b75ca..0000000000000
--- a/build/media/com_modules/js/admin-modules-modal.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * @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', function() {
- "use strict";
-
- /** Get the elements **/
- var modulesLinks = document.querySelectorAll('.js-module-insert'), i,
- positionsLinks = document.querySelectorAll('.js-position-insert');
-
- /** Assign listener for click event (for single module insertion) **/
- for (i= 0; modulesLinks.length > i; i++) {
- modulesLinks[i].addEventListener('click', function(event) {
- event.preventDefault();
- var type = event.target.getAttribute('data-module'),
- name = event.target.getAttribute('data-title'),
- editor = event.target.getAttribute('data-editor');
-
- window.parent.Joomla.editors.instances[editor].replaceSelection("{loadmodule " + type + "," + name + "}");
-
- if (window.parent.Joomla.Modal) {
- window.parent.Joomla.Modal.getCurrent().close();
- }
- });
- }
-
- /** Assign listener for click event (for position insertion) **/
- for (i= 0; positionsLinks.length > i; i++) {
- positionsLinks[i].addEventListener('click', function(event) {
- event.preventDefault();
- var position = event.target.getAttribute('data-position'),
- editor = event.target.getAttribute('data-editor');
-
- window.parent.Joomla.editors.instances[editor].replaceSelection("{loadposition " + position + "}");
-
- if (window.parent.Joomla.Modal) {
- window.parent.Joomla.Modal.getCurrent().close();
- }
- });
- }
-});
diff --git a/build/media_src/com_modules/js/admin-module-edit.es6.js b/build/media_src/com_modules/js/admin-module-edit.es6.js
new file mode 100644
index 0000000000000..fddf7783c2f08
--- /dev/null
+++ b/build/media_src/com_modules/js/admin-module-edit.es6.js
@@ -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 = `${Joomla.JText._('JNO')}`;
+ if (!tmpRow.classList.contains('no') || tmpRow.classList.length === 0) { tmpRow.classList.add('no'); }
+ }
+ if (parseInt(updMenus, 10) === 0) {
+ tmpMenu.innerHTML = `${Joomla.JText._('JALL')}`;
+ 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 = `${Joomla.JText._('JALL')}`;
+ if (tmpRow.classList.contains('no') || tmpRow.classList.length === 0) { tmpRow.classList.remove('no'); }
+ } else {
+ tmpMenu.innerHTML = `${Joomla.JText._('JYES')}`;
+ if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no'); }
+ }
+ }
+ if (window.parent.inMenus.indexOf(window.parent.menuId) < 0) {
+ tmpMenu.innerHTML = `${Joomla.JText._('JNO')}`;
+ 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 = `${Joomla.JText._('JALL')}`;
+ if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no'); }
+ } else {
+ tmpMenu.innerHTML = `${Joomla.JText._('JYES')}`;
+ if (tmpRow.classList.contains('no')) { tmpRow.classList.remove('no'); }
+ }
+ }
+ if (window.parent.inMenus.indexOf(window.parent.menuId) < 0) {
+ tmpMenu.innerHTML = `${Joomla.JText._('JNO')}`;
+ if (!tmpRow.classList.contains('no') || tmpRow.classList.length === 0) { tmpRow.classList.add('no'); }
+ }
+ }
+ if (parseInt(updStatus, 10) === 1) {
+ tmpStatus.innerHTML = `${Joomla.JText._('JYES')}`;
+ if (tmpRow.classList.contains('unpublished')) { tmpRow.classList.remove('unpublished'); }
+ }
+ if (parseInt(updStatus, 10) === 0) {
+ tmpStatus.innerHTML = `${Joomla.JText._('JNO')}`;
+ if (!tmpRow.classList.contains('unpublished') || tmpRow.classList.length === 0) { tmpRow.classList.add('unpublished'); }
+ }
+ if (parseInt(updStatus, 10) === -2) {
+ tmpStatus.innerHTML = `${Joomla.JText._('JTRASHED')}`;
+ 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);
diff --git a/build/media_src/com_modules/js/admin-module-edit_assignment.es6.js b/build/media_src/com_modules/js/admin-module-edit_assignment.es6.js
new file mode 100644
index 0000000000000..dac6092e02e3d
--- /dev/null
+++ b/build/media_src/com_modules/js/admin-module-edit_assignment.es6.js
@@ -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);
+})();
diff --git a/build/media_src/com_modules/js/admin-modules-modal.es6.js b/build/media_src/com_modules/js/admin-modules-modal.es6.js
new file mode 100644
index 0000000000000..72ef9da29793b
--- /dev/null
+++ b/build/media_src/com_modules/js/admin-modules-modal.es6.js
@@ -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();
+ }
+ });
+ });
+});