1document.addEventListener('DOMContentLoaded', (event) => { 2 document.querySelectorAll('.btn-toggle, .btn-toggle-class').forEach(function (element) { 3 initButtonToggle(element); 4 }); 5}); 6 7function initButtonToggle(element) { 8 element.addEventListener('click', function (e) { 9 e.preventDefault(); 10 e.stopPropagation(); 11 12 const targetSelector = this.dataset.target; 13 let target; 14 15 if (targetSelector) { 16 if (targetSelector.startsWith('#')) { 17 target = document.getElementById(targetSelector.slice(1)); 18 } else { 19 target = document.querySelector(targetSelector); 20 } 21 } 22 23 target = target || this.nextElementSibling; 24 25 if (this.dataset.class) { 26 this.dataset.class.split(' ').forEach(function (dataClass) { 27 target.classList.toggle(dataClass); 28 }); 29 } else { 30 target.style.display = target.style.display === 'block' ? 'none' : 'block'; 31 } 32 33 const icons = this.dataset.icons || 'glyphicon-minus glyphicon-plus'; 34 const iconSelector = icons.split(' ').map(icon => '.' + icon).join(', '); 35 const iconElements = this.querySelectorAll(iconSelector); 36 37 iconElements.forEach(icon => { 38 icons.split(' ').forEach(function (iconClass) { 39 icon.classList.toggle(iconClass); 40 }); 41 }); 42 43 return false; 44 }); 45}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.