feat/proposer-antifragile #31
@@ -156,29 +156,19 @@ const GITEA_REPO = import.meta.env.PUBLIC_GITEA_REPO ?? "";
|
|||||||
if (giteaReady) {
|
if (giteaReady) {
|
||||||
const propose = document.createElement("a");
|
const propose = document.createElement("a");
|
||||||
propose.className = "para-propose";
|
propose.className = "para-propose";
|
||||||
propose.href = "#";
|
|
||||||
propose.textContent = "Proposer";
|
propose.textContent = "Proposer";
|
||||||
propose.setAttribute("aria-label", "Proposer une correction sur Gitea");
|
propose.setAttribute("aria-label", "Proposer une correction sur Gitea");
|
||||||
propose.setAttribute("data-propose","1");
|
propose.setAttribute("data-propose", "1");
|
||||||
|
|
||||||
propose.addEventListener("click", (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
const raw = (p.textContent || "").trim().replace(/\s+/g, " ");
|
const raw = (p.textContent || "").trim().replace(/\s+/g, " ");
|
||||||
const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw;
|
const excerpt = raw.length > 420 ? (raw.slice(0, 420) + "…") : raw;
|
||||||
const url = buildIssueURL(p.id, excerpt);
|
const url = buildIssueURL(p.id, excerpt);
|
||||||
|
|
||||||
// on stocke l'URL pour le modal
|
// progressive enhancement : sans JS/modal, href fonctionne.
|
||||||
propose.dataset.url = url.toString();
|
propose.href = url;
|
||||||
|
|
||||||
// fallback: si le modal n'existe pas -> ouverture directe
|
// compat : la modal lit data-url en priorité (garde aussi href).
|
||||||
const dlg = document.getElementById("propose-modal");
|
propose.dataset.url = url;
|
||||||
if (!dlg || typeof dlg.showModal !== "function") {
|
|
||||||
window.open(propose.dataset.url, "_blank", "noopener,noreferrer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// si modal existe, il va intercepter le click globalement
|
|
||||||
// donc on ne fait rien ici de plus.
|
|
||||||
});
|
|
||||||
|
|
||||||
tools.appendChild(propose);
|
tools.appendChild(propose);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user