1(() => { 2 // accordion/src/view.tsx 3 var updateSizes = function() { 4 document.querySelectorAll(".wp-block-mytheme-collapser").forEach( 5 /** @param {HTMLElement} el */ 6 function(el) { 7 var content = el.querySelector(".content"); 8 if (content instanceof HTMLElement) { 9 var h = content.getBoundingClientRect(); 10 content.style.maxHeight = "" + h.height + "px"; 11 el.classList.add("hide"); 12 } 13 } 14 ); 15 }; 16 setTimeout(updateSizes, 5); 17 function openCollapser(el) { 18 const opener = el.querySelector(":scope > .opener"); 19 const isExpanded = opener?.getAttribute("aria-expanded"); 20 const anchor = opener?.hash; 21 if (isExpanded === "false") { 22 opener.setAttribute("aria-expanded", "true"); 23 el.classList.remove("hide"); 24 el.classList.add("showing"); 25 setTimeout(() => { 26 el.classList.add("show"); 27 setTimeout(() => { 28 el.classList.remove("showing"); 29 }, 0); 30 }, 0); 31 if (anchor) { 32 history.replaceState(null, "", anchor); 33 } 34 } 35 } 36 function closeCollapser(el) { 37 const opener = el.querySelector(":scope > .opener"); 38 const isExpanded = opener.getAttribute("aria-expanded"); 39 if (isExpanded === "true") { 40 opener.setAttribute("aria-expanded", "false"); 41 el.classList.remove("show"); 42 el.classList.add("hiding"); 43 setTimeout(() => { 44 el.classList.add("hide"); 45 setTimeout(() => { 46 el.classList.remove("hiding"); 47 }, 0); 48 }, 300); 49 } 50 if (window.location.hash) { 51 history.replaceState(null, "", window.location.pathname); 52 } 53 } 54 function toggleCollapser(el) { 55 const opener = el.querySelector(":scope > .opener"); 56 const isExpanded = opener.getAttribute("aria-expanded"); 57 if (isExpanded === "true") { 58 closeCollapser(el); 59 } else { 60 openCollapser(el); 61 } 62 } 63 document.querySelectorAll(".wp-block-mytheme-collapser").forEach((el) => { 64 el.querySelector(":scope > .opener")?.addEventListener("click", function(e) { 65 if (e.target instanceof Element) { 66 toggleCollapser(e.target.parentElement); 67 } 68 e.preventDefault(); 69 }); 70 setTimeout(() => { 71 if (window.location.hash) { 72 const anchor = window.location.hash; 73 const opener = el.querySelector(":scope > .opener"); 74 if (opener?.hash === anchor) { 75 openCollapser(el); 76 } 77 } 78 }, 150); 79 }); 80})();
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.