[FIX] V3 polish: spotlight ARIA su top-nav + CSP font segnala-anonimo

- aria-guide "Mostrami dov'è": ora aggancia le voci del menu IN ALTO V3
  (data-nav aggiunto in topnav-v3.js su voci dirette + mega-link). Se la voce è
  in un mega-menu, lo apre (.aria-guide-open) e ci punta lo spotlight; coach
  "menu in alto". Fallback navigazione invariato. (Prima cercava .sidebar-nav V2.)
- segnala-anonimo.html: CSP font-src 'self' → 'self' data: (sbloccato il font
  data: embeddato, niente più violazione CSP).
- Cache-buster: topnav-v3.js/common.js ?v=20260627t, aria-guide.js ?v=20260627t.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
DevEnv nis2-agile
2026-06-27 17:57:21 +02:00
co-authored by Claude Opus 4.8
parent 95e77a668a
commit a71d1a096d
39 changed files with 98 additions and 83 deletions
+21 -8
View File
@@ -79,13 +79,15 @@
'.aria-guide-coach .row{margin-top:8px;display:flex;gap:8px;justify-content:flex-end}',
'.aria-guide-coach button{border:none;border-radius:7px;padding:6px 12px;font:600 12px system-ui;cursor:pointer}',
'.aria-guide-go{background:#0066CC;color:#fff}.aria-guide-x{background:#1e3a5f;color:#cbd5e1}',
'.nav-item.aria-guide-open .mega,.nav-item.aria-guide-open .mega.no-promo{display:flex!important}',
'@media (prefers-reduced-motion:reduce){.aria-guide-spot,.aria-guide-ptr{transition:none;animation:none}}'
].join('\n');
document.head.appendChild(s);
}
var _open = null;
var _open = null, _openMega = null;
function dismiss() {
if (_openMega) { _openMega.classList.remove('aria-guide-open'); _openMega = null; }
if (!_open) return;
_open.forEach(function (el) { if (el && el.parentNode) el.parentNode.removeChild(el); });
document.removeEventListener('keydown', onKey, true);
@@ -100,19 +102,29 @@
*/
function pointTo(nav, label) {
dismiss();
var el = document.querySelector('.sidebar-nav a[data-nav="' + nav + '"]');
var href = el ? el.getAttribute('href') : (nav + '.html');
var rect = el && el.getBoundingClientRect();
// fallback: niente sidebar visibile → vai diretto
if (!el || !rect || rect.width === 0 || rect.height === 0) { window.location.href = href; return false; }
injectCss();
// V3: menu IN ALTO (data-nav su voci dirette e mega-link). Fallback compat sidebar V2.
var el = document.querySelector('.bar-nav [data-nav="' + nav + '"]')
|| document.querySelector('[data-nav="' + nav + '"]')
|| document.querySelector('.sidebar-nav a[data-nav="' + nav + '"]');
var href = el ? (el.getAttribute('href') || (nav + '.html')) : (nav + '.html');
// Se la voce è dentro un mega-menu (dropdown chiuso), aprilo per renderla visibile.
var megaItem = (el && el.closest && el.closest('.mega')) ? el.closest('.nav-item') : null;
if (megaItem) megaItem.classList.add('aria-guide-open');
try { window.scrollTo({ top: 0, behavior: 'auto' }); } catch (e) {}
var rect = el && el.getBoundingClientRect();
// fallback: voce non trovata/visibile → vai diretto
if (!el || !rect || rect.width === 0 || rect.height === 0) {
if (megaItem) megaItem.classList.remove('aria-guide-open');
window.location.href = href; return false;
}
var ov = document.createElement('div'); ov.className = 'aria-guide-ov';
var spot = document.createElement('div'); spot.className = 'aria-guide-spot';
var ptr = document.createElement('div'); ptr.className = 'aria-guide-ptr';
ptr.innerHTML = '<svg viewBox="0 0 24 24" fill="#0066CC" stroke="#fff" stroke-width="1.2"><path d="M5 3l14 8-6 1.5L9.5 19 5 3z"/></svg>';
var coach = document.createElement('div'); coach.className = 'aria-guide-coach';
coach.innerHTML = 'Eccolo: <b>' + (label || nav) + '</b><br><span style="opacity:.85">È nel menu a sinistra. Vuoi che ti ci porti?</span>'
coach.innerHTML = 'Eccolo: <b>' + (label || nav) + '</b><br><span style="opacity:.85">È nel menu in alto. Vuoi che ti ci porti?</span>'
+ '<div class="row"><button class="aria-guide-x" type="button">Chiudi</button><button class="aria-guide-go" type="button">Vai →</button></div>';
document.body.appendChild(ov);
@@ -137,6 +149,7 @@
coach.querySelector('.aria-guide-go').addEventListener('click', function () { window.location.href = href; });
document.addEventListener('keydown', onKey, true);
_open = [ov, spot, ptr, coach];
_openMega = megaItem;
return true;
}