diff --git a/forum/apercu.js b/forum/apercu.js index 77c28fe..abcbd5e 100644 --- a/forum/apercu.js +++ b/forum/apercu.js @@ -63,3 +63,51 @@ document.querySelectorAll("form[action$='/sujet'], form[action$='/repondre']").f if (champ) champ.addEventListener(champ.type === "file" ? "change" : "input", function () { if (!vue.hidden) dessiner(); }); }); }); + +// « Copier le lien » d'un message : copie l'adresse complète. Sans JavaScript, le lien mène au message. +document.querySelectorAll("a.copier-lien").forEach(function (a) { + a.addEventListener("click", function (ev) { + if (!navigator.clipboard) return; + ev.preventDefault(); + var url = location.origin + location.pathname + location.search + a.getAttribute("href"); + navigator.clipboard.writeText(url).then(function () { + a.textContent = "Lien copié"; + setTimeout(function () { a.textContent = "Copier le lien"; }, 2000); + }); + }); +}); + +// Photos : un clic ouvre la photo en grand, flèches pour passer à la suivante, Échap pour fermer. +// Sans JavaScript, le lien ouvre simplement la photo. +(function () { + var liens = Array.prototype.slice.call(document.querySelectorAll(".msg .galerie a")); + if (!liens.length || typeof HTMLDialogElement !== "function") return; + var dlg = document.createElement("dialog"); + dlg.className = "visionneuse"; + dlg.setAttribute("aria-label", "Photo en grand"); + dlg.innerHTML = "
" + + "" + + "
"; + document.body.appendChild(dlg); + var img = dlg.querySelector("img"), compte = dlg.querySelector(".compte"), i = 0; + function montrer(n) { + i = (n + liens.length) % liens.length; + var vignette = liens[i].querySelector("img"); + img.src = liens[i].getAttribute("href"); + img.alt = vignette ? vignette.alt : ""; + compte.textContent = (i + 1) + " / " + liens.length; + dlg.querySelectorAll("[data-pas]").forEach(function (b) { b.hidden = liens.length < 2; }); + } + liens.forEach(function (a, n) { + a.addEventListener("click", function (ev) { ev.preventDefault(); montrer(n); dlg.showModal(); }); + }); + dlg.addEventListener("click", function (ev) { + var pas = ev.target.getAttribute && ev.target.getAttribute("data-pas"); + if (pas) montrer(i + Number(pas)); + else if (ev.target === dlg || ev.target.classList.contains("fermer")) dlg.close(); + }); + dlg.addEventListener("keydown", function (ev) { + if (ev.key === "ArrowRight") montrer(i + 1); + if (ev.key === "ArrowLeft") montrer(i - 1); + }); +})(); diff --git a/forum/server.py b/forum/server.py index fe15827..1a6ee82 100644 --- a/forum/server.py +++ b/forum/server.py @@ -141,6 +141,12 @@ form.inline{display:inline;margin:0 6px 0 0}form.inline button{font-size:12px;pa .actions{margin:10px 0 0}.actions form{margin:0} .actions details{max-width:100%} .actions details[open]{flex-basis:100%} +.visionneuse{border:1px solid var(--roche);background:#faf9f5;padding:12px;max-width:min(1100px,96vw);max-height:96vh;color:var(--roche)} +.visionneuse::backdrop{background:rgba(245,243,238,.92)} +.visionneuse img{display:block;max-width:100%;max-height:78vh;margin:0 auto;object-fit:contain} +.visionneuse .barre{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-top:10px;font-size:14px} +.visionneuse button{min-height:44px;min-width:44px} +.actions .signaler{margin-left:auto}.actions .signaler[open]{margin-left:0} .actions summary,.fiche summary{cursor:pointer;color:var(--sapin);font-weight:600;padding:7px 0} .ligne{display:flex;flex-wrap:wrap;gap:8px;align-items:flex-end}.ligne>div{flex:1 1 180px;min-width:0} .ligne select,.ligne input{width:100%} @@ -808,8 +814,9 @@ class Handler(BaseHTTPRequestHandler): for m in msgs: gal = galerie_html(f.photos_de(m["id"]), "/photo", None if fiche is None or m["hidden"] else fiche) outils = "" + lien = "Copier le lien" % m["id"] if roles.peut(rs, "signaler") and not m["hidden"]: - outils += ("
Signaler le message
" + outils += ("
Signaler le message" "" "
" % m["id"]) @@ -831,7 +838,7 @@ class Handler(BaseHTTPRequestHandler): e(m["body"]), ("
Modifié le %s · voir l’ancienne version

%s

" % (e(date_fr(m["edited_at"], True)), e(m["ancien_body"] or "")) if m["edited_at"] else ""), gal, - "
%s
" % outils if outils else "")) + "
%s
" % (lien + outils))) gestion = [] if roles.peut(rs, "verrouiller") and not t["fixed"]: gestion.append("
"