[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 /** 2 * @copyright (C) 2020 Open Source Matters, Inc. <https://www.joomla.org> 3 * @license GNU General Public License version 2 or later; see LICENSE.txt 4 */ 5 Joomla = window.Joomla || {}; 6 /** 7 * Method that switches a given class to the following elements of the element provided 8 * 9 * @param {HTMLElement} element The reference element 10 * @param {string} className The class name to be toggled 11 */ 12 13 Joomla.toggleAllNextElements = (element, className) => { 14 const getNextSiblings = el => { 15 const siblings = []; 16 /* eslint-disable no-cond-assign,no-param-reassign */ 17 18 do { 19 siblings.push(el); 20 } while ((el = el.nextElementSibling) !== null); 21 /* eslint-enable no-cond-assign,no-param-reassign */ 22 23 24 return siblings; 25 }; 26 27 const followingElements = getNextSiblings(element); 28 29 if (followingElements.length) { 30 followingElements.forEach(elem => { 31 if (elem.classList.contains(className)) { 32 elem.classList.remove(className); 33 } else { 34 elem.classList.add(className); 35 } 36 }); 37 } 38 }; 39 40 (() => { 41 42 document.addEventListener('DOMContentLoaded', () => { 43 const dropDownBtn = document.getElementById('toolbar-status-group'); 44 45 if (!dropDownBtn) { 46 return; 47 } 48 49 const transitions = [].slice.call(dropDownBtn.querySelectorAll('.button-transition')); 50 const headline = dropDownBtn.querySelector('.button-transition-headline'); 51 const separator = dropDownBtn.querySelector('.button-transition-separator'); 52 const itemList = document.querySelector('table.itemList'); 53 let itemListRows = []; 54 let transitionIds = []; 55 56 if (itemList) { 57 itemListRows = [].slice.call(itemList.querySelectorAll('tbody tr')); 58 } 59 60 function enableTransitions() { 61 if (transitionIds.length) { 62 let availableTrans = transitionIds.shift(); 63 64 while (transitionIds.length) { 65 const compareTrans = transitionIds.shift(); 66 availableTrans = availableTrans.filter(id => compareTrans.indexOf(id) !== -1); 67 } 68 69 if (availableTrans.length) { 70 if (headline) { 71 headline.classList.remove('d-none'); 72 } 73 74 if (separator) { 75 separator.classList.remove('d-none'); 76 } 77 } 78 79 availableTrans.forEach(trans => { 80 const elem = dropDownBtn.querySelector(`.transition-$trans}`); 81 82 if (elem) { 83 elem.parentNode.classList.remove('d-none'); 84 } 85 }); 86 } 87 } // check for common attributes for which the conditions for a transition are possible or not 88 // and save this information in a boolean variable. 89 90 91 function collectTransitions(row) { 92 transitionIds.push(row.getAttribute('data-transitions').split(',')); 93 } // listen to click event to get selected rows 94 95 96 if (itemList) { 97 itemList.addEventListener('click', () => { 98 transitions.forEach(trans => { 99 trans.parentNode.classList.add('d-none'); 100 }); 101 102 if (headline) { 103 headline.classList.add('d-none'); 104 } 105 106 if (separator) { 107 separator.classList.add('d-none'); 108 } 109 110 transitionIds = []; 111 itemListRows.forEach(el => { 112 const checkedBox = el.querySelector('input[type=checkbox]'); 113 114 if (checkedBox.checked) { 115 const parentTr = checkedBox.closest('tr'); 116 collectTransitions(parentTr); 117 } 118 }); 119 enableTransitions(); 120 }); 121 } 122 }); 123 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |