Skip to content

Commit

Permalink
Make pencil/edit icon toggle-able on site template.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Nov 13, 2023
1 parent 0f9604d commit 0f14a03
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions site/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@
const btn = e.target;

// Form is already open.
if (btn.dataset.open) {
if (btn.close) {
btn.close();
return;
}
btn.dataset.open = true;

const form = document.querySelector(".form-comments").cloneNode(true);
o.parentNode.appendChild(form);
Expand All @@ -127,12 +127,12 @@
txt.focus();
txt.onkeydown = (e) => {
if (e.key === "Escape") {
close();
btn.close();
}
};

const close = () => {
btn.dataset.open = "";
btn.close = () => {
btn.close = null;
form.remove();
};

Expand All @@ -153,10 +153,10 @@
});

alert(form.dataset.success);
close();
btn.close();
};

form.querySelector("button.close").onclick = close;
form.querySelector("button.close").onclick = btn.close;
});
})
})();

0 comments on commit 0f14a03

Please sign in to comment.