primo commit
This commit is contained in:
21
media/com_workflow/joomla.asset.json
Normal file
21
media/com_workflow/joomla.asset.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
|
||||
"name": "com_workflow",
|
||||
"version": "4.0.0",
|
||||
"description": "Joomla CMS",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"assets": [
|
||||
{
|
||||
"name": "com_workflow.admin-items-workflow-buttons",
|
||||
"type": "script",
|
||||
"uri": "com_workflow/admin-items-workflow-buttons.min.js",
|
||||
"dependencies": [
|
||||
"core"
|
||||
],
|
||||
"attributes": {
|
||||
"type": "module"
|
||||
},
|
||||
"version": "34dbe2"
|
||||
}
|
||||
]
|
||||
}
|
||||
104
media/com_workflow/js/admin-items-workflow-buttons.js
Normal file
104
media/com_workflow/js/admin-items-workflow-buttons.js
Normal file
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
Joomla = window.Joomla || {};
|
||||
|
||||
/**
|
||||
* Method that switches a given class to the following elements of the element provided
|
||||
*
|
||||
* @param {HTMLElement} element The reference element
|
||||
* @param {string} className The class name to be toggled
|
||||
*/
|
||||
Joomla.toggleAllNextElements = (element, className) => {
|
||||
const getNextSiblings = el => {
|
||||
const siblings = [];
|
||||
/* eslint-disable no-cond-assign,no-param-reassign */
|
||||
do {
|
||||
siblings.push(el);
|
||||
} while ((el = el.nextElementSibling) !== null);
|
||||
/* eslint-enable no-cond-assign,no-param-reassign */
|
||||
return siblings;
|
||||
};
|
||||
const followingElements = getNextSiblings(element);
|
||||
if (followingElements.length) {
|
||||
followingElements.forEach(elem => {
|
||||
if (elem.classList.contains(className)) {
|
||||
elem.classList.remove(className);
|
||||
} else {
|
||||
elem.classList.add(className);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
(() => {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const dropDownBtn = document.getElementById('toolbar-status-group');
|
||||
if (!dropDownBtn) {
|
||||
return;
|
||||
}
|
||||
const headline = dropDownBtn.querySelector('.button-transition-headline');
|
||||
const separator = dropDownBtn.querySelector('.button-transition-separator');
|
||||
const itemList = document.querySelector('table.itemList');
|
||||
let itemListRows = [];
|
||||
let transitionIds = [];
|
||||
if (itemList) {
|
||||
itemListRows = itemList.querySelectorAll('tbody tr');
|
||||
}
|
||||
function enableTransitions() {
|
||||
if (transitionIds.length) {
|
||||
let availableTrans = transitionIds.shift();
|
||||
while (transitionIds.length) {
|
||||
const compareTrans = transitionIds.shift();
|
||||
availableTrans = availableTrans.filter(id => compareTrans.indexOf(id) !== -1);
|
||||
}
|
||||
if (availableTrans.length) {
|
||||
if (headline) {
|
||||
headline.classList.remove('d-none');
|
||||
}
|
||||
if (separator) {
|
||||
separator.classList.remove('d-none');
|
||||
}
|
||||
}
|
||||
availableTrans.forEach(trans => {
|
||||
const elem = dropDownBtn.querySelector(`.transition-${trans}`);
|
||||
if (elem) {
|
||||
elem.parentNode.classList.remove('d-none');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// check for common attributes for which the conditions for a transition are possible or not
|
||||
// and save this information in a boolean variable.
|
||||
function collectTransitions(row) {
|
||||
transitionIds.push(row.getAttribute('data-transitions').split(','));
|
||||
}
|
||||
|
||||
// listen to click event to get selected rows
|
||||
if (itemList) {
|
||||
itemList.addEventListener('click', () => {
|
||||
dropDownBtn.querySelectorAll('.button-transition').forEach(trans => {
|
||||
trans.parentNode.classList.add('d-none');
|
||||
});
|
||||
if (headline) {
|
||||
headline.classList.add('d-none');
|
||||
}
|
||||
if (separator) {
|
||||
separator.classList.add('d-none');
|
||||
}
|
||||
transitionIds = [];
|
||||
itemListRows.forEach(el => {
|
||||
const checkedBox = el.querySelector('input[type=checkbox]');
|
||||
if (checkedBox.checked) {
|
||||
const parentTr = checkedBox.closest('tr');
|
||||
collectTransitions(parentTr);
|
||||
}
|
||||
});
|
||||
enableTransitions();
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
4
media/com_workflow/js/admin-items-workflow-buttons.min.js
vendored
Normal file
4
media/com_workflow/js/admin-items-workflow-buttons.min.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/Joomla=window.Joomla||{},Joomla.toggleAllNextElements=(s,o)=>{const i=(t=>{const n=[];do n.push(t);while((t=t.nextElementSibling)!==null);return n})(s);i.length&&i.forEach(t=>{t.classList.contains(o)?t.classList.remove(o):t.classList.add(o)})},document.addEventListener("DOMContentLoaded",()=>{const s=document.getElementById("toolbar-status-group");if(!s)return;const o=s.querySelector(".button-transition-headline"),a=s.querySelector(".button-transition-separator"),i=document.querySelector("table.itemList");let t=[],n=[];i&&(t=i.querySelectorAll("tbody tr"));function c(){if(n.length){let e=n.shift();for(;n.length;){const l=n.shift();e=e.filter(r=>l.indexOf(r)!==-1)}e.length&&(o&&o.classList.remove("d-none"),a&&a.classList.remove("d-none")),e.forEach(l=>{const r=s.querySelector(`.transition-${l}`);r&&r.parentNode.classList.remove("d-none")})}}function d(e){n.push(e.getAttribute("data-transitions").split(","))}i&&i.addEventListener("click",()=>{s.querySelectorAll(".button-transition").forEach(e=>{e.parentNode.classList.add("d-none")}),o&&o.classList.add("d-none"),a&&a.classList.add("d-none"),n=[],t.forEach(e=>{const l=e.querySelector("input[type=checkbox]");if(l.checked){const r=l.closest("tr");d(r)}}),c()})});
|
||||
BIN
media/com_workflow/js/admin-items-workflow-buttons.min.js.gz
Normal file
BIN
media/com_workflow/js/admin-items-workflow-buttons.min.js.gz
Normal file
Binary file not shown.
Reference in New Issue
Block a user