primo commit
This commit is contained in:
101
media/com_menus/js/admin-item-edit.js
Normal file
101
media/com_menus/js/admin-item-edit.js
Normal file
@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
if (!window.Joomla) {
|
||||
throw new Error('core.js was not properly initialised');
|
||||
}
|
||||
Joomla.submitbutton = (task, type) => {
|
||||
if (task === 'item.setType' || task === 'item.setMenuType') {
|
||||
if (task === 'item.setType') {
|
||||
document.querySelectorAll('#item-form input[name="jform[type]"]').forEach(item => {
|
||||
item.value = type;
|
||||
});
|
||||
document.getElementById('fieldtype').value = 'type';
|
||||
} else {
|
||||
document.querySelectorAll('#item-form input[name="jform[menutype]"]').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 = document.querySelectorAll('#item-form .modal-value.invalid');
|
||||
list.forEach(field => {
|
||||
const textInput = field.parentElement.querySelector('.js-input-title, [type="text"]');
|
||||
textInput.classList.add('invalid');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Listen to "joomla:content-select-menutype" message
|
||||
window.addEventListener('message', event => {
|
||||
// Avoid cross origins
|
||||
if (event.origin !== window.location.origin) return;
|
||||
// Check message type
|
||||
if (event.data.messageType === 'joomla:content-select-menutype') {
|
||||
// Set and submit values
|
||||
Joomla.submitbutton('item.setType', event.data.encoded);
|
||||
}
|
||||
});
|
||||
const onChange = ({
|
||||
target
|
||||
}) => {
|
||||
const menuType = 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 fancySelect = document.getElementById('jform_parent_id').closest('joomla-field-fancy-select');
|
||||
fancySelect.choicesInstance.clearChoices();
|
||||
fancySelect.choicesInstance.setChoices([{
|
||||
id: '1',
|
||||
text: Joomla.Text._('JGLOBAL_ROOT_PARENT')
|
||||
}], 'id', 'text', false);
|
||||
data.forEach(value => {
|
||||
const option = {};
|
||||
option.innerText = value.title;
|
||||
option.id = value.id;
|
||||
fancySelect.choicesInstance.setChoices([option], 'id', 'innerText', false);
|
||||
});
|
||||
fancySelect.choicesInstance.setChoiceByValue('1');
|
||||
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 element = document.getElementById('jform_menutype');
|
||||
if (element) {
|
||||
element.addEventListener('change', onChange);
|
||||
}
|
||||
|
||||
// Menu type Login Form specific
|
||||
document.getElementById('item-form').addEventListener('submit', () => {
|
||||
if (document.getElementById('jform_params_login_redirect_url') && document.getElementById('jform_params_logout_redirect_url')) {
|
||||
// Login
|
||||
if (!document.getElementById('jform_params_login_redirect_url').closest('.control-group').classList.contains('hidden')) {
|
||||
document.getElementById('jform_params_login_redirect_menuitem_id').value = '';
|
||||
}
|
||||
if (!document.getElementById('jform_params_login_redirect_menuitem_name').closest('.control-group').classList.contains('hidden')) {
|
||||
document.getElementById('jform_params_login_redirect_url').value = '';
|
||||
}
|
||||
|
||||
// Logout
|
||||
if (!document.getElementById('jform_params_logout_redirect_url').closest('.control-group').classList.contains('hidden')) {
|
||||
document.getElementById('jform_params_logout_redirect_menuitem_id').value = '';
|
||||
}
|
||||
if (!document.getElementById('jform_params_logout_redirect_menuitem_id').closest('.control-group').classList.contains('hidden')) {
|
||||
document.getElementById('jform_params_logout_redirect_url').value = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
4
media/com_menus/js/admin-item-edit.min.js
vendored
Normal file
4
media/com_menus/js/admin-item-edit.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/if(!window.Joomla)throw new Error("core.js was not properly initialised");Joomla.submitbutton=(e,n)=>{e==="item.setType"||e==="item.setMenuType"?(e==="item.setType"?(document.querySelectorAll('#item-form input[name="jform[type]"]').forEach(t=>{t.value=n}),document.getElementById("fieldtype").value="type"):document.querySelectorAll('#item-form input[name="jform[menutype]"]').forEach(t=>{t.value=n}),Joomla.submitform("item.setType",document.getElementById("item-form"))):e==="item.cancel"||document.formvalidator.isValid(document.getElementById("item-form"))?Joomla.submitform(e,document.getElementById("item-form")):document.querySelectorAll("#item-form .modal-value.invalid").forEach(m=>{m.parentElement.querySelector('.js-input-title, [type="text"]').classList.add("invalid")})},window.addEventListener("message",e=>{e.origin===window.location.origin&&e.data.messageType==="joomla:content-select-menutype"&&Joomla.submitbutton("item.setType",e.data.encoded)});const onChange=({target:e})=>{const n=e.value;Joomla.request({url:`index.php?option=com_menus&task=item.getParentItem&menutype=${n}`,headers:{"Content-Type":"application/json"},onSuccess(t){const m=JSON.parse(t),o=document.getElementById("jform_parent_id").closest("joomla-field-fancy-select");o.choicesInstance.clearChoices(),o.choicesInstance.setChoices([{id:"1",text:Joomla.Text._("JGLOBAL_ROOT_PARENT")}],"id","text",!1),m.forEach(l=>{const i={};i.innerText=l.title,i.id=l.id,o.choicesInstance.setChoices([i],"id","innerText",!1)}),o.choicesInstance.setChoiceByValue("1");const r=document.createEvent("HTMLEvents");r.initEvent("change",!0,!1),document.getElementById("jform_parent_id").dispatchEvent(r)},onError:t=>{Joomla.renderMessages(Joomla.ajaxErrorsMessages(t))}})},element=document.getElementById("jform_menutype");element&&element.addEventListener("change",onChange),document.getElementById("item-form").addEventListener("submit",()=>{document.getElementById("jform_params_login_redirect_url")&&document.getElementById("jform_params_logout_redirect_url")&&(document.getElementById("jform_params_login_redirect_url").closest(".control-group").classList.contains("hidden")||(document.getElementById("jform_params_login_redirect_menuitem_id").value=""),document.getElementById("jform_params_login_redirect_menuitem_name").closest(".control-group").classList.contains("hidden")||(document.getElementById("jform_params_login_redirect_url").value=""),document.getElementById("jform_params_logout_redirect_url").closest(".control-group").classList.contains("hidden")||(document.getElementById("jform_params_logout_redirect_menuitem_id").value=""),document.getElementById("jform_params_logout_redirect_menuitem_id").closest(".control-group").classList.contains("hidden")||(document.getElementById("jform_params_logout_redirect_url").value=""))});
|
||||
BIN
media/com_menus/js/admin-item-edit.min.js.gz
Normal file
BIN
media/com_menus/js/admin-item-edit.min.js.gz
Normal file
Binary file not shown.
37
media/com_menus/js/admin-item-edit_container.js
Normal file
37
media/com_menus/js/admin-item-edit_container.js
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
(document => {
|
||||
const isChecked = element => element.checked;
|
||||
const getTreeElements = element => element.querySelectorAll('input[type="checkbox"]');
|
||||
const getTreeRoot = element => element.parentElement.nextElementSibling;
|
||||
const check = element => {
|
||||
element.checked = true;
|
||||
};
|
||||
const uncheck = element => {
|
||||
element.checked = false;
|
||||
};
|
||||
const disable = element => element.setAttribute('disabled', 'disabled');
|
||||
const enable = element => element.removeAttribute('disabled');
|
||||
const toggleState = (element, rootChecked) => {
|
||||
if (rootChecked === true) {
|
||||
disable(element);
|
||||
check(element);
|
||||
return;
|
||||
}
|
||||
enable(element);
|
||||
uncheck(element);
|
||||
};
|
||||
const switchState = ({
|
||||
target
|
||||
}) => {
|
||||
const root = getTreeRoot(target);
|
||||
const selfChecked = isChecked(target);
|
||||
if (root) {
|
||||
getTreeElements(root).forEach(element => toggleState(element, selfChecked));
|
||||
}
|
||||
};
|
||||
document.querySelectorAll('.treeselect input[type="checkbox"]').forEach(checkbox => checkbox.addEventListener('click', switchState));
|
||||
})(document);
|
||||
4
media/com_menus/js/admin-item-edit_container.min.js
vendored
Normal file
4
media/com_menus/js/admin-item-edit_container.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/(c=>{const o=e=>e.checked,s=e=>e.querySelectorAll('input[type="checkbox"]'),n=e=>e.parentElement.nextElementSibling,r=e=>{e.checked=!0},l=e=>{e.checked=!1},i=e=>e.setAttribute("disabled","disabled"),d=e=>e.removeAttribute("disabled"),h=(e,t)=>{if(t===!0){i(e),r(e);return}d(e),l(e)},a=({target:e})=>{const t=n(e),u=o(e);t&&s(t).forEach(b=>h(b,u))};c.querySelectorAll('.treeselect input[type="checkbox"]').forEach(e=>e.addEventListener("click",a))})(document);
|
||||
BIN
media/com_menus/js/admin-item-edit_container.min.js.gz
Normal file
BIN
media/com_menus/js/admin-item-edit_container.min.js.gz
Normal file
Binary file not shown.
165
media/com_menus/js/admin-item-edit_modules.js
Normal file
165
media/com_menus/js/admin-item-edit_modules.js
Normal file
@ -0,0 +1,165 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
const options = Joomla.getOptions('menus-edit-modules', {});
|
||||
const viewLevels = options.viewLevels || [];
|
||||
const menuId = options.itemId || 0;
|
||||
const assigned1 = document.getElementById('jform_toggle_modules_assigned1');
|
||||
const assigned0 = document.getElementById('jform_toggle_modules_assigned0');
|
||||
const published1 = document.getElementById('jform_toggle_modules_published1');
|
||||
const published0 = document.getElementById('jform_toggle_modules_published0');
|
||||
if (assigned1) {
|
||||
assigned1.addEventListener('click', () => {
|
||||
document.querySelectorAll('tr.no').forEach(item => {
|
||||
item.classList.add('table-row');
|
||||
item.classList.remove('hidden');
|
||||
});
|
||||
});
|
||||
}
|
||||
if (assigned0) {
|
||||
assigned0.addEventListener('click', () => {
|
||||
document.querySelectorAll('tr.no').forEach(item => {
|
||||
item.classList.add('hidden');
|
||||
item.classList.remove('table-row');
|
||||
});
|
||||
});
|
||||
}
|
||||
if (published1) {
|
||||
published1.addEventListener('click', () => {
|
||||
document.querySelectorAll('.table tr.unpublished').forEach(item => {
|
||||
item.classList.add('table-row');
|
||||
item.classList.remove('hidden');
|
||||
});
|
||||
});
|
||||
}
|
||||
if (published0) {
|
||||
published0.addEventListener('click', () => {
|
||||
document.querySelectorAll('.table tr.unpublished').forEach(item => {
|
||||
item.classList.add('hidden');
|
||||
item.classList.remove('table-row');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper to create an element
|
||||
* @param {String} tag
|
||||
* @param {String} content
|
||||
* @param {Array} classList
|
||||
* @returns {HTMLElement}
|
||||
*/
|
||||
const createElement = (tag, content, classList = []) => {
|
||||
const el = document.createElement(tag);
|
||||
el.textContent = content;
|
||||
if (classList.length) {
|
||||
el.classList.add(...classList);
|
||||
}
|
||||
return el;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update module in list
|
||||
* @param {Object} data
|
||||
*/
|
||||
const updateView = data => {
|
||||
const modId = data.id;
|
||||
const updPosition = data.position;
|
||||
const updTitle = data.title;
|
||||
const updMenus = data.assignment;
|
||||
const updStatus = data.status;
|
||||
const updAccess = data.access;
|
||||
const tmpMenu = document.getElementById(`menus-${modId}`);
|
||||
const tmpRow = document.getElementById(`tr-${modId}`);
|
||||
const tmpStatus = document.getElementById(`status-${modId}`);
|
||||
const assigned = data.assigned || [];
|
||||
const inMenus = assigned.map(v => Math.abs(v));
|
||||
const inAssignedList = inMenus.indexOf(menuId);
|
||||
let assignedState = 0; // 0 = No, 1 = Yes, 2 = All
|
||||
|
||||
// Update assignment badge
|
||||
if (updMenus === '-') {
|
||||
assignedState = 0;
|
||||
} else if (updMenus === 0) {
|
||||
assignedState = 2;
|
||||
} else if (updMenus > 0) {
|
||||
if (inAssignedList >= 0) {
|
||||
assignedState = 1;
|
||||
} else if (inAssignedList < 0) {
|
||||
assignedState = 0;
|
||||
}
|
||||
} else if (updMenus < 0) {
|
||||
if (inAssignedList >= 0) {
|
||||
assignedState = 0;
|
||||
} else if (inAssignedList < 0) {
|
||||
assignedState = 1;
|
||||
}
|
||||
}
|
||||
switch (assignedState) {
|
||||
case 1:
|
||||
tmpMenu.innerHTML = createElement('span', Joomla.Text._('JYES'), ['badge', 'bg-success']).outerHTML;
|
||||
tmpRow.classList.add('no');
|
||||
break;
|
||||
case 2:
|
||||
tmpMenu.innerHTML = createElement('span', Joomla.Text._('JALL'), ['badge', 'bg-info']).outerHTML;
|
||||
tmpRow.classList.add('no');
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
tmpMenu.innerHTML = createElement('span', Joomla.Text._('JNO'), ['badge', 'bg-danger']).outerHTML;
|
||||
tmpRow.classList.add('no');
|
||||
}
|
||||
|
||||
// Update status
|
||||
if (updStatus === 1) {
|
||||
tmpStatus.innerHTML = createElement('span', Joomla.Text._('JYES'), ['badge', 'bg-success']).outerHTML;
|
||||
tmpRow.classList.remove('unpublished');
|
||||
} else if (updStatus === 0) {
|
||||
tmpStatus.innerHTML = createElement('span', Joomla.Text._('JNO'), ['badge', 'bg-danger']).outerHTML;
|
||||
tmpRow.classList.add('unpublished');
|
||||
} else if (updStatus === -2) {
|
||||
tmpStatus.innerHTML = createElement('span', Joomla.Text._('JTRASHED'), ['badge', 'bg-secondary']).outerHTML;
|
||||
tmpRow.classList.add('unpublished');
|
||||
}
|
||||
|
||||
// Update Title, Position and Access
|
||||
document.querySelector(`#title-${modId}`).textContent = updTitle;
|
||||
document.querySelector(`#position-${modId}`).textContent = updPosition;
|
||||
document.querySelector(`#access-${modId}`).textContent = viewLevels[updAccess] || '';
|
||||
};
|
||||
|
||||
/**
|
||||
* Message listener
|
||||
* @param {MessageEvent} event
|
||||
*/
|
||||
const msgListener = function msgListener(event) {
|
||||
// Avoid cross origins
|
||||
if (event.origin !== window.location.origin) return;
|
||||
// Check message
|
||||
if (event.data.messageType === 'joomla:content-select' && event.data.contentType === 'com_modules.module') {
|
||||
// Update view, if there are any changes
|
||||
if (event.data.id) {
|
||||
updateView(event.data);
|
||||
}
|
||||
// Close dialog
|
||||
this.close();
|
||||
}
|
||||
};
|
||||
|
||||
// Listen when "add module" dialog opens, and add message listener
|
||||
document.addEventListener('joomla-dialog:open', ({
|
||||
target
|
||||
}) => {
|
||||
if (!target.classList.contains('menus-dialog-module-editing')) return;
|
||||
// Create a listener with current dialog context
|
||||
const listener = msgListener.bind(target);
|
||||
|
||||
// Wait for a message
|
||||
window.addEventListener('message', listener);
|
||||
|
||||
// Remove listener on close
|
||||
target.addEventListener('joomla-dialog:close', () => {
|
||||
window.removeEventListener('message', listener);
|
||||
});
|
||||
});
|
||||
4
media/com_menus/js/admin-item-edit_modules.min.js
vendored
Normal file
4
media/com_menus/js/admin-item-edit_modules.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/const options=Joomla.getOptions("menus-edit-modules",{}),viewLevels=options.viewLevels||[],menuId=options.itemId||0,assigned1=document.getElementById("jform_toggle_modules_assigned1"),assigned0=document.getElementById("jform_toggle_modules_assigned0"),published1=document.getElementById("jform_toggle_modules_published1"),published0=document.getElementById("jform_toggle_modules_published0");assigned1&&assigned1.addEventListener("click",()=>{document.querySelectorAll("tr.no").forEach(e=>{e.classList.add("table-row"),e.classList.remove("hidden")})}),assigned0&&assigned0.addEventListener("click",()=>{document.querySelectorAll("tr.no").forEach(e=>{e.classList.add("hidden"),e.classList.remove("table-row")})}),published1&&published1.addEventListener("click",()=>{document.querySelectorAll(".table tr.unpublished").forEach(e=>{e.classList.add("table-row"),e.classList.remove("hidden")})}),published0&&published0.addEventListener("click",()=>{document.querySelectorAll(".table tr.unpublished").forEach(e=>{e.classList.add("hidden"),e.classList.remove("table-row")})});const createElement=(e,s,d=[])=>{const o=document.createElement(e);return o.textContent=s,d.length&&o.classList.add(...d),o},updateView=e=>{const s=e.id,d=e.position,o=e.title,i=e.assignment,c=e.status,r=e.access,a=document.getElementById(`menus-${s}`),n=document.getElementById(`tr-${s}`),u=document.getElementById(`status-${s}`),l=(e.assigned||[]).map(m=>Math.abs(m)).indexOf(menuId);let t=0;switch(i==="-"?t=0:i===0?t=2:i>0?l>=0?t=1:l<0&&(t=0):i<0&&(l>=0?t=0:l<0&&(t=1)),t){case 1:a.innerHTML=createElement("span",Joomla.Text._("JYES"),["badge","bg-success"]).outerHTML,n.classList.add("no");break;case 2:a.innerHTML=createElement("span",Joomla.Text._("JALL"),["badge","bg-info"]).outerHTML,n.classList.add("no");break;case 0:default:a.innerHTML=createElement("span",Joomla.Text._("JNO"),["badge","bg-danger"]).outerHTML,n.classList.add("no")}c===1?(u.innerHTML=createElement("span",Joomla.Text._("JYES"),["badge","bg-success"]).outerHTML,n.classList.remove("unpublished")):c===0?(u.innerHTML=createElement("span",Joomla.Text._("JNO"),["badge","bg-danger"]).outerHTML,n.classList.add("unpublished")):c===-2&&(u.innerHTML=createElement("span",Joomla.Text._("JTRASHED"),["badge","bg-secondary"]).outerHTML,n.classList.add("unpublished")),document.querySelector(`#title-${s}`).textContent=o,document.querySelector(`#position-${s}`).textContent=d,document.querySelector(`#access-${s}`).textContent=viewLevels[r]||""},msgListener=function(s){s.origin===window.location.origin&&s.data.messageType==="joomla:content-select"&&s.data.contentType==="com_modules.module"&&(s.data.id&&updateView(s.data),this.close())};document.addEventListener("joomla-dialog:open",({target:e})=>{if(!e.classList.contains("menus-dialog-module-editing"))return;const s=msgListener.bind(e);window.addEventListener("message",s),e.addEventListener("joomla-dialog:close",()=>{window.removeEventListener("message",s)})});
|
||||
BIN
media/com_menus/js/admin-item-edit_modules.min.js.gz
Normal file
BIN
media/com_menus/js/admin-item-edit_modules.min.js.gz
Normal file
Binary file not shown.
17
media/com_menus/js/admin-item-modal.js
Normal file
17
media/com_menus/js/admin-item-modal.js
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
window.Joomla = window.Joomla || {};
|
||||
Joomla.setMenuType = (type, tmpl) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('Method Joomla.setMenuType() is deprecated. Use "modal-content-select" asset and elements with [data-content-select] attribute.');
|
||||
if (tmpl !== '') {
|
||||
window.parent.Joomla.submitbutton('item.setType', type);
|
||||
if (window.parent.Joomla.Modal && window.parent.Joomla.Modal.getCurrent()) {
|
||||
window.parent.Joomla.Modal.getCurrent().close();
|
||||
}
|
||||
} else {
|
||||
window.location = `index.php?option=com_menus&view=item&task=item.setType&layout=edit&type=${type}`;
|
||||
}
|
||||
};
|
||||
4
media/com_menus/js/admin-item-modal.min.js
vendored
Normal file
4
media/com_menus/js/admin-item-modal.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/window.Joomla=window.Joomla||{},Joomla.setMenuType=(e,o)=>{console.warn('Method Joomla.setMenuType() is deprecated. Use "modal-content-select" asset and elements with [data-content-select] attribute.'),o!==""?(window.parent.Joomla.submitbutton("item.setType",e),window.parent.Joomla.Modal&&window.parent.Joomla.Modal.getCurrent()&&window.parent.Joomla.Modal.getCurrent().close()):window.location=`index.php?option=com_menus&view=item&task=item.setType&layout=edit&type=${e}`};
|
||||
BIN
media/com_menus/js/admin-item-modal.min.js.gz
Normal file
BIN
media/com_menus/js/admin-item-modal.min.js.gz
Normal file
Binary file not shown.
62
media/com_menus/js/admin-items-modal.js
Normal file
62
media/com_menus/js/admin-items-modal.js
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
((Joomla, document) => {
|
||||
|
||||
/**
|
||||
* Javascript to insert the link
|
||||
* View element calls jSelectContact when a contact is clicked
|
||||
* jSelectContact creates the link tag, sends it to the editor,
|
||||
* and closes the select frame.
|
||||
*/
|
||||
window.jSelectMenuItem = (id, title, uri, object, link, lang) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('Method jSelectMenuItem() is deprecated. Use postMessage() instead.');
|
||||
let thislang = '';
|
||||
if (!Joomla.getOptions('xtd-menus')) {
|
||||
// Something went wrong!
|
||||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
const editor = Joomla.getOptions('xtd-menus').editor;
|
||||
if (lang !== '') {
|
||||
thislang = '&lang=';
|
||||
}
|
||||
const tag = `<a href="${uri + thislang + lang}">${title}</a>`;
|
||||
|
||||
// Insert the link in the editor
|
||||
if (window.parent.Joomla.editors.instances[editor].getSelection()) {
|
||||
window.parent.Joomla.editors.instances[editor].replaceSelection(`<a href="${uri + thislang + lang}">${window.parent.Joomla.editors.instances[editor].getSelection()}</a>`);
|
||||
} else {
|
||||
window.parent.Joomla.editors.instances[editor].replaceSelection(tag);
|
||||
}
|
||||
|
||||
// Close the modal
|
||||
if (window.parent.Joomla.Modal && window.parent.Joomla.Modal.getCurrent()) {
|
||||
window.parent.Joomla.Modal.getCurrent().close();
|
||||
}
|
||||
};
|
||||
|
||||
// Get the elements
|
||||
document.querySelectorAll('.select-link').forEach(element => {
|
||||
// Listen for click event
|
||||
element.addEventListener('click', event => {
|
||||
event.preventDefault();
|
||||
const functionName = event.target.getAttribute('data-function');
|
||||
if (functionName === 'jSelectMenuItem' && window[functionName]) {
|
||||
// Used in xtd_contacts
|
||||
window[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), event.target.getAttribute('data-uri'), null, null, event.target.getAttribute('data-language'));
|
||||
} else if (window.parent[functionName]) {
|
||||
// Used in com_menus
|
||||
window.parent[functionName](event.target.getAttribute('data-id'), event.target.getAttribute('data-title'), null, null, event.target.getAttribute('data-uri'), event.target.getAttribute('data-language'), null);
|
||||
}
|
||||
|
||||
// Close the modal
|
||||
if (window.parent.Joomla.Modal && window.parent.Joomla.Modal.getCurrent()) {
|
||||
window.parent.Joomla.Modal.getCurrent().close();
|
||||
}
|
||||
});
|
||||
});
|
||||
})(Joomla, document);
|
||||
4
media/com_menus/js/admin-items-modal.min.js
vendored
Normal file
4
media/com_menus/js/admin-items-modal.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/((i,l)=>{window.jSelectMenuItem=(r,t,e,s,g,o)=>{console.warn("Method jSelectMenuItem() is deprecated. Use postMessage() instead.");let n="";if(!i.getOptions("xtd-menus"))return;const a=i.getOptions("xtd-menus").editor;o!==""&&(n="&lang=");const d=`<a href="${e+n+o}">${t}</a>`;window.parent.Joomla.editors.instances[a].getSelection()?window.parent.Joomla.editors.instances[a].replaceSelection(`<a href="${e+n+o}">${window.parent.Joomla.editors.instances[a].getSelection()}</a>`):window.parent.Joomla.editors.instances[a].replaceSelection(d),window.parent.Joomla.Modal&&window.parent.Joomla.Modal.getCurrent()&&window.parent.Joomla.Modal.getCurrent().close()},l.querySelectorAll(".select-link").forEach(r=>{r.addEventListener("click",t=>{t.preventDefault();const e=t.target.getAttribute("data-function");e==="jSelectMenuItem"&&window[e]?window[e](t.target.getAttribute("data-id"),t.target.getAttribute("data-title"),t.target.getAttribute("data-uri"),null,null,t.target.getAttribute("data-language")):window.parent[e]&&window.parent[e](t.target.getAttribute("data-id"),t.target.getAttribute("data-title"),null,null,t.target.getAttribute("data-uri"),t.target.getAttribute("data-language"),null),window.parent.Joomla.Modal&&window.parent.Joomla.Modal.getCurrent()&&window.parent.Joomla.Modal.getCurrent().close()})})})(Joomla,document);
|
||||
BIN
media/com_menus/js/admin-items-modal.min.js.gz
Normal file
BIN
media/com_menus/js/admin-items-modal.min.js.gz
Normal file
Binary file not shown.
21
media/com_menus/js/admin-menus-default.js
Normal file
21
media/com_menus/js/admin-menus-default.js
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
if (Joomla.getOptions('menus-default')) {
|
||||
const items = Joomla.getOptions('menus-default', {}).items || [];
|
||||
items.forEach(item => {
|
||||
window[`jSelectPosition_${item}`] = name => {
|
||||
document.getElementById(item).value = name;
|
||||
Joomla.Modal.getCurrent().close();
|
||||
};
|
||||
});
|
||||
}
|
||||
const originalFn = Joomla.submitform;
|
||||
Joomla.submitform = (task, form) => {
|
||||
originalFn(task, form);
|
||||
if (task === 'menu.exportXml') {
|
||||
document.adminForm.task.value = '';
|
||||
}
|
||||
};
|
||||
4
media/com_menus/js/admin-menus-default.min.js
vendored
Normal file
4
media/com_menus/js/admin-menus-default.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/Joomla.getOptions("menus-default")&&(Joomla.getOptions("menus-default",{}).items||[]).forEach(o=>{window[`jSelectPosition_${o}`]=t=>{document.getElementById(o).value=t,Joomla.Modal.getCurrent().close()}});const originalFn=Joomla.submitform;Joomla.submitform=(e,o)=>{originalFn(e,o),e==="menu.exportXml"&&(document.adminForm.task.value="")};
|
||||
BIN
media/com_menus/js/admin-menus-default.min.js.gz
Normal file
BIN
media/com_menus/js/admin-menus-default.min.js.gz
Normal file
Binary file not shown.
22
media/com_menus/js/default-batch-body.js
Normal file
22
media/com_menus/js/default-batch-body.js
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
(document => {
|
||||
const batchMenu = document.getElementById('batch-menu-id');
|
||||
const batchCopyMove = document.getElementById('batch-copy-move');
|
||||
let batchSelector;
|
||||
const onChange = () => {
|
||||
if (batchSelector.value !== 0 || batchSelector.value !== '') {
|
||||
batchCopyMove.classList.remove('hidden');
|
||||
} else {
|
||||
batchCopyMove.classList.add('hidden');
|
||||
}
|
||||
};
|
||||
if (batchMenu) {
|
||||
batchSelector = batchMenu;
|
||||
}
|
||||
if (batchCopyMove) {
|
||||
batchSelector.addEventListener('change', onChange);
|
||||
}
|
||||
})(document);
|
||||
4
media/com_menus/js/default-batch-body.min.js
vendored
Normal file
4
media/com_menus/js/default-batch-body.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/(n=>{const a=n.getElementById("batch-menu-id"),t=n.getElementById("batch-copy-move");let e;const c=()=>{e.value!==0||e.value!==""?t.classList.remove("hidden"):t.classList.add("hidden")};a&&(e=a),t&&e.addEventListener("change",c)})(document);
|
||||
BIN
media/com_menus/js/default-batch-body.min.js.gz
Normal file
BIN
media/com_menus/js/default-batch-body.min.js.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user