stylescape
Version:
Stylescape is a visual identity framework developed by Scape Agency.
35 lines • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DetailManager = void 0;
class DetailManager {
constructor(selector = "details") {
this.details = document.querySelectorAll(selector);
this.boundHandler = this.handleClick.bind(this);
document.addEventListener("click", this.boundHandler);
}
handleClick(event) {
const target = event.target;
const summary = target.closest("summary");
const parent = summary?.parentElement;
if (parent && parent.tagName === "DETAILS") {
this.details.forEach((detail) => {
if (detail !== parent)
detail.removeAttribute("open");
});
}
else {
this.details.forEach((detail) => detail.removeAttribute("open"));
}
}
toggle(detail, open) {
if (open)
detail.setAttribute("open", "");
else
detail.removeAttribute("open");
}
destroy() {
document.removeEventListener("click", this.boundHandler);
}
}
exports.DetailManager = DetailManager;
//# sourceMappingURL=DetailManager.js.map