function toggleArticle(event, id) { event.preventDefault(); var link = event.currentTarget; var row = link.closest("li.article-row"); var body = document.getElementById("article-body-" + id); var wasOpen = row.classList.contains("is-expanded"); document.querySelectorAll("li.article-row.is-expanded").forEach(function (openRow) { openRow.classList.remove("is-expanded"); var openBody = openRow.querySelector(".article-inline-body"); if (openBody) { openBody.hidden = true; } }); if (!wasOpen) { row.classList.add("is-expanded"); body.hidden = false; if (!body.dataset.loaded) { body.dataset.loaded = "1"; htmx.ajax("GET", link.dataset.inlineUrl, { target: body, swap: "innerHTML" }).then( function () { row.classList.add("is-read"); } ); } } return false; }