1(function () { 2 'use strict'; 3 4 var selectors = { 5 title: '.accordion-title', 6 item: '.accordion-item', 7 inner: '.accordion-inner' 8 }; 9 10 var duration = 360; 11 var easing = 'cubic-bezier(0.4, 0, 0.2, 1)'; 12 13 function getPanel(title) { 14 var item = title.closest(selectors.item); 15 if (item) { 16 return item.querySelector(selectors.inner); 17 } 18 19 var next = title.nextElementSibling; 20 return next && next.matches(selectors.inner) ? next : null; 21 } 22 23 function getItem(title) { 24 return title.closest(selectors.item) || title.parentElement; 25 } 26 27 function isOpen(title, panel) { 28 return title.classList.contains('active') || panel.style.display !== 'none' && panel.offsetHeight > 0; 29 } 30 31 function setExpanded(title, panel, open) { 32 title.setAttribute('aria-expanded', open ? 'true' : 'false'); 33 panel.setAttribute('aria-hidden', open ? 'false' : 'true'); 34 } 35 36 function setTransition(panel) { 37 panel.style.transition = 'height ' + duration + 'ms ' + easing + ', opacity ' + duration + 'ms ease'; 38 panel.style.overflow = 'hidden'; 39 } 40 41 function clearPanel(panel, open) { 42 panel.style.transition = ''; 43 panel.style.height = ''; 44 panel.style.opacity = ''; 45 panel.style.overflow = ''; 46 panel.style.display = open ? 'block' : 'none'; 47 panel.dataset.smoothAccordionAnimating = ''; 48 } 49 50 function openPanel(title, panel) { 51 var item = getItem(title); 52 53 title.classList.add('active'); 54 setExpanded(title, panel, true); 55 if (item) { 56 item.classList.add('active'); 57 } 58 59 panel.dataset.smoothAccordionAnimating = '1'; 60 panel.style.display = 'block'; 61 panel.style.height = '0px'; 62 panel.style.opacity = '0'; 63 setTransition(panel); 64 65 requestAnimationFrame(function () { 66 panel.style.height = panel.scrollHeight + 'px'; 67 panel.style.opacity = '1'; 68 }); 69 70 window.setTimeout(function () { 71 clearPanel(panel, true); 72 }, duration + 40); 73 } 74 75 function closePanel(title, panel) { 76 var item = getItem(title); 77 78 title.classList.remove('active'); 79 setExpanded(title, panel, false); 80 if (item) { 81 item.classList.remove('active'); 82 } 83 84 panel.dataset.smoothAccordionAnimating = '1'; 85 panel.style.display = 'block'; 86 panel.style.height = panel.scrollHeight + 'px'; 87 panel.style.opacity = '1'; 88 setTransition(panel); 89 90 requestAnimationFrame(function () { 91 panel.style.height = '0px'; 92 panel.style.opacity = '0'; 93 }); 94 95 window.setTimeout(function () { 96 clearPanel(panel, false); 97 }, duration + 40); 98 } 99 100 function closeSiblingPanels(title) { 101 var accordion = title.closest('.accordion'); 102 103 if (!accordion || accordion.classList.contains('allow-multiple')) { 104 return; 105 } 106 107 accordion.querySelectorAll(selectors.title + '.active').forEach(function (activeTitle) { 108 var activePanel; 109 110 if (activeTitle === title) { 111 return; 112 } 113 114 activePanel = getPanel(activeTitle); 115 if (activePanel) { 116 closePanel(activeTitle, activePanel); 117 } 118 }); 119 } 120 121 function handleClick(event) { 122 var title = event.target.closest(selectors.title); 123 var panel; 124 125 if (!title || !document.body.contains(title)) { 126 return; 127 } 128 129 panel = getPanel(title); 130 if (!panel || panel.dataset.smoothAccordionAnimating === '1') { 131 return; 132 } 133 134 event.preventDefault(); 135 event.stopImmediatePropagation(); 136 137 if (isOpen(title, panel)) { 138 closePanel(title, panel); 139 } else { 140 closeSiblingPanels(title); 141 openPanel(title, panel); 142 } 143 } 144 145 function handleKeydown(event) { 146 var title; 147 148 if (event.key !== ' ' && event.key !== 'Spacebar') { 149 return; 150 } 151 152 title = event.target.closest(selectors.title); 153 if (!title) { 154 return; 155 } 156 157 event.preventDefault(); 158 title.click(); 159 } 160 161 function syncAriaState() { 162 document.querySelectorAll(selectors.title).forEach(function (title) { 163 var panel = getPanel(title); 164 if (panel) { 165 setExpanded(title, panel, isOpen(title, panel)); 166 } 167 }); 168 } 169 170 document.addEventListener('click', handleClick, true); 171 document.addEventListener('keydown', handleKeydown, true); 172 173 if (document.readyState === 'loading') { 174 document.addEventListener('DOMContentLoaded', syncAriaState); 175 } else { 176 syncAriaState(); 177 } 178}());
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.