2024-01-23 04:30:23 -08:00
|
|
|
function setFormStateCookie(value) {
|
|
|
|
const thirtyDays = 60 * 60 * 24 * 30;
|
2024-01-23 04:40:05 -08:00
|
|
|
document.cookie = `DTIItemPageUserListsFormState=${value};max-age=${thirtyDays}`;
|
2024-01-23 04:30:23 -08:00
|
|
|
}
|
|
|
|
|
2024-01-23 04:20:03 -08:00
|
|
|
const headers = document.querySelectorAll(".item-header");
|
|
|
|
for (const header of headers) {
|
2024-01-21 06:20:32 -08:00
|
|
|
try {
|
2024-01-23 04:20:03 -08:00
|
|
|
const form = header.querySelector(".user-lists-form");
|
|
|
|
const opener = header.querySelector(".user-lists-form-opener");
|
|
|
|
opener.addEventListener("click", (event) => {
|
2024-01-23 04:30:23 -08:00
|
|
|
if (form.hasAttribute("hidden")) {
|
|
|
|
form.removeAttribute("hidden");
|
|
|
|
setFormStateCookie("open");
|
|
|
|
} else {
|
|
|
|
form.setAttribute("hidden", "");
|
|
|
|
setFormStateCookie("closed");
|
|
|
|
}
|
2024-01-23 04:20:03 -08:00
|
|
|
event.preventDefault();
|
|
|
|
});
|
2024-01-21 06:20:32 -08:00
|
|
|
} catch (error) {
|
|
|
|
console.error(`Error applying dialog behavior to item header:`, error);
|
|
|
|
}
|
|
|
|
}
|