|
17 | 17 | * |
18 | 18 | * ENGRID PAGE TEMPLATE ASSETS |
19 | 19 | * |
20 | | - * Date: Thursday, May 14, 2026 @ 10:33:01 ET |
| 20 | + * Date: Monday, May 18, 2026 @ 11:00:44 ET |
21 | 21 | * By: nick |
22 | 22 | * ENGrid styles: v0.25.0 |
23 | 23 | * ENGrid scripts: v0.25.1 |
@@ -20953,59 +20953,23 @@ class ClickToExpand { |
20953 | 20953 | constructor() { |
20954 | 20954 | this.clickToExpandWrapper = document.querySelectorAll("div.click-to-expand"); |
20955 | 20955 | if (this.clickToExpandWrapper.length) { |
20956 | | - this.clickToExpandWrapper.forEach((element, index) => { |
20957 | | - var _a; |
20958 | | - const textWrapperId = `click-to-expand-text-${index}`; |
20959 | | - const ctaId = `click-to-expand-cta-${index}`; |
20960 | | - // Extract screen reader tip from the live DOM |
20961 | | - const screenReaderTip = element.querySelector(".click-to-expand-screenreader-tip"); |
20962 | | - let ariaLabel = "Show more"; |
20963 | | - if (screenReaderTip) { |
20964 | | - const tipText = (_a = screenReaderTip.textContent) === null || _a === void 0 ? void 0 : _a.trim(); |
20965 | | - if (tipText) { |
20966 | | - ariaLabel = `Show more: ${tipText}`; |
| 20956 | + this.clickToExpandWrapper.forEach(element => { |
| 20957 | + const content = element.innerHTML; |
| 20958 | + const wrapper_html = '<div class="click-to-expand-cta"></div><div class="click-to-expand-text-wrapper" tabindex="0">' + content + "</div>"; |
| 20959 | + element.innerHTML = wrapper_html; |
| 20960 | + element.addEventListener("click", event => { |
| 20961 | + if (event) { |
| 20962 | + if (engrid_ENGrid.debug) console.log("A click-to-expand div was clicked"); |
| 20963 | + element.classList.add("expanded"); |
20967 | 20964 | } |
20968 | | - screenReaderTip.remove(); |
20969 | | - } |
20970 | | - // Capture all original child nodes before restructuring |
20971 | | - const originalChildren = Array.from(element.childNodes); |
20972 | | - element.innerHTML = ""; |
20973 | | - // Create the text wrapper |
20974 | | - const textWrapper = document.createElement("div"); |
20975 | | - textWrapper.className = "click-to-expand-text-wrapper"; |
20976 | | - textWrapper.id = textWrapperId; |
20977 | | - textWrapper.setAttribute("aria-hidden", "true"); |
20978 | | - textWrapper.setAttribute("aria-label", "Expanded content" + (ariaLabel ? `${ariaLabel.replace('Show more', '')}` : "")); |
20979 | | - textWrapper.setAttribute("tabindex", "-1"); |
20980 | | - originalChildren.forEach(child => { |
20981 | | - textWrapper.appendChild(child); |
20982 | 20965 | }); |
20983 | | - const cta = document.createElement("div"); |
20984 | | - cta.className = "click-to-expand-cta"; |
20985 | | - cta.id = ctaId; |
20986 | | - cta.setAttribute("role", "button"); |
20987 | | - cta.setAttribute("tabindex", "0"); |
20988 | | - cta.setAttribute("aria-expanded", "false"); |
20989 | | - cta.setAttribute("aria-controls", textWrapperId); |
20990 | | - cta.setAttribute("aria-label", ariaLabel); |
20991 | | - element.appendChild(textWrapper); |
20992 | | - element.appendChild(cta); |
20993 | | - const expand = () => { |
20994 | | - if (engrid_ENGrid.debug) { |
20995 | | - console.log("A click-to-expand div was expanded"); |
20996 | | - } |
20997 | | - element.classList.add("expanded"); |
20998 | | - cta.setAttribute("aria-expanded", "true"); |
20999 | | - cta.setAttribute("aria-hidden", "true"); |
21000 | | - textWrapper.setAttribute("aria-hidden", "false"); |
21001 | | - textWrapper.focus(); // Move focus to revealed content for screen reader announcement |
21002 | | - }; |
21003 | | - element.addEventListener("click", expand); |
21004 | 20966 | element.addEventListener("keydown", event => { |
21005 | 20967 | if (event.key === "Enter") { |
21006 | | - expand(); |
| 20968 | + if (engrid_ENGrid.debug) console.log("A click-to-expand div had the 'Enter' key pressed on it"); |
| 20969 | + element.classList.add("expanded"); |
21007 | 20970 | } else if (event.key === " ") { |
21008 | | - expand(); |
| 20971 | + if (engrid_ENGrid.debug) console.log("A click-to-expand div had the 'Spacebar' key pressed on it"); |
| 20972 | + element.classList.add("expanded"); |
21009 | 20973 | event.preventDefault(); // Prevents the page from scrolling |
21010 | 20974 | event.stopPropagation(); // Prevent a console error generated by LastPass https://github.com/KillerCodeMonkey/ngx-quill/issues/351#issuecomment-476017960 |
21011 | 20975 | } |
|
0 commit comments