diff --git a/administrator/components/com_associations/tmpl/association/edit.php b/administrator/components/com_associations/tmpl/association/edit.php index e2703cd3b365f..8efb4c7387170 100644 --- a/administrator/components/com_associations/tmpl/association/edit.php +++ b/administrator/components/com_associations/tmpl/association/edit.php @@ -15,7 +15,7 @@ HTMLHelper::_('behavior.formvalidator'); HTMLHelper::_('behavior.keepalive'); -HTMLHelper::_('formbehavior.chosen', 'select'); +HTMLHelper::_('jquery.framework'); HTMLHelper::_('script', 'com_associations/sidebyside.js', false, true); HTMLHelper::_('stylesheet', 'com_associations/sidebyside.css', array(), true); diff --git a/administrator/components/com_associations/tmpl/associations/modal.php b/administrator/components/com_associations/tmpl/associations/modal.php index 85b794f3bfca9..970350a3d641f 100644 --- a/administrator/components/com_associations/tmpl/associations/modal.php +++ b/administrator/components/com_associations/tmpl/associations/modal.php @@ -24,9 +24,7 @@ Session::checkToken('get') or die(Text::_('JINVALID_TOKEN')); } -HTMLHelper::_('jquery.framework'); HTMLHelper::_('behavior.multiselect'); -HTMLHelper::_('formbehavior.chosen', 'select'); $function = $app->input->getCmd('function', 'jSelectAssociation'); $listOrder = $this->escape($this->state->get('list.ordering')); diff --git a/media/com_associations/js/admin-associations-default.es6.js b/media/com_associations/js/admin-associations-default.es6.js new file mode 100644 index 0000000000000..fd2a617923df8 --- /dev/null +++ b/media/com_associations/js/admin-associations-default.es6.js @@ -0,0 +1,18 @@ +/** + * @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.submitbutton = (pressbutton) => { + if (pressbutton === 'associations.purge') { + // eslint-disable-next-line no-restricted-globals + if (confirm(Joomla.JText._('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT'))) { + Joomla.submitform(pressbutton); + } else { + return false; + } + } else { + Joomla.submitform(pressbutton); + } + + return true; +}; diff --git a/media/com_associations/js/admin-associations-default.es6.min.js b/media/com_associations/js/admin-associations-default.es6.min.js new file mode 100644 index 0000000000000..fec48ec8324c4 --- /dev/null +++ b/media/com_associations/js/admin-associations-default.es6.min.js @@ -0,0 +1 @@ +Joomla.submitbutton=(o=>{if("associations.purge"===o){if(!confirm(Joomla.JText._("COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT")))return!1;Joomla.submitform(o)}else Joomla.submitform(o);return!0}); \ No newline at end of file diff --git a/media/com_associations/js/admin-associations-default.js b/media/com_associations/js/admin-associations-default.js index 3cc6ad4a3bc4b..4a3d9955fc9c3 100644 --- a/media/com_associations/js/admin-associations-default.js +++ b/media/com_associations/js/admin-associations-default.js @@ -1,15 +1,23 @@ +/** +* 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 - 2018 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ -Joomla.submitbutton = function(pressbutton) { - if (pressbutton == 'associations.purge') { - if (confirm(Joomla.JText._('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT'))) { - Joomla.submitform(pressbutton); - } else { - return false; - } - } else { - Joomla.submitform(pressbutton); - } +Joomla.submitbutton = function (pressbutton) { + if (pressbutton === 'associations.purge') { + // eslint-disable-next-line no-restricted-globals + if (confirm(Joomla.JText._('COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT'))) { + Joomla.submitform(pressbutton); + } else { + return false; + } + } else { + Joomla.submitform(pressbutton); + } + + return true; }; diff --git a/media/com_associations/js/admin-associations-default.min.js b/media/com_associations/js/admin-associations-default.min.js index dfe5460a7bd7e..18e3e30e956f1 100644 --- a/media/com_associations/js/admin-associations-default.min.js +++ b/media/com_associations/js/admin-associations-default.min.js @@ -1 +1 @@ -Joomla.submitbutton=function(o){if("associations.purge"==o){if(!confirm(Joomla.JText._("COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT")))return!1;Joomla.submitform(o)}else Joomla.submitform(o)}; \ No newline at end of file +Joomla.submitbutton=function(o){if("associations.purge"===o){if(!confirm(Joomla.JText._("COM_ASSOCIATIONS_PURGE_CONFIRM_PROMPT")))return!1;Joomla.submitform(o)}else Joomla.submitform(o);return!0}; \ No newline at end of file diff --git a/media/com_associations/js/admin-associations-modal.es6.js b/media/com_associations/js/admin-associations-modal.es6.js new file mode 100644 index 0000000000000..741712d9d93db --- /dev/null +++ b/media/com_associations/js/admin-associations-modal.es6.js @@ -0,0 +1,21 @@ +/** + * @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, document) => { + 'use strict'; + + document.addEventListener('DOMContentLoaded', () => { + const target = window.parent.document.getElementById('target-association'); + const links = [].slice.call(document.querySelectorAll('.select-link')); + + links.forEach((item) => { + item.addEventListener('click', (event) => { + target.src = `${target.getAttribute('data-editurl')}&task=${target.getAttribute('data-item')}.edit&id=${parseInt(event.target.getAttribute('data-id'), 10)}`; + window.parent.Joomla.Modal.getCurrent().close(); + }); + }); + }); +})(Joomla, document); diff --git a/media/com_associations/js/admin-associations-modal.es6.min.js b/media/com_associations/js/admin-associations-modal.es6.min.js new file mode 100644 index 0000000000000..36fd43bbf2961 --- /dev/null +++ b/media/com_associations/js/admin-associations-modal.es6.min.js @@ -0,0 +1 @@ +Joomla=window.Joomla||{},((t,e)=>{"use strict";e.addEventListener("DOMContentLoaded",()=>{const t=window.parent.document.getElementById("target-association");[].slice.call(e.querySelectorAll(".select-link")).forEach(e=>{e.addEventListener("click",e=>{t.src=`${t.getAttribute("data-editurl")}&task=${t.getAttribute("data-item")}.edit&id=${parseInt(e.target.getAttribute("data-id"),10)}`,window.parent.Joomla.Modal.getCurrent().close()})})})})(Joomla,document); \ No newline at end of file diff --git a/media/com_associations/js/admin-associations-modal.js b/media/com_associations/js/admin-associations-modal.js index 1bcfc9edda6e5..b78219457f4eb 100644 --- a/media/com_associations/js/admin-associations-modal.js +++ b/media/com_associations/js/admin-associations-modal.js @@ -1,27 +1,26 @@ +/** +* 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 - 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, document ) { - 'use strict'; +(function (Joomla, document) { + 'use strict'; - document.addEventListener('DOMContentLoaded', function() { - - if (Joomla.getOptions('modal-associations')) { - var fnName = Joomla.getOptions('modal-associations').func, - links = [].slice.call(document.querySelectorAll('.select-link')); + document.addEventListener('DOMContentLoaded', function () { + var target = window.parent.document.getElementById('target-association'); + var links = [].slice.call(document.querySelectorAll('.select-link')); - links.forEach(function (item) { - item.addEventListener('click', function (event) { - if (self != top) { - // Run function on parent window. - window.parent[fnName](event.target.getAttribute('data-id')); - } - }); - }); - } - }); -})(); + links.forEach(function (item) { + item.addEventListener('click', function (event) { + target.src = target.getAttribute('data-editurl') + '&task=' + target.getAttribute('data-item') + '.edit&id=' + parseInt(event.target.getAttribute('data-id'), 10); + window.parent.Joomla.Modal.getCurrent().close(); + }); + }); + }); +})(Joomla, document); diff --git a/media/com_associations/js/admin-associations-modal.min.js b/media/com_associations/js/admin-associations-modal.min.js index 9c5c297a1a9d6..d668e10f5a8a7 100644 --- a/media/com_associations/js/admin-associations-modal.min.js +++ b/media/com_associations/js/admin-associations-modal.min.js @@ -1 +1 @@ -Joomla=window.Joomla||{},function(t,o){"use strict";(void 0).addEventListener("DOMContentLoaded",function(){if((void 0).getOptions("modal-associations")){var t=(void 0).getOptions("modal-associations").func;[].slice.call((void 0).querySelectorAll(".select-link")).forEach(function(o){o.addEventListener("click",function(o){self!=top&&window.parent[t](o.target.getAttribute("data-id"))})})}})}(); \ No newline at end of file +Joomla=window.Joomla||{},function(t,e){"use strict";e.addEventListener("DOMContentLoaded",function(){var t=window.parent.document.getElementById("target-association");[].slice.call(e.querySelectorAll(".select-link")).forEach(function(e){e.addEventListener("click",function(e){t.src=t.getAttribute("data-editurl")+'"&task="'+t.getAttribute("data-item")+".edit&id="+parseInt(e.target.getAttribute("data-id"),10),window.parent.Joomla.Modal.getCurrent().close()})})})}(Joomla,document); \ No newline at end of file diff --git a/media/com_associations/js/associations-edit.es6.js b/media/com_associations/js/associations-edit.es6.js new file mode 100644 index 0000000000000..3fa7e60707abb --- /dev/null +++ b/media/com_associations/js/associations-edit.es6.js @@ -0,0 +1,112 @@ +/** + * @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, document) => { + 'use strict'; + + Joomla.hideAssociation = (formControl, languageCode) => { + const controlGroup = [].slice.call(document.querySelectorAll('#associations .control-group')); + + controlGroup.forEach((element) => { + // Current selected language. Hide it + const el = element.querySelector('.control-label label'); + + if (el) { + const attribute = el.getAttribute('for'); + + if (attribute.replace('_id', '') === `${formControl}_associations_${languageCode.replace('-', '_')}`) { + element.style.display = 'none'; + } + } + }); + }; + + Joomla.showAssociationMessage = () => { + const controlGroup = [].slice.call(document.querySelectorAll('#associations .control-group')); + + controlGroup.forEach((element) => { + element.style.display = 'none'; + + const associations = document.getElementById('associations'); + + if (associations) { + const html = document.createElement('div'); + html.classList.add('alert'); + html.classList.add('alert-info'); + html.id = 'associations-notice'; + html.innerHTML = Joomla.JText._('JGLOBAL_ASSOC_NOT_POSSIBLE'); + + associations.insertAdjacentElement('afterbegin', html); + } + }); + }; + + document.addEventListener('DOMContentLoaded', () => { + const associationsEditOptions = Joomla.getOptions('system.associations.edit'); + const formControl = associationsEditOptions.formControl || 'jform'; + const formControlLanguage = document.getElementById(`${formControl}_language`); + + // Hide the associations tab if needed + if (parseInt(associationsEditOptions.hidden, 10) === 1) { + Joomla.showAssociationMessage(); + } else if (formControlLanguage) { + // Hide only the associations for the current language + Joomla.hideAssociation(formControl, formControlLanguage.value); + } + + // When changing the language + if (formControlLanguage) { + formControlLanguage.addEventListener('change', (event) => { + // Remove message if any + Joomla.removeMessages(); + + let existsAssociations = false; + + /** For each language, remove the associations, ie, + * empty the associations fields and reset the buttons to Select/Create + */ + const controlGroup = [].slice.call(document.querySelectorAll('#associations .control-group')); + + controlGroup.forEach((element) => { + const attribute = element.querySelector('.control-label label').getAttribute('for'); + const languageCode = attribute.replace('_id', '').replace('jform_associations_', ''); + + // Show the association fields + element.style.display = 'block'; + + // Check if there was an association selected for this language + if (!existsAssociations && document.getElementById(`${formControl}_associations_${languageCode}_id`).value !== '') { + existsAssociations = true; + } + + // Call the modal clear button + const clear = document.getElementById(`${formControl}_associations_${languageCode}_clear`); + + if (clear.onclick) { + clear.onclick(); + } else if (clear.click) { + clear.click(); + } + }); + + // If associations existed, send a warning to the user + if (existsAssociations) { + Joomla.renderMessages({ warning: [Joomla.JText._('JGLOBAL_ASSOCIATIONS_RESET_WARNING')] }); + } + + // If the selected language is All hide the fields and add a message + const selectedLanguage = event.target.value; + + if (selectedLanguage === '*') { + Joomla.showAssociationMessage(); + } else { + // Else show the associations fields/buttons and hide the current selected language + Joomla.hideAssociation(formControl, selectedLanguage); + } + }); + } + }); +})(Joomla, document); diff --git a/media/com_associations/js/associations-edit.es6.min.js b/media/com_associations/js/associations-edit.es6.min.js new file mode 100644 index 0000000000000..650214f337f61 --- /dev/null +++ b/media/com_associations/js/associations-edit.es6.min.js @@ -0,0 +1 @@ +Joomla=window.Joomla||{},((e,o)=>{"use strict";e.hideAssociation=((e,s)=>{[].slice.call(o.querySelectorAll("#associations .control-group")).forEach(o=>{const t=o.querySelector(".control-label label");if(t){t.getAttribute("for").replace("_id","")===`${e}_associations_${s.replace("-","_")}`&&(o.style.display="none")}})}),e.showAssociationMessage=(()=>{[].slice.call(o.querySelectorAll("#associations .control-group")).forEach(s=>{s.style.display="none";const t=o.getElementById("associations");if(t){const s=o.createElement("div");s.classList.add("alert"),s.classList.add("alert-info"),s.id="associations-notice",s.innerHTML=e.JText._("JGLOBAL_ASSOC_NOT_POSSIBLE"),t.insertAdjacentElement("afterbegin",s)}})}),o.addEventListener("DOMContentLoaded",()=>{const s=e.getOptions("system.associations.edit"),t=s.formControl||"jform",a=o.getElementById(`${t}_language`);1===parseInt(s.hidden,10)?e.showAssociationMessage():a&&e.hideAssociation(t,a.value),a&&a.addEventListener("change",s=>{e.removeMessages();let a=!1;[].slice.call(o.querySelectorAll("#associations .control-group")).forEach(e=>{const s=e.querySelector(".control-label label").getAttribute("for").replace("_id","").replace("jform_associations_","");e.style.display="block",a||""===o.getElementById(`${t}_associations_${s}_id`).value||(a=!0);const i=o.getElementById(`${t}_associations_${s}_clear`);i.onclick?i.onclick():i.click&&i.click()}),a&&e.renderMessages({warning:[e.JText._("JGLOBAL_ASSOCIATIONS_RESET_WARNING")]});const i=s.target.value;"*"===i?e.showAssociationMessage():e.hideAssociation(t,i)})})})(Joomla,document); \ No newline at end of file diff --git a/media/com_associations/js/associations-edit.js b/media/com_associations/js/associations-edit.js index d5825db67cb42..e5aa3e742cb85 100644 --- a/media/com_associations/js/associations-edit.js +++ b/media/com_associations/js/associations-edit.js @@ -1,131 +1,117 @@ /** - * @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ +* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION. +* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD. +**/ /** - * Edit Associations javascript behavior - * - * Used for editing associations in the backend. - * - * @package Joomla - * @since 3.7.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, document) { - 'use strict'; - - Joomla.hideAssociation = function(formControl, languageCode) - { - var controlGroup = document.querySelectorAll('#associations .control-group'); - - for (var i = 0, l = controlGroup.length; i < l; i++) { - - // Current selected language. Hide it - var attribute = controlGroup[i].querySelector('.control-label label').getAttribute('for'); - - if (attribute.replace('_id', '') == formControl + '_associations_' + languageCode.replace('-', '_')) { - controlGroup[i].style.display = 'none'; - } - } - } - - Joomla.showAssociationMessage = function() - { - var controlGroup = document.querySelectorAll('#associations .control-group'); - - for (var i = 0, l = controlGroup.length; i < l; i++) { - controlGroup[i].style.display = 'none'; - - var associations = document.getElementById('associations'); - - if (associations) { - var html = document.createElement('div'); - html.classList.add('alert') - html.classList.add('alert-info') - html.id = 'associations-notice'; - html.innerHTML = Joomla.JText._('JGLOBAL_ASSOC_NOT_POSSIBLE'); - - associations.insertAdjacentElement('afterbegin', html); - } - } - } - - - document.addEventListener('DOMContentLoaded', function() { - - var associationsEditOptions = Joomla.getOptions('system.associations.edit'), formControl = associationsEditOptions.formControl || 'jform', - formControlLanguage = document.getElementById(formControl + '_language'); - - // Hide the associations tab if needed - if (associationsEditOptions.hidden == 1) - { - Joomla.showAssociationMessage(); - } - // Hide only the associations for the current language - else { - if (formControlLanguage) { - Joomla.hideAssociation(formControl, formControlLanguage.value); - } - } - - // When changing the language - if (formControlLanguage) { - formControlLanguage.addEventListener('change', function (event) { - - // Remove message if any - Joomla.removeMessages(); - - var existsAssociations = false; - - // For each language, remove the associations, ie, empty the associations fields and reset the buttons to Select/Create - var controlGroup = document.querySelectorAll('#associations .control-group'); - - for (var i = 0, l = controlGroup.length; i < l; i++) { - var attribute = controlGroup[i].querySelector('.control-label label').getAttribute('for'), - languageCode = attribute.replace('_id', '').replace('jform_associations_', ''); - - // Show the association fields - controlGroup[i].style.display = 'block'; - - // Check if there was an association selected for this language - if (!existsAssociations && document.getElementById(formControl + '_associations_' + languageCode + '_id').value !== '') - { - existsAssociations = true; - } - - // Call the modal clear button - var clear = document.getElementById(formControl + '_associations_' + languageCode + '_clear'); - - if (clear.onclick) { - clear.onclick(); - } else if (clear.click) { - clear.click(); - } - } - - // If associations existed, send a warning to the user - if (existsAssociations) - { - Joomla.renderMessages({warning: [Joomla.JText._('JGLOBAL_ASSOCIATIONS_RESET_WARNING')]}); - } - - // If the selected language is All hide the fields and add a message - var selectedLanguage = event.target.value; - if (selectedLanguage == '*') - { - Joomla.showAssociationMessage(); - } - // Else show the associations fields/buttons and hide the current selected language - else - { - Joomla.hideAssociation(formControl, selectedLanguage); - } - }); - } - - }); - +(function (Joomla, document) { + 'use strict'; + + Joomla.hideAssociation = function (formControl, languageCode) { + var controlGroup = [].slice.call(document.querySelectorAll('#associations .control-group')); + + controlGroup.forEach(function (element) { + // Current selected language. Hide it + var el = element.querySelector('.control-label label'); + + if (el) { + var attribute = el.getAttribute('for'); + + if (attribute.replace('_id', '') === formControl + '_associations_' + languageCode.replace('-', '_')) { + element.style.display = 'none'; + } + } + }); + }; + + Joomla.showAssociationMessage = function () { + var controlGroup = [].slice.call(document.querySelectorAll('#associations .control-group')); + + controlGroup.forEach(function (element) { + element.style.display = 'none'; + + var associations = document.getElementById('associations'); + + if (associations) { + var html = document.createElement('div'); + html.classList.add('alert'); + html.classList.add('alert-info'); + html.id = 'associations-notice'; + html.innerHTML = Joomla.JText._('JGLOBAL_ASSOC_NOT_POSSIBLE'); + + associations.insertAdjacentElement('afterbegin', html); + } + }); + }; + + document.addEventListener('DOMContentLoaded', function () { + var associationsEditOptions = Joomla.getOptions('system.associations.edit'); + var formControl = associationsEditOptions.formControl || 'jform'; + var formControlLanguage = document.getElementById(formControl + '_language'); + + // Hide the associations tab if needed + if (parseInt(associationsEditOptions.hidden, 10) === 1) { + Joomla.showAssociationMessage(); + } else if (formControlLanguage) { + // Hide only the associations for the current language + Joomla.hideAssociation(formControl, formControlLanguage.value); + } + + // When changing the language + if (formControlLanguage) { + formControlLanguage.addEventListener('change', function (event) { + // Remove message if any + Joomla.removeMessages(); + + var existsAssociations = false; + + /** For each language, remove the associations, ie, + * empty the associations fields and reset the buttons to Select/Create + */ + var controlGroup = [].slice.call(document.querySelectorAll('#associations .control-group')); + + controlGroup.forEach(function (element) { + var attribute = element.querySelector('.control-label label').getAttribute('for'); + var languageCode = attribute.replace('_id', '').replace('jform_associations_', ''); + + // Show the association fields + element.style.display = 'block'; + + // Check if there was an association selected for this language + if (!existsAssociations && document.getElementById(formControl + '_associations_' + languageCode + '_id').value !== '') { + existsAssociations = true; + } + + // Call the modal clear button + var clear = document.getElementById(formControl + '_associations_' + languageCode + '_clear'); + + if (clear.onclick) { + clear.onclick(); + } else if (clear.click) { + clear.click(); + } + }); + + // If associations existed, send a warning to the user + if (existsAssociations) { + Joomla.renderMessages({ warning: [Joomla.JText._('JGLOBAL_ASSOCIATIONS_RESET_WARNING')] }); + } + + // If the selected language is All hide the fields and add a message + var selectedLanguage = event.target.value; + + if (selectedLanguage === '*') { + Joomla.showAssociationMessage(); + } else { + // Else show the associations fields/buttons and hide the current selected language + Joomla.hideAssociation(formControl, selectedLanguage); + } + }); + } + }); })(Joomla, document); diff --git a/media/com_associations/js/associations-edit.min.js b/media/com_associations/js/associations-edit.min.js index 2c4012d12bd40..1e226b6bb24f4 100644 --- a/media/com_associations/js/associations-edit.min.js +++ b/media/com_associations/js/associations-edit.min.js @@ -1 +1 @@ -Joomla=window.Joomla||{},function(e,o){"use strict";e.hideAssociation=function(e,t){for(var s=o.querySelectorAll("#associations .control-group"),a=0,i=s.length;a { + 'use strict'; - // @TODO function should not be global, move it to Joomla - window['jSelectAssociation_' + itemId] = function(id) { - var target = document.getElementById('target-association'); + document.addEventListener('DOMContentLoaded', () => { + if (Joomla.getOptions('modal-associations')) { + const itemId = Joomla.getOptions('modal-associations').itemId; - if (target) - { - target.src = target.getAttribute('data-editurl') + - '&task=' + target.getAttribute('data-item') + '.edit' + '&id=' + id; - } + // @TODO function should not be global, move it to Joomla + window['jSelectAssociation_' + itemId] = (id) => { + const target = document.getElementById('target-association'); - Joomla.Modal.getCurrent().close(); - } - } - }); + if (target) { + target.setAttribute('src', + `${target.getAttribute('data-editurl')}&task=${target.getAttribute('data-item')}.edit&id=${id}`); + } + Joomla.Modal.getCurrent().close(); + } + } + }); })(Joomla, window); diff --git a/media/com_associations/js/modal-associations.min.js b/media/com_associations/js/modal-associations.min.js index a213bafe715da..0f182d49c16ad 100644 --- a/media/com_associations/js/modal-associations.min.js +++ b/media/com_associations/js/modal-associations.min.js @@ -1 +1 @@ -Joomla=window.Joomla||{},function(t,o){"use strict";document.addEventListener("DOMContentLoaded",function(){if(t.getOptions("modal-associations")){var e=t.getOptions("modal-associations").itemId;o["jSelectAssociation_"+e]=function(o){var e=document.getElementById("target-association");e&&(e.src=e.getAttribute("data-editurl")+"&task="+e.getAttribute("data-item")+".edit&id="+o),t.Modal.getCurrent().close()}}})}(Joomla,window); \ No newline at end of file +Joomla=window.Joomla||{},((t,e)=>{"use strict";document.addEventListener("DOMContentLoaded",()=>{if(t.getOptions("modal-associations")){const o=t.getOptions("modal-associations").itemId;e["jSelectAssociation_"+o]=(e=>{const o=document.getElementById("target-association");o&&o.setAttribute("src",`${o.getAttribute("data-editurl")}&task=${o.getAttribute("data-item")}.edit&id=${e}`),t.Modal.getCurrent().close()})}})})(Joomla,window); \ No newline at end of file diff --git a/media/com_associations/js/sidebyside.js b/media/com_associations/js/sidebyside.js index 53368caef7017..e43d5ad40b3d8 100644 --- a/media/com_associations/js/sidebyside.js +++ b/media/com_associations/js/sidebyside.js @@ -8,18 +8,14 @@ jQuery(document).ready(function($) { $('#toolbar-copy').hide(); // Save button actions, replacing the default Joomla.submitbutton() with custom function. - Joomla.submitbutton = function(task) - { + Joomla.submitbutton = function(task) { // Using close button, normal joomla submit. - if (task === 'association.cancel') - { + if (task === 'association.cancel') { Joomla.submitform(task); - } - else if(task === 'copy') - { + } else if(task === 'copy') { Joomla.loadingLayer('show'); - var targetLang = document.getElementById('target-association').getAttribute('data-language'), + var targetLang = document.getElementById('target-association').getAttribute('data-language'), referlangInput = window.frames['reference-association'].document.getElementById('jform_language'); // Set target language, to get correct content language in the copy @@ -27,10 +23,7 @@ jQuery(document).ready(function($) { referlangInput.value = targetLang; window.frames['reference-association'].Joomla.submitbutton(document.getElementById('adminForm').getAttribute('data-associatedview') + '.save2copy'); - } - // Undo association - else if (task === 'undo-association') - { + } else if (task === 'undo-association') { // Undo association var reference = document.getElementById('reference-association'); var target = document.getElementById('target-association'); var referenceId = reference.getAttribute('data-id'); @@ -46,8 +39,7 @@ jQuery(document).ready(function($) { reference.find('#jform_associations_' + targetLang + '_name').val(''); // - For chosen association selectors (menus). - reference.find('#jform_associations_' + targetLang + '_chzn').remove(); - reference.find('#jform_associations_' + targetLang).val('').change().chosen(); + reference.find('#jform_associations_' + targetLang).val(''); var lang = ''; @@ -55,14 +47,13 @@ jQuery(document).ready(function($) { $('#jform_itemlanguage option').each(function() { lang = $(this).val().split('|')[0]; - if (typeof lang !== 'undefined') - { + + if (typeof lang !== 'undefined') { lang = lang.replace(/-/,'_'); // - For modal association selectors. target.find('#jform_associations_' + lang + '_id').val(''); // - For chosen association selectors (menus). - target.find('#jform_associations_' + lang + '_chzn').remove(); - target.find('#jform_associations_' + lang).val('').change().chosen(); + target.find('#jform_associations_' + lang).val(''); } }); @@ -72,24 +63,19 @@ jQuery(document).ready(function($) { target.find('#jform_associations_' + referenceLang + '_name').val(''); // - For chosen association selectors (menus). - target.find('#jform_associations_' + referenceLang + '_chzn').remove(); - target.find('#jform_associations_' + referenceLang).val('').change().chosen(); + target.find('#jform_associations_' + referenceLang).val(''); // Reset switcher after removing association var currentSwitcher = $('#jform_itemlanguage').val(); var currentLang = targetLang.replace(/_/,'-'); $('#jform_itemlanguage option[value=\"' + currentSwitcher + '\"]').val(currentLang + ':0:add'); - $('#jform_itemlanguage').val('').change(); - $('#jform_itemlanguage').trigger('liszt:updated'); + $('#jform_itemlanguage').val(''); // Save one of the items to confirm action Joomla.submitbutton('reference'); - } - // Saving target or reference, send the save action to the target/reference iframe. - else - { + } else { + // Saving target or reference, send the save action to the target/reference iframe. // We need to re-enable the language field to save. - $('#' + task + '-association').contents().find('#jform_language').attr('disabled', false); window.frames[task + '-association'].Joomla.submitbutton(document.getElementById('adminForm').getAttribute('data-associatedview') + '.apply'); } @@ -101,17 +87,13 @@ jQuery(document).ready(function($) { Joomla.loadingLayer('load'); // Attach behaviour to toggle button. - $(document).on('click', '#toogle-left-panel', function() - { + $(document).on('click', '#toogle-left-panel', function() { var referenceHide = this.getAttribute('data-hide-reference'); var referenceShow = this.getAttribute('data-show-reference'); - if ($(this).text() === referenceHide) - { + if ($(this).text() === referenceHide) { $(this).text(referenceShow); - } - else - { + } else { $(this).text(referenceHide); } @@ -125,8 +107,7 @@ jQuery(document).ready(function($) { var selected = $(this).val(); // Populate the data attributes and load the the edit page in target frame. - if (selected !== '' && typeof selected !== 'undefined') - { + if (selected !== '' && typeof selected !== 'undefined') { target.setAttribute('data-action', selected.split(':')[2]); target.setAttribute('data-id', selected.split(':')[1]); target.setAttribute('data-language', selected.split(':')[0]); @@ -136,10 +117,8 @@ jQuery(document).ready(function($) { // Load the target frame. target.src = target.getAttribute('data-editurl') + '&task=' + target.getAttribute('data-item') + '.' + target.getAttribute('data-action') + '&id=' + target.getAttribute('data-id'); - } - // Reset the data attributes and no item to load. - else - { + } else { + // Reset the data attributes and no item to load. $('#toolbar-target').hide(); $('#toolbar-copy').hide(); $('#select-change').addClass("hidden"); @@ -154,13 +133,11 @@ jQuery(document).ready(function($) { // Attach behaviour to reference frame load event. $('#reference-association').on('load', function() { - // Load Target Pane AFTER reference pane has loaded to prevent session conflict with checkout document.getElementById('target-association').setAttribute('src', document.getElementById('target-association').getAttribute('src')); // If copy button used - if ($(this).contents().find('#jform_id').val() !== this.getAttribute('data-id')) - { + if ($(this).contents().find('#jform_id').val() !== this.getAttribute('data-id')) { var target = document.getElementById('target-association'); target.src = target.getAttribute('data-editurl') + '&task=' + target.getAttribute('data-item') + '.edit' + '&id=' + $(this).contents().find('#jform_id').val(); this.src = this.getAttribute('data-editurl') + '&task=' + this.getAttribute('data-item') + '.edit' + '&id=' + this.getAttribute('data-id'); @@ -169,24 +146,21 @@ jQuery(document).ready(function($) { var reference = $(this).contents(); // Disable language field. - reference.find('#jform_language_chzn').remove(); - reference.find('#jform_language').attr('disabled', true).chosen(); + reference.find('#jform_language').attr('disabled', ''); // Remove modal buttons on the reference reference.find('#associations').find('.btn').remove(); var parse = ''; - $('#jform_itemlanguage option').each(function() - { + $('#jform_itemlanguage option').each(function() { parse = $(this).val().split(':'); - if (typeof parse[0] !== 'undefined') - { + if (typeof parse[0] !== 'undefined') { // - For modal association selectors. - langAssociation = parse[0].replace(/-/,'_'); - if (reference.find('#jform_associations_' + langAssociation + '_id').val() == '') - { + var langAssociation = parse[0].replace(/-/,'_'); + + if (reference.find('#jform_associations_' + langAssociation + '_id').val() == '') { reference.find('#jform_associations_' + langAssociation + '_name') .val(document.getElementById('reference-association').getAttribute('data-no-assoc')); } @@ -200,23 +174,21 @@ jQuery(document).ready(function($) { // Attach behaviour to target frame load event. $('#target-association').on('load', function() { // We need to check if we are not loading a blank iframe. - if (this.getAttribute('src') != '') - { + if (this.getAttribute('src') != '') { $('#toolbar-target').show(); $('#toolbar-copy').show(); $('#select-change').removeClass("hidden"); - var targetLanguage = this.getAttribute('data-language'); - var targetId = this.getAttribute('data-id'); - var targetLoadedId = $(this).contents().find('#jform_id').val() || '0'; + var targetLanguage = this.getAttribute('data-language'); + var targetId = this.getAttribute('data-id'); + var targetLoadedId = $(this).contents().find('#jform_id').val() || '0'; // Remove modal buttons on the target $(this).contents().find('a[href=\"#associations\"]').parent().find('.btn').remove(); $(this).contents().find('#associations').find('.btn').remove(); // Always show General tab first if associations tab is selected on the reference - if ($(this).contents().find('#associations').hasClass('active')) - { + if ($(this).contents().find('#associations').hasClass('active')) { $(this).contents().find('a[href=\"#associations\"]').parent().removeClass('active'); $(this).contents().find('#associations').removeClass('active'); @@ -225,8 +197,7 @@ jQuery(document).ready(function($) { } // Update language field with the selected language and them disable it. - $(this).contents().find('#jform_language_chzn').remove(); - $(this).contents().find('#jform_language').val(targetLanguage).change().attr('disabled', true).chosen(); + $(this).contents().find('#jform_language').val(targetLanguage).attr('disabled', ''); // If we are creating a new association (before save) we need to add the new association. if (targetLoadedId == '0') @@ -243,12 +214,11 @@ jQuery(document).ready(function($) { // Add the id to list of items to check in on close. var currentIdList = document.getElementById('target-id').value; - var updatedList = currentIdList == '' ? targetLoadedId : currentIdList + ',' + targetLoadedId; + var updatedList = currentIdList == '' ? targetLoadedId : currentIdList + ',' + targetLoadedId; document.getElementById('target-id').value = updatedList; // If we created a new association (after save). - if (targetLoadedId != targetId) - { + if (targetLoadedId != targetId) { // Refresh the language selector with the new id (used after save). $('#jform_itemlanguage option[value^=\"' + targetLanguage + ':' + targetId + ':add\"]').val(targetLanguage + ':' + targetLoadedId + ':edit'); @@ -260,16 +230,15 @@ jQuery(document).ready(function($) { // Update the reference item associations tab. var reference = document.getElementById('reference-association'); var languageCode = targetLanguage.replace(/-/, '_'); - var title = $(this).contents().find('#jform_title').val() + var title = $(this).contents().find('#jform_title').val(); // - For modal association selectors. $(reference).contents().find('#jform_associations_' + languageCode + '_id').val(targetLoadedId); $(reference).contents().find('#jform_associations_' + languageCode + '_name').val(title); // - For chosen association selectors (menus). - $(reference).contents().find('#jform_associations_' + languageCode + '_chzn').remove(); $(reference).contents().find('#jform_associations_' + languageCode).append(''); - $(reference).contents().find('#jform_associations_' + languageCode).val(targetLoadedId).change().chosen(); + $(reference).contents().find('#jform_associations_' + languageCode).val(targetLoadedId); } // Update the target item associations tab. @@ -284,28 +253,24 @@ jQuery(document).ready(function($) { target.find('#jform_associations_' + languageCode + '_name').val(title); // - For chosen association selectors (menus). - target.find('#jform_associations_' + languageCode + '_chzn').remove(); var chznField = target.find('#jform_associations_' + languageCode); chznField.append(''); - chznField.val(referenceId).change().chosen(); + chznField.val(referenceId); var parse, langAssociation; - $('#jform_itemlanguage option').each(function() - { + $('#jform_itemlanguage option').each(function() { parse = $(this).val().split(':'); - if (typeof parse[1] !== 'undefined' && parse[1] !== '0') - { + if (typeof parse[1] !== 'undefined' && parse[1] !== '0') { // - For modal association selectors. langAssociation = parse[0].replace(/-/,'_'); target.find('#jform_associations_' + langAssociation + '_id').val(parse[1]); // - For chosen association selectors (menus). - target.find('#jform_associations_' + langAssociation + '_chzn').remove(); chznField = target.find('#jform_associations_' + langAssociation); chznField.append(''); - chznField.val(parse[1]).change().chosen(); + chznField.val(parse[1]); } }); diff --git a/media/com_associations/js/sidebyside.min.js b/media/com_associations/js/sidebyside.min.js index 74b39553317f9..851dac8375e8b 100644 --- a/media/com_associations/js/sidebyside.min.js +++ b/media/com_associations/js/sidebyside.min.js @@ -1 +1 @@ -jQuery(document).ready(function(t){t("#toolbar-target").hide(),t("#toolbar-copy").hide(),Joomla.submitbutton=function(e){if("association.cancel"===e)Joomla.submitform(e);else if("copy"===e){Joomla.loadingLayer("show");var a=document.getElementById("target-association").getAttribute("data-language"),i=window.frames["reference-association"].document.getElementById("jform_language");i.removeAttribute("disabled"),i.value=a,window.frames["reference-association"].Joomla.submitbutton(document.getElementById("adminForm").getAttribute("data-associatedview")+".save2copy")}else if("undo-association"===e){var n=document.getElementById("reference-association"),o=document.getElementById("target-association"),s=(n.getAttribute("data-id"),n.getAttribute("data-language").replace(/-/,"_"));o.getAttribute("data-id"),a=o.getAttribute("data-language").replace(/-/,"_");n=t(n).contents(),o=t(o).contents(),n.find("#jform_associations_"+a+"_id").val(""),n.find("#jform_associations_"+a+"_name").val(""),n.find("#jform_associations_"+a+"_chzn").remove(),n.find("#jform_associations_"+a).val("").change().chosen();var d="";t("#jform_itemlanguage option").each(function(){void 0!==(d=t(this).val().split("|")[0])&&(d=d.replace(/-/,"_"),o.find("#jform_associations_"+d+"_id").val(""),o.find("#jform_associations_"+d+"_chzn").remove(),o.find("#jform_associations_"+d).val("").change().chosen())}),o.find("#jform_associations_"+s+"_id").val(""),o.find("#jform_associations_"+s+"_name").val(""),o.find("#jform_associations_"+s+"_chzn").remove(),o.find("#jform_associations_"+s).val("").change().chosen();var r=t("#jform_itemlanguage").val(),c=a.replace(/_/,"-");t('#jform_itemlanguage option[value="'+r+'"]').val(c+":0:add"),t("#jform_itemlanguage").val("").change(),t("#jform_itemlanguage").trigger("liszt:updated"),Joomla.submitbutton("reference")}else t("#"+e+"-association").contents().find("#jform_language").attr("disabled",!1),window.frames[e+"-association"].Joomla.submitbutton(document.getElementById("adminForm").getAttribute("data-associatedview")+".apply");return!1},Joomla.loadingLayer("load"),t(document).on("click","#toogle-left-panel",function(){var e=this.getAttribute("data-hide-reference"),a=this.getAttribute("data-show-reference");t(this).text()===e?t(this).text(a):t(this).text(e),t("#left-panel").toggle(),t("#right-panel").toggleClass("full-width")}),t(document).on("change","#jform_itemlanguage",function(){var e=document.getElementById("target-association"),a=t(this).val();""!==a&&void 0!==a?(e.setAttribute("data-action",a.split(":")[2]),e.setAttribute("data-id",a.split(":")[1]),e.setAttribute("data-language",a.split(":")[0]),Joomla.loadingLayer("show"),e.src=e.getAttribute("data-editurl")+"&task="+e.getAttribute("data-item")+"."+e.getAttribute("data-action")+"&id="+e.getAttribute("data-id")):(t("#toolbar-target").hide(),t("#toolbar-copy").hide(),t("#select-change").addClass("hidden"),t("#remove-assoc").addClass("hidden"),e.setAttribute("data-action",""),e.setAttribute("data-id","0"),e.setAttribute("data-language",""),e.src="")}),t("#reference-association").on("load",function(){if(document.getElementById("target-association").setAttribute("src",document.getElementById("target-association").getAttribute("src")),t(this).contents().find("#jform_id").val()!==this.getAttribute("data-id")){var e=document.getElementById("target-association");e.src=e.getAttribute("data-editurl")+"&task="+e.getAttribute("data-item")+".edit&id="+t(this).contents().find("#jform_id").val(),this.src=this.getAttribute("data-editurl")+"&task="+this.getAttribute("data-item")+".edit&id="+this.getAttribute("data-id")}var a=t(this).contents();a.find("#jform_language_chzn").remove(),a.find("#jform_language").attr("disabled",!0).chosen(),a.find("#associations").find(".btn").remove();var i="";t("#jform_itemlanguage option").each(function(){void 0!==(i=t(this).val().split(":"))[0]&&(langAssociation=i[0].replace(/-/,"_"),""==a.find("#jform_associations_"+langAssociation+"_id").val()&&a.find("#jform_associations_"+langAssociation+"_name").val(document.getElementById("reference-association").getAttribute("data-no-assoc")))}),Joomla.loadingLayer("hide")}),t("#target-association").on("load",function(){if(""!=this.getAttribute("src")){t("#toolbar-target").show(),t("#toolbar-copy").show(),t("#select-change").removeClass("hidden");var e=this.getAttribute("data-language"),a=this.getAttribute("data-id"),i=t(this).contents().find("#jform_id").val()||"0";if(t(this).contents().find('a[href="#associations"]').parent().find(".btn").remove(),t(this).contents().find("#associations").find(".btn").remove(),t(this).contents().find("#associations").hasClass("active")&&(t(this).contents().find('a[href="#associations"]').parent().removeClass("active"),t(this).contents().find("#associations").removeClass("active"),t(this).contents().find(".nav-tabs").find("li").first().addClass("active"),t(this).contents().find(".tab-content").find(".tab-pane").first().addClass("active")),t(this).contents().find("#jform_language_chzn").remove(),t(this).contents().find("#jform_language").val(e).change().attr("disabled",!0).chosen(),"0"==i)document.getElementById("select-change-text").innerHTML=document.getElementById("select-change").getAttribute("data-select");else{document.getElementById("select-change-text").innerHTML=document.getElementById("select-change").getAttribute("data-change"),t("#remove-assoc").removeClass("hidden"),t("#toolbar-copy").hide();var n=document.getElementById("target-id").value,o=""==n?i:n+","+i;document.getElementById("target-id").value=o,i!=a&&(t('#jform_itemlanguage option[value^="'+e+":"+a+':add"]').val(e+":"+i+":edit"),this.setAttribute("data-id",i),this.setAttribute("data-action","edit"));var s=document.getElementById("reference-association"),d=e.replace(/-/,"_"),r=t(this).contents().find("#jform_title").val();t(s).contents().find("#jform_associations_"+d+"_id").val(i),t(s).contents().find("#jform_associations_"+d+"_name").val(r),t(s).contents().find("#jform_associations_"+d+"_chzn").remove(),t(s).contents().find("#jform_associations_"+d).append('"),t(s).contents().find("#jform_associations_"+d).val(i).change().chosen()}var c=(s=document.getElementById("reference-association")).getAttribute("data-id"),l=(d=s.getAttribute("data-language").replace(/-/,"_"),r=t(s).contents().find("#jform_title").val(),t(this).contents());l.find("#jform_associations_"+d+"_id").val(c),l.find("#jform_associations_"+d+"_name").val(r),l.find("#jform_associations_"+d+"_chzn").remove();var m,g,f=l.find("#jform_associations_"+d);f.append('"),f.val(c).change().chosen(),t("#jform_itemlanguage option").each(function(){void 0!==(m=t(this).val().split(":"))[1]&&"0"!==m[1]&&(g=m[0].replace(/-/,"_"),l.find("#jform_associations_"+g+"_id").val(m[1]),l.find("#jform_associations_"+g+"_chzn").remove(),(f=l.find("#jform_associations_"+g)).append(''),f.val(m[1]).change().chosen())}),Joomla.loadingLayer("hide")}})}); \ No newline at end of file +jQuery(document).ready(function(t){t("#toolbar-target").hide(),t("#toolbar-copy").hide(),Joomla.submitbutton=function(e){if("association.cancel"===e)Joomla.submitform(e);else if("copy"===e){Joomla.loadingLayer("show");var a=document.getElementById("target-association").getAttribute("data-language"),i=window.frames["reference-association"].document.getElementById("jform_language");i.removeAttribute("disabled"),i.value=a,window.frames["reference-association"].Joomla.submitbutton(document.getElementById("adminForm").getAttribute("data-associatedview")+".save2copy")}else if("undo-association"===e){var o=document.getElementById("reference-association"),n=document.getElementById("target-association"),s=(o.getAttribute("data-id"),o.getAttribute("data-language").replace(/-/,"_"));n.getAttribute("data-id"),a=n.getAttribute("data-language").replace(/-/,"_");o=t(o).contents(),n=t(n).contents(),o.find("#jform_associations_"+a+"_id").val(""),o.find("#jform_associations_"+a+"_name").val(""),o.find("#jform_associations_"+a).val("");var d="";t("#jform_itemlanguage option").each(function(){void 0!==(d=t(this).val().split("|")[0])&&(d=d.replace(/-/,"_"),n.find("#jform_associations_"+d+"_id").val(""),n.find("#jform_associations_"+d).val(""))}),n.find("#jform_associations_"+s+"_id").val(""),n.find("#jform_associations_"+s+"_name").val(""),n.find("#jform_associations_"+s).val("");var r=t("#jform_itemlanguage").val(),c=a.replace(/_/,"-");t('#jform_itemlanguage option[value="'+r+'"]').val(c+":0:add"),t("#jform_itemlanguage").val(""),Joomla.submitbutton("reference")}else t("#"+e+"-association").contents().find("#jform_language").attr("disabled",!1),window.frames[e+"-association"].Joomla.submitbutton(document.getElementById("adminForm").getAttribute("data-associatedview")+".apply");return!1},Joomla.loadingLayer("load"),t(document).on("click","#toogle-left-panel",function(){var e=this.getAttribute("data-hide-reference"),a=this.getAttribute("data-show-reference");t(this).text()===e?t(this).text(a):t(this).text(e),t("#left-panel").toggle(),t("#right-panel").toggleClass("full-width")}),t(document).on("change","#jform_itemlanguage",function(){var e=document.getElementById("target-association"),a=t(this).val();""!==a&&void 0!==a?(e.setAttribute("data-action",a.split(":")[2]),e.setAttribute("data-id",a.split(":")[1]),e.setAttribute("data-language",a.split(":")[0]),Joomla.loadingLayer("show"),e.src=e.getAttribute("data-editurl")+"&task="+e.getAttribute("data-item")+"."+e.getAttribute("data-action")+"&id="+e.getAttribute("data-id")):(t("#toolbar-target").hide(),t("#toolbar-copy").hide(),t("#select-change").addClass("hidden"),t("#remove-assoc").addClass("hidden"),e.setAttribute("data-action",""),e.setAttribute("data-id","0"),e.setAttribute("data-language",""),e.src="")}),t("#reference-association").on("load",function(){if(document.getElementById("target-association").setAttribute("src",document.getElementById("target-association").getAttribute("src")),t(this).contents().find("#jform_id").val()!==this.getAttribute("data-id")){var e=document.getElementById("target-association");e.src=e.getAttribute("data-editurl")+"&task="+e.getAttribute("data-item")+".edit&id="+t(this).contents().find("#jform_id").val(),this.src=this.getAttribute("data-editurl")+"&task="+this.getAttribute("data-item")+".edit&id="+this.getAttribute("data-id")}var a=t(this).contents();a.find("#jform_language").attr("disabled",""),a.find("#associations").find(".btn").remove();var i="";t("#jform_itemlanguage option").each(function(){if(void 0!==(i=t(this).val().split(":"))[0]){var e=i[0].replace(/-/,"_");""==a.find("#jform_associations_"+e+"_id").val()&&a.find("#jform_associations_"+e+"_name").val(document.getElementById("reference-association").getAttribute("data-no-assoc"))}}),Joomla.loadingLayer("hide")}),t("#target-association").on("load",function(){if(""!=this.getAttribute("src")){t("#toolbar-target").show(),t("#toolbar-copy").show(),t("#select-change").removeClass("hidden");var e=this.getAttribute("data-language"),a=this.getAttribute("data-id"),i=t(this).contents().find("#jform_id").val()||"0";if(t(this).contents().find('a[href="#associations"]').parent().find(".btn").remove(),t(this).contents().find("#associations").find(".btn").remove(),t(this).contents().find("#associations").hasClass("active")&&(t(this).contents().find('a[href="#associations"]').parent().removeClass("active"),t(this).contents().find("#associations").removeClass("active"),t(this).contents().find(".nav-tabs").find("li").first().addClass("active"),t(this).contents().find(".tab-content").find(".tab-pane").first().addClass("active")),t(this).contents().find("#jform_language").val(e).attr("disabled",""),"0"==i)document.getElementById("select-change-text").innerHTML=document.getElementById("select-change").getAttribute("data-select");else{document.getElementById("select-change-text").innerHTML=document.getElementById("select-change").getAttribute("data-change"),t("#remove-assoc").removeClass("hidden"),t("#toolbar-copy").hide();var o=document.getElementById("target-id").value,n=""==o?i:o+","+i;document.getElementById("target-id").value=n,i!=a&&(t('#jform_itemlanguage option[value^="'+e+":"+a+':add"]').val(e+":"+i+":edit"),this.setAttribute("data-id",i),this.setAttribute("data-action","edit"));var s=document.getElementById("reference-association"),d=e.replace(/-/,"_"),r=t(this).contents().find("#jform_title").val();t(s).contents().find("#jform_associations_"+d+"_id").val(i),t(s).contents().find("#jform_associations_"+d+"_name").val(r),t(s).contents().find("#jform_associations_"+d).append('"),t(s).contents().find("#jform_associations_"+d).val(i)}var c=(s=document.getElementById("reference-association")).getAttribute("data-id"),l=(d=s.getAttribute("data-language").replace(/-/,"_"),r=t(s).contents().find("#jform_title").val(),t(this).contents());l.find("#jform_associations_"+d+"_id").val(c),l.find("#jform_associations_"+d+"_name").val(r);var m,g,f=l.find("#jform_associations_"+d);f.append('"),f.val(c),t("#jform_itemlanguage option").each(function(){void 0!==(m=t(this).val().split(":"))[1]&&"0"!==m[1]&&(g=m[0].replace(/-/,"_"),l.find("#jform_associations_"+g+"_id").val(m[1]),(f=l.find("#jform_associations_"+g)).append(''),f.val(m[1]))}),Joomla.loadingLayer("hide")}})}); \ No newline at end of file diff --git a/media/com_banners/js/admin-banner-edit.min.js b/media/com_banners/js/admin-banner-edit.min.js index 2e0c78d94217b..0d46f688bb716 100644 --- a/media/com_banners/js/admin-banner-edit.min.js +++ b/media/com_banners/js/admin-banner-edit.min.js @@ -1 +1 @@ -!function(e){"use strict";var t=function(t){var n=e.getElementById("image"),a=e.getElementById("custom");switch(t){case"0":n.style.display="block",a.style.display="none";break;case"1":n.style.display="none",a.style.display="block"}};e.addEventListener("DOMContentLoaded",function(){var n=e.getElementById("jform_type");n&&(t(n.value),n.addEventListener("change",function(e){t(e.target.value)}))})}(document); \ No newline at end of file +(e=>{"use strict";const t=t=>{const s=e.getElementById("image"),n=e.getElementById("custom");switch(t){case"0":s.style.display="block",n.style.display="none";break;case"1":s.style.display="none",n.style.display="block"}};e.addEventListener("DOMContentLoaded",()=>{const s=e.getElementById("jform_type");s&&(t(s.value),s.addEventListener("change",e=>{t(e.target.value)}))})})(document); \ No newline at end of file diff --git a/media/com_fields/js/admin-field-edit.min.js b/media/com_fields/js/admin-field-edit.min.js index a6be5ebcfdb57..0ba58e0c33aa1 100644 --- a/media/com_fields/js/admin-field-edit.min.js +++ b/media/com_fields/js/admin-field-edit.min.js @@ -1 +1 @@ -document.addEventListener("DOMContentLoaded",function(){var e=document.getElementById("jform_title");e.dpOldValue=e.value,e.addEventListener("change",function(e){var t=document.getElementById("jform_label"),d=e.currentTarget;d.dpOldValue===t.value&&(t.value=d.value),d.dpOldValue=d.value})}); \ No newline at end of file +document.addEventListener("DOMContentLoaded",()=>{const e=document.getElementById("jform_title");e.dpOldValue=e.value,e.addEventListener("change",e=>{const t=document.getElementById("jform_label"),d=e.currentTarget;d.dpOldValue===t.value&&(t.value=d.value),d.dpOldValue=d.value})}); \ No newline at end of file diff --git a/media/legacy/js/bootstrap-init.js b/media/legacy/js/bootstrap-init.js index 30a9575f6300c..1ad13fbd4164a 100644 --- a/media/legacy/js/bootstrap-init.js +++ b/media/legacy/js/bootstrap-init.js @@ -93,18 +93,23 @@ // @TODO throw the standard Joomla event if ($self.data('url')) { var modalBody = $self.find('.modal-body'); + var el; modalBody.find('iframe').remove(); + // Hacks because com_associations and field modals use pure javascript in the url! if ($self.data('iframe').indexOf("document.getElementById") > 0){ var iframeTextArr = $self.data('iframe').split('+'); var idFieldArr = iframeTextArr[1].split('"'); - var data_iframe = iframeTextArr[0] + - document.getElementById(idFieldArr[1]).value + - iframeTextArr[2]; + + if (!document.getElementById(idFieldArr[1])) { + el = eval(idFieldArr[0]); + } else { + el = document.getElementById(idFieldArr[1]).value; + } + + var data_iframe = iframeTextArr[0] + el + iframeTextArr[2]; modalBody.prepend(data_iframe); - } - else - { + } else { modalBody.prepend($self.data('iframe')); } } diff --git a/media/legacy/js/bootstrap-init.min.js b/media/legacy/js/bootstrap-init.min.js index 248ec0412e34c..e1e279584eecb 100644 --- a/media/legacy/js/bootstrap-init.min.js +++ b/media/legacy/js/bootstrap-init.min.js @@ -1 +1 @@ -!function(){"use strict";jQuery(document).ready(function(o){var t=Joomla.getOptions("bootstrap.accordion"),n=Joomla.getOptions("bootstrap.alert"),e=Joomla.getOptions("bootstrap.button"),a=Joomla.getOptions("bootstrap.carousel"),i=Joomla.getOptions("bootstrap.dropdown"),l=o(".joomla-modal"),s=Joomla.getOptions("bootstrap.popover"),d=Joomla.getOptions("bootstrap.scrollspy"),r=Joomla.getOptions("bootstrap.tabs"),c=Joomla.getOptions("bootstrap.tooltip");t&&o.each(t,function(t,n){o("#"+t).collapse({parent:n.parent,toggle:n.toggle}).on("show",new Function(n.onShow)()).on("shown",new Function(n.onShown)()).on("hideme",new Function(n.onHide)()).on("hidden",new Function(n.onHidden)())}),n&&o.each(n,function(t,n){o("#"+t).alert()}),e&&o.each(e,function(t,n){o("#"+t).button()}),a&&o.each(a,function(t,n){o("#"+t).carousel({interval:n.interval?n.interval:5e3,pause:n.pause?n.pause:"hover"})}),i&&o.each(i,function(t,n){o("#"+t).dropdown()}),l.length&&o.each(o(".joomla-modal"),function(){var t=o(this),n=t.get(0);n&&(n.open=function(){return t.modal("show")},n.close=function(){return t.modal("hide")}),t.on("show.bs.modal",function(){if(Joomla.Modal.setCurrent(n),t.data("url")){var o=t.find(".modal-body");if(o.find("iframe").remove(),t.data("iframe").indexOf("document.getElementById")>0){var e=t.data("iframe").split("+"),a=e[1].split('"'),i=e[0]+document.getElementById(a[1]).value+e[2];o.prepend(i)}else o.prepend(t.data("iframe"))}}).on("shown.bs.modal",function(){o("div.modal:visible").outerHeight(!0);var n=o("div.modal-header:visible").outerHeight(!0),e=o("div.modal-body:visible").outerHeight(!0),a=o("div.modal-body:visible").height(),i=o("div.modal-footer:visible").outerHeight(!0),l=t.offsetTop,s=e-a,d=o(window).height()-2*l-(n+i+s);t.data("url")&&(o(".iframe").height()>d&&(o(".modal-body").css({"max-height":d,"overflow-y":"auto"}),o(".iframe").css("max-height",d-s)))}).on("hide.bs.modal",function(){o(".modal-body").css({"max-height":"initial","overflow-y":"initial"}),o(".modalTooltip").tooltip("dispose")}).on("hidden.bs.modal",function(){Joomla.Modal.setCurrent("")})}),s&&o.each(s,function(t,n){n.constraints=[n.constraints],o(t).popover(n)}),d&&o.each(d,function(t,n){o("#"+t).scrollspy(n)}),r&&o.each(r,function(t,n){o.each(o("#"+t+"Content").find(".tab-pane"),function(n,e){if(o(e).data("node")){var a=o(e).data("node").split("["),i=""!=a[0]?'class="nav-link '+a[0]+'"':'class="nav-link"';o("#"+t+"Tabs").append('")}})}),c&&o.each(c,function(t,n){n.constraints=[n.constraints],o(t).tooltip(n).on("show.bs.tooltip",new Function(n.onShow)()).on("shown.bs.tooltip",new Function(n.onShown)()).on("hide.bs.tooltip",new Function(n.onHide)()).on("hidden.bs.tooltip",new Function(n.onHidden)())})})}(); \ No newline at end of file +!function(){"use strict";jQuery(document).ready(function($){var accordion=Joomla.getOptions("bootstrap.accordion"),alert=Joomla.getOptions("bootstrap.alert"),button=Joomla.getOptions("bootstrap.button"),carousel=Joomla.getOptions("bootstrap.carousel"),dropdown=Joomla.getOptions("bootstrap.dropdown"),modal=$(".joomla-modal"),popover=Joomla.getOptions("bootstrap.popover"),scrollspy=Joomla.getOptions("bootstrap.scrollspy"),tabs=Joomla.getOptions("bootstrap.tabs"),tooltip=Joomla.getOptions("bootstrap.tooltip");accordion&&$.each(accordion,function(o,e){$("#"+o).collapse({parent:e.parent,toggle:e.toggle}).on("show",new Function(e.onShow)()).on("shown",new Function(e.onShown)()).on("hideme",new Function(e.onHide)()).on("hidden",new Function(e.onHidden)())}),alert&&$.each(alert,function(o,e){$("#"+o).alert()}),button&&$.each(button,function(o,e){$("#"+o).button()}),carousel&&$.each(carousel,function(o,e){$("#"+o).carousel({interval:e.interval?e.interval:5e3,pause:e.pause?e.pause:"hover"})}),dropdown&&$.each(dropdown,function(o,e){$("#"+o).dropdown()}),modal.length&&$.each($(".joomla-modal"),function(){var $self=$(this),element=$self.get(0);element&&(element.open=function(){return $self.modal("show")},element.close=function(){return $self.modal("hide")}),$self.on("show.bs.modal",function(){if(Joomla.Modal.setCurrent(element),$self.data("url")){var modalBody=$self.find(".modal-body"),el;if(modalBody.find("iframe").remove(),$self.data("iframe").indexOf("document.getElementById")>0){var iframeTextArr=$self.data("iframe").split("+"),idFieldArr=iframeTextArr[1].split('"');el=document.getElementById(idFieldArr[1])?document.getElementById(idFieldArr[1]).value:eval(idFieldArr[0]);var data_iframe=iframeTextArr[0]+el+iframeTextArr[2];modalBody.prepend(data_iframe)}else modalBody.prepend($self.data("iframe"))}}).on("shown.bs.modal",function(){$("div.modal:visible").outerHeight(!0);var o=$("div.modal-header:visible").outerHeight(!0),e=$("div.modal-body:visible").outerHeight(!0),t=$("div.modal-body:visible").height(),n=$("div.modal-footer:visible").outerHeight(!0),a=$self.offsetTop,i=e-t,l=$(window).height()-2*a-(o+n+i);$self.data("url")&&($(".iframe").height()>l&&($(".modal-body").css({"max-height":l,"overflow-y":"auto"}),$(".iframe").css("max-height",l-i)))}).on("hide.bs.modal",function(){$(".modal-body").css({"max-height":"initial","overflow-y":"initial"}),$(".modalTooltip").tooltip("dispose")}).on("hidden.bs.modal",function(){Joomla.Modal.setCurrent("")})}),popover&&$.each(popover,function(o,e){e.constraints=[e.constraints],$(o).popover(e)}),scrollspy&&$.each(scrollspy,function(o,e){$("#"+o).scrollspy(e)}),tabs&&$.each(tabs,function(o,e){$.each($("#"+o+"Content").find(".tab-pane"),function(e,t){if($(t).data("node")){var n=$(t).data("node").split("["),a=""!=n[0]?'class="nav-link '+n[0]+'"':'class="nav-link"';$("#"+o+"Tabs").append('")}})}),tooltip&&$.each(tooltip,function(o,e){e.constraints=[e.constraints],$(o).tooltip(e).on("show.bs.tooltip",new Function(e.onShow)()).on("shown.bs.tooltip",new Function(e.onShown)()).on("hide.bs.tooltip",new Function(e.onHide)()).on("hidden.bs.tooltip",new Function(e.onHidden)())})})}(); \ No newline at end of file