- md5
- ccd53bffca95b442ce5c5c4bdec70b73
- sha1
- 79fe41483186d3a86a02b5871f6250f3bbddc0e1
- sha256
- d4c836409fb73b10155083da1d1fa1e54d32eb091dabee7b38fd1227b93426ef
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
/**
* @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 transitions = [].slice.call(dropDownBtn.querySelectorAll('.button-transition'));
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 = [].slice.call(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', () => {
transitions.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();
});
}
});
})();
The same content is in 79 releases, Joomla 4.3.0-alpha1 to 5.1.0-beta1. See them all, or every version of this file.