style(mobile): widen reading in landscape on small screens (css-only)
This commit is contained in:
@@ -25,12 +25,12 @@
|
||||
|
||||
{/* ✅ actions références en haut (niveau 2 uniquement) */}
|
||||
<div class="panel-top-actions level-2" aria-label="Actions références">
|
||||
<div class="panel-actions">
|
||||
<div class="panel-actions">
|
||||
<button class="panel-btn panel-btn--primary" id="panel-ref-submit" type="button">
|
||||
Soumettre une référence (Gitea)
|
||||
Soumettre une référence (Gitea)
|
||||
</button>
|
||||
</div>
|
||||
<div class="panel-msg" id="panel-ref-msg" hidden></div>
|
||||
</div>
|
||||
<div class="panel-msg" id="panel-ref-msg" hidden></div>
|
||||
</div>
|
||||
|
||||
<section class="panel-block level-2" aria-label="Références et auteurs">
|
||||
@@ -60,7 +60,7 @@
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{/* ✅ Lightbox media (pop-up au-dessus du panel) */}
|
||||
{/* ✅ Lightbox media (plein écran) */}
|
||||
<div class="panel-lightbox" id="panel-lightbox" hidden aria-hidden="true">
|
||||
<div class="panel-lightbox__overlay" data-close="1"></div>
|
||||
<div class="panel-lightbox__dialog" role="dialog" aria-modal="true" aria-label="Aperçu du média">
|
||||
@@ -93,6 +93,9 @@
|
||||
const btnMediaSubmit = root.querySelector("#panel-media-submit");
|
||||
const msgMedia = root.querySelector("#panel-media-msg");
|
||||
|
||||
const btnRefSubmit = root.querySelector("#panel-ref-submit");
|
||||
const msgRef = root.querySelector("#panel-ref-msg");
|
||||
|
||||
const taComment = root.querySelector("#panel-comment-text");
|
||||
const btnSend = root.querySelector("#panel-comment-send");
|
||||
const msgComment = root.querySelector("#panel-comment-msg");
|
||||
@@ -101,9 +104,6 @@
|
||||
const lbContent = root.querySelector("#panel-lightbox-content");
|
||||
const lbCaption = root.querySelector("#panel-lightbox-caption");
|
||||
|
||||
const btnRefSubmit = root.querySelector("#panel-ref-submit");
|
||||
const msgRef = root.querySelector("#panel-ref-msg");
|
||||
|
||||
const docTitle = document.body?.dataset?.docTitle || document.title || "Archicratie";
|
||||
const docVersion = document.body?.dataset?.docVersion || "";
|
||||
|
||||
@@ -114,6 +114,16 @@
|
||||
let currentParaId = "";
|
||||
let mediaShowAll = (localStorage.getItem("archicratie:panel:mediaAll") === "1");
|
||||
|
||||
// ===== cosmetics: micro flash “update” =====
|
||||
let _flashT = 0;
|
||||
function flashUpdate(){
|
||||
try {
|
||||
root.classList.add("is-updating");
|
||||
if (_flashT) clearTimeout(_flashT);
|
||||
_flashT = setTimeout(() => root.classList.remove("is-updating"), 180);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// ===== globals =====
|
||||
function getG() {
|
||||
return window.__archiGitea || { ready: false, base: "", owner: "", repo: "" };
|
||||
@@ -121,9 +131,6 @@
|
||||
function getAuthInfoP() {
|
||||
return window.__archiAuthInfoP || Promise.resolve({ ok: false, groups: [] });
|
||||
}
|
||||
function isDev() {
|
||||
return Boolean((window.__archiFlags && window.__archiFlags.dev) || /^(localhost|127\.0\.0\.1|\[::1\])$/i.test(location.hostname));
|
||||
}
|
||||
|
||||
const access = { ready: false, canUsers: false };
|
||||
|
||||
@@ -137,8 +144,7 @@
|
||||
return Array.isArray(groups) && groups.some((x) => String(x).toLowerCase() === gg);
|
||||
}
|
||||
|
||||
// ✅ règle mission : readers + editors peuvent soumettre médias + commentaires
|
||||
// ✅ dev fallback : si /_auth/whoami n’existe pas, on autorise pour tester
|
||||
// ✅ readers + editors peuvent soumettre médias + commentaires + refs
|
||||
getAuthInfoP().then((info) => {
|
||||
const groups = Array.isArray(info?.groups) ? info.groups : [];
|
||||
const canReaders = inGroup(groups, "readers");
|
||||
@@ -152,7 +158,6 @@
|
||||
if (btnSend) btnSend.disabled = !access.canUsers;
|
||||
if (btnRefSubmit) btnRefSubmit.disabled = !access.canUsers;
|
||||
|
||||
// si pas d'accès, on informe (soft)
|
||||
if (!access.canUsers) {
|
||||
if (msgHead) {
|
||||
msgHead.hidden = false;
|
||||
@@ -161,7 +166,6 @@
|
||||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
// fallback dev (cohérent: media + ref + comment)
|
||||
access.ready = true;
|
||||
if (Boolean(window.__archiFlags && window.__archiFlags.whoamiSkipped)) {
|
||||
access.canUsers = true;
|
||||
@@ -213,7 +217,6 @@
|
||||
const res = await fetch("/annotations-index.json?_=" + Date.now(), { cache: "no-store" });
|
||||
if (res && res.ok) return await res.json();
|
||||
} catch {}
|
||||
// ✅ antifragile: ne pas “cacher” un échec pour toujours (dev/HMR/boot race)
|
||||
_idxP = null;
|
||||
return null;
|
||||
})();
|
||||
@@ -255,24 +258,22 @@
|
||||
return issue.toString();
|
||||
}
|
||||
|
||||
// Ouvre un nouvel onglet UNE SEULE FOIS (évite le double-open Safari/Firefox + noopener).
|
||||
function openNewTab(url) {
|
||||
try {
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener noreferrer";
|
||||
a.style.display = "none";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
return true; // on ne peut pas détecter proprement un blocage sans retomber dans le double-open
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
function openNewTab(url) {
|
||||
try {
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.target = "_blank";
|
||||
a.rel = "noopener noreferrer";
|
||||
a.style.display = "none";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ====== GARDES ANTI-DOUBLONS ======
|
||||
const _openStamp = new Map();
|
||||
function openOnce(key, fn) {
|
||||
const now = Date.now();
|
||||
@@ -301,13 +302,21 @@
|
||||
}
|
||||
|
||||
// ===== Lightbox =====
|
||||
function lockScroll(on) {
|
||||
try {
|
||||
document.documentElement.classList.toggle("archi-lb-open", !!on);
|
||||
} catch {}
|
||||
}
|
||||
|
||||
function closeLightbox() {
|
||||
if (!lb) return;
|
||||
lb.hidden = true;
|
||||
lb.setAttribute("aria-hidden", "true");
|
||||
if (lbContent) clear(lbContent);
|
||||
if (lbCaption) { lbCaption.hidden = true; lbCaption.textContent = ""; }
|
||||
lockScroll(false);
|
||||
}
|
||||
|
||||
function openLightbox({ type, src, caption }) {
|
||||
if (!lb || !lbContent) return;
|
||||
clear(lbContent);
|
||||
@@ -346,6 +355,7 @@
|
||||
else { lbCaption.hidden = true; lbCaption.textContent = ""; }
|
||||
}
|
||||
|
||||
lockScroll(true);
|
||||
lb.hidden = false;
|
||||
lb.setAttribute("aria-hidden", "false");
|
||||
}
|
||||
@@ -363,7 +373,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ===== Renders =====
|
||||
function renderLevel2(data) {
|
||||
clear(elL2);
|
||||
if (!elL2) return;
|
||||
@@ -563,13 +572,16 @@
|
||||
async function updatePanel(paraId) {
|
||||
currentParaId = paraId || currentParaId || "";
|
||||
if (elId) elId.textContent = currentParaId || "—";
|
||||
|
||||
flashUpdate();
|
||||
|
||||
hideMsg(msgHead);
|
||||
hideMsg(msgMedia);
|
||||
hideMsg(msgComment);
|
||||
hideMsg(msgRef);
|
||||
|
||||
const idx = await loadIndex();
|
||||
|
||||
// ✅ message soft si l’index est indisponible (sans écraser le message d’auth)
|
||||
if (!idx && msgHead && msgHead.hidden) {
|
||||
msgHead.hidden = false;
|
||||
msgHead.textContent = "Index annotations indisponible (annotations-index.json).";
|
||||
@@ -583,7 +595,6 @@
|
||||
renderLevel4(data);
|
||||
}
|
||||
|
||||
// ===== media "voir tous" =====
|
||||
if (btnMediaAll) {
|
||||
bindClickOnce(btnMediaAll, (ev) => {
|
||||
ev.preventDefault();
|
||||
@@ -595,7 +606,6 @@
|
||||
btnMediaAll.textContent = mediaShowAll ? "Réduire la liste" : "Voir tous les éléments";
|
||||
}
|
||||
|
||||
// ===== media submit (readers + editors) =====
|
||||
if (btnMediaSubmit) {
|
||||
bindClickOnce(btnMediaSubmit, (ev) => {
|
||||
ev.preventDefault();
|
||||
@@ -638,27 +648,26 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ===== référence submit (readers + editors) =====
|
||||
if (btnRefSubmit) {
|
||||
if (btnRefSubmit) {
|
||||
bindClickOnce(btnRefSubmit, (ev) => {
|
||||
ev.preventDefault();
|
||||
hideMsg(msgRef);
|
||||
ev.preventDefault();
|
||||
hideMsg(msgRef);
|
||||
|
||||
if (guardEventOnce(ev, "gitea_open_ref")) return;
|
||||
if (guardEventOnce(ev, "gitea_open_ref")) return;
|
||||
|
||||
if (!currentParaId) return showMsg(msgRef, "Choisis d’abord un paragraphe (scroll / survol).", "warn");
|
||||
if (!getG().ready) return showMsg(msgRef, "Gitea non configuré (PUBLIC_GITEA_*).", "error");
|
||||
if (btnRefSubmit.disabled) return showMsg(msgRef, "Connexion requise (readers/editors).", "error");
|
||||
if (!currentParaId) return showMsg(msgRef, "Choisis d’abord un paragraphe (scroll / survol).", "warn");
|
||||
if (!getG().ready) return showMsg(msgRef, "Gitea non configuré (PUBLIC_GITEA_*).", "error");
|
||||
if (btnRefSubmit.disabled) return showMsg(msgRef, "Connexion requise (readers/editors).", "error");
|
||||
|
||||
const pageUrl = new URL(location.href);
|
||||
pageUrl.search = "";
|
||||
pageUrl.hash = currentParaId;
|
||||
const pageUrl = new URL(location.href);
|
||||
pageUrl.search = "";
|
||||
pageUrl.hash = currentParaId;
|
||||
|
||||
const paraTxt = getParaText(currentParaId);
|
||||
const excerpt = paraTxt.length > FULL_TEXT_SOFT_LIMIT ? (paraTxt.slice(0, FULL_TEXT_SOFT_LIMIT) + "…") : paraTxt;
|
||||
const paraTxt = getParaText(currentParaId);
|
||||
const excerpt = paraTxt.length > FULL_TEXT_SOFT_LIMIT ? (paraTxt.slice(0, FULL_TEXT_SOFT_LIMIT) + "…") : paraTxt;
|
||||
|
||||
const title = `[Reference] ${currentParaId} — ${docTitle}`;
|
||||
const body = [
|
||||
const title = `[Reference] ${currentParaId} — ${docTitle}`;
|
||||
const body = [
|
||||
`Chemin: ${location.pathname}`,
|
||||
`URL: ${pageUrl.toString()}`,
|
||||
`Ancre: #${currentParaId}`,
|
||||
@@ -676,18 +685,16 @@
|
||||
``,
|
||||
`---`,
|
||||
`Note: issue générée depuis le site (pré-remplissage).`,
|
||||
].join("\n");
|
||||
].join("\n");
|
||||
|
||||
const url = buildIssueURL({ title, body });
|
||||
if (!url) return showMsg(msgRef, "Impossible de générer l’issue.", "error");
|
||||
const url = buildIssueURL({ title, body });
|
||||
if (!url) return showMsg(msgRef, "Impossible de générer l’issue.", "error");
|
||||
|
||||
const ok = openOnce(`ref:${currentParaId}`, () => openNewTab(url));
|
||||
if (!ok) showMsg(msgRef, "Si rien ne s’ouvre : autorise les popups pour ce site.", "error");
|
||||
const ok = openOnce(`ref:${currentParaId}`, () => openNewTab(url));
|
||||
if (!ok) showMsg(msgRef, "Si rien ne s’ouvre : autorise les popups pour ce site.", "error");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ===== commentaire (readers + editors) =====
|
||||
if (btnSend) {
|
||||
bindClickOnce(btnSend, (ev) => {
|
||||
ev.preventDefault();
|
||||
@@ -739,60 +746,31 @@
|
||||
});
|
||||
}
|
||||
|
||||
// ===== wiring: para courant (aligné sur le paragraphe sous le reading-follow) =====
|
||||
function isPara(el) {
|
||||
return Boolean(el && el.nodeType === 1 && el.matches && el.matches('.reading p[id^="p-"]'));
|
||||
// ===== wiring: para courant (SOURCE OF TRUTH = EditionLayout) =====
|
||||
function onCurrentPara(ev) {
|
||||
try {
|
||||
const id = ev?.detail?.id ? String(ev.detail.id) : "";
|
||||
if (!id || !/^p-\d+-/i.test(id)) return;
|
||||
if (id === currentParaId) return;
|
||||
updatePanel(id);
|
||||
} catch {}
|
||||
}
|
||||
window.addEventListener("archicratie:currentPara", onCurrentPara);
|
||||
|
||||
function pickParaAtY(y) {
|
||||
const x = Math.max(0, Math.round(window.innerWidth * 0.5));
|
||||
const candidates = [
|
||||
document.elementFromPoint(x, y),
|
||||
document.elementFromPoint(Math.min(window.innerWidth - 1, x + 60), y),
|
||||
document.elementFromPoint(Math.max(0, x - 60), y),
|
||||
].filter(Boolean);
|
||||
const initial = String(location.hash || "").replace(/^#/, "").trim();
|
||||
|
||||
for (const c of candidates) {
|
||||
if (isPara(c)) return c;
|
||||
const p = c.closest ? c.closest('.reading p[id^="p-"]') : null;
|
||||
if (isPara(p)) return p;
|
||||
}
|
||||
return null;
|
||||
if (/^p-\d+-/i.test(initial)) {
|
||||
updatePanel(initial);
|
||||
} else if (window.__archiCurrentParaId && /^p-\d+-/i.test(String(window.__archiCurrentParaId))) {
|
||||
updatePanel(String(window.__archiCurrentParaId));
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
try {
|
||||
const id = String(window.__archiCurrentParaId || "").trim();
|
||||
if (/^p-\d+-/i.test(id)) updatePanel(id);
|
||||
} catch {}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
let _lastPicked = "";
|
||||
function syncFromFollowLine() {
|
||||
const off = Number(document.documentElement.style.getPropertyValue("--sticky-offset-px")) || 0;
|
||||
const y = Math.round(off + 8);
|
||||
const p = pickParaAtY(y);
|
||||
if (!p || !p.id) return;
|
||||
if (p.id === _lastPicked) return;
|
||||
_lastPicked = p.id;
|
||||
|
||||
// met à jour l'app global (EditionLayout écoute déjà currentPara)
|
||||
try { window.dispatchEvent(new CustomEvent("archicratie:currentPara", { detail: { id: p.id } })); } catch {}
|
||||
|
||||
// et met à jour le panel immédiatement (sans attendre)
|
||||
updatePanel(p.id);
|
||||
}
|
||||
|
||||
let ticking = false;
|
||||
function onScroll() {
|
||||
if (ticking) return;
|
||||
ticking = true;
|
||||
requestAnimationFrame(() => {
|
||||
ticking = false;
|
||||
syncFromFollowLine();
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("scroll", onScroll, { passive: true });
|
||||
window.addEventListener("resize", onScroll);
|
||||
|
||||
// Initial: hash > sinon calc
|
||||
const initial = String(location.hash || "").replace(/^#/, "");
|
||||
if (/^p-\d+-/i.test(initial)) updatePanel(initial);
|
||||
else setTimeout(() => { try { syncFromFollowLine(); } catch {} }, 0);
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -805,6 +783,8 @@
|
||||
position: sticky;
|
||||
top: calc(var(--sticky-header-h) + var(--page-gap));
|
||||
align-self: start;
|
||||
|
||||
--thumb: 92px; /* ✅ taille des vignettes (80–110 selon goût) */
|
||||
}
|
||||
|
||||
:global(body[data-reading-level="3"]) .page-panel{
|
||||
@@ -922,28 +902,33 @@
|
||||
/* actions médias en haut */
|
||||
.panel-top-actions{ margin-top: 8px; }
|
||||
|
||||
/* ===== media thumbnails (150x150) ===== */
|
||||
/* ===== media thumbnails (plus petits + plus denses) ===== */
|
||||
.panel-media-grid{
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
||||
grid-template-columns: repeat(auto-fill, minmax(var(--thumb), 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.panel-media-tile{
|
||||
width: 150px;
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
border: 1px solid rgba(127,127,127,.20);
|
||||
border-radius: 14px;
|
||||
padding: 8px;
|
||||
background: rgba(127,127,127,0.04);
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
|
||||
}
|
||||
|
||||
.panel-media-tile:hover{
|
||||
transform: translateY(-1px);
|
||||
background: rgba(127,127,127,0.07);
|
||||
border-color: rgba(127,127,127,.32);
|
||||
}
|
||||
|
||||
.panel-media-tile img{
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
height: var(--thumb);
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
border-radius: 10px;
|
||||
@@ -951,8 +936,8 @@
|
||||
}
|
||||
|
||||
.panel-media-ph{
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
width: 100%;
|
||||
height: var(--thumb);
|
||||
border-radius: 10px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
@@ -995,7 +980,11 @@
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
/* ===== Lightbox ===== */
|
||||
/* ===== Lightbox (plein écran “cinéma”) ===== */
|
||||
:global(html.archi-lb-open){
|
||||
overflow: hidden; /* ✅ empêche le scroll derrière */
|
||||
}
|
||||
|
||||
.panel-lightbox{
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
@@ -1005,58 +994,66 @@
|
||||
.panel-lightbox__overlay{
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(0,0,0,0.80);
|
||||
backdrop-filter: blur(6px);
|
||||
-webkit-backdrop-filter: blur(6px);
|
||||
background: rgba(0,0,0,0.84);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.panel-lightbox__dialog{
|
||||
position: absolute;
|
||||
right: 24px;
|
||||
top: calc(var(--sticky-header-h) + 16px);
|
||||
width: min(520px, calc(100vw - 48px));
|
||||
max-height: calc(100vh - (var(--sticky-header-h) + 32px));
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
width: min(1100px, 92vw);
|
||||
max-height: 92vh;
|
||||
overflow: auto;
|
||||
|
||||
border: 1px solid rgba(127,127,127,0.22);
|
||||
border-radius: 16px;
|
||||
background: rgba(255,255,255,0.10);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
padding: 12px;
|
||||
}
|
||||
border: 1px solid rgba(255,255,255,0.14);
|
||||
border-radius: 18px;
|
||||
|
||||
@media (prefers-color-scheme: dark){
|
||||
.panel-lightbox__dialog{
|
||||
background: rgba(0,0,0,0.28);
|
||||
}
|
||||
background: rgba(20,20,20,0.55);
|
||||
backdrop-filter: blur(14px);
|
||||
-webkit-backdrop-filter: blur(14px);
|
||||
|
||||
padding: 16px;
|
||||
box-shadow: 0 24px 70px rgba(0,0,0,0.55);
|
||||
}
|
||||
|
||||
.panel-lightbox__close{
|
||||
position: sticky;
|
||||
top: 0;
|
||||
margin-left: auto;
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 34px;
|
||||
height: 30px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid rgba(127,127,127,0.35);
|
||||
background: rgba(127,127,127,0.10);
|
||||
|
||||
width: 44px;
|
||||
height: 40px;
|
||||
|
||||
border-radius: 14px;
|
||||
border: 1px solid rgba(255,255,255,0.22);
|
||||
background: rgba(255,255,255,0.10);
|
||||
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
font-size: 22px;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.panel-lightbox__content{
|
||||
margin-top: 36px;
|
||||
}
|
||||
|
||||
.panel-lightbox__content img,
|
||||
.panel-lightbox__content video{
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
max-width: 1400px;
|
||||
margin: 0 auto;
|
||||
border-radius: 12px;
|
||||
max-height: calc(92vh - 160px);
|
||||
object-fit: contain;
|
||||
|
||||
background: rgba(0,0,0,0.22);
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
.panel-lightbox__content audio{
|
||||
@@ -1064,13 +1061,14 @@
|
||||
}
|
||||
|
||||
.panel-lightbox__caption{
|
||||
margin-top: 10px;
|
||||
margin-top: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
opacity: .92;
|
||||
color: rgba(255,255,255,0.92);
|
||||
}
|
||||
|
||||
@media (max-width: 1100px){
|
||||
.page-panel{ display: none; }
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user