Bot:Gadget-figureSource.js: Difference between revisions
Content deleted Content added
Footnote-pattern peek: hover card / touch banner, tabindex tap fix, click = viewer |
Prose address: section h2 + chunk title (title lives in the marker paragraph) |
||
| (4 intermediate revisions by the same user not shown) | |||
Line 203:
var idx = 0, node;
while (idx < list.length && (node = walker.nextNode())) {
// .fig-src in the guard = idempotency: re-running the tagger
if (node.parentElement.closest('table, .fig-popover')) { continue; }▼
// (staging-copy injection during verification) must never
// nest a second wrapper inside an already-tagged figure
'table, .fig-card, .fig-banner, .fig-src')) { continue; }
if (chunkOf(node) !== parseInt(chunk, 10)) { break; }
var at, from = 0;
Line 246 ⟶ 250:
var tables = Array.prototype.filter.call(
document.querySelectorAll('#mw-content-text table.wikitable'),
function (t) { return !t.closest('.fig-
var grids = tables.map(expandTable);
var located = sidecar.figures.concat(sidecar.unmatched || []);
Line 300 ⟶ 304:
if (label && label !== el) { parts.push(cellText(label)); }
} else {
// Address for a prose figure, outer -> inner: the enclosing
parts.push('chunk ' + entry.loc.chunk);▼
// section heading, then the CHUNK TITLE — which lives INSIDE the
// marker's own <p> ("[c. 3; p. 1] Gross written premiums and
// underlying earnings"), so it is the paragraph text minus the
// .ed-chunk span. "chunk 3" appears nowhere: readers get words.
var anchor = document.querySelector(
while (up && !/^H[1-4]$/.test(up.tagName)) {
parts.push(up.textContent.replace(/\s+/g, ' ').trim());
clone.querySelectorAll('.ed-chunk').forEach(function (s) {
var title = clone.textContent.replace(/\s+/g, ' ').trim();
}
}
// one line, middle-dot separated ("Solvency II ratio (%) · FY24 · …")
Line 336 ⟶ 362:
}
function renderCrop(container, entry, pdf
if (!entry.rect) { return; }
pdf.page(entry.page).then(function (pg) {
var s = pg.viewport.scale;
var x0 = Math.max(0, (entry.rect[0] - CROP_MARGIN_X) * s);
Line 372 ⟶ 397:
}
function onAway(e) {
// clicks INSIDE the surface never dismiss it — the open link
// must be clickable on both surfaces
if (!cueOf(e)) { close(); }
}
Line 404 ⟶ 432:
}, false);
} else {
//
// UI, which the user preferred over a hover peek (and which the
document.addEventListener('mouseover', function (e) {▼
// touch banner mirrors). The card carries the open link, so
// unlike the footnote hover popover it is interactive.
var cue = cueOf(e);
if (!cue
e.preventDefault();
e.stopPropagation();
close();
activeCue = cue;
Line 413 ⟶ 447:
box = document.createElement('div');
box.className = 'fig-card';
box.innerHTML = peekHtml(cue, entry,
document.body.appendChild(box);
// page like the
setTimeout(function ()
}, false);
▲ });
▲ if (!activeCue) { return; }
▲ var to = e.relatedTarget;
▲ if (to && to.closest &&
▲ close();
▲ });
▲ if (box) { close(); }
▲ }, true);
▲ document.addEventListener('click', function (e) {
▲ var cue = cueOf(e);
▲ if (!cue) { return; }
▲ var entry = byEl.get(cue);
▲ if (!entry.id) { return; }
▲ '_blank');
});
}
Line 557 ⟶ 570:
// --text-dark because body-attached elements inherit the SKIN's
// #202122, not the content area's ink.
// absolute (page coords) so it scrolls with the page like the
'.fig-card{position:fixed;z-index:2147483647;' +▼
// original popover; interactive because it carries the open link
'max-width:min(420px,90vw);background:#fff;padding:0;' +
'border:1px solid #0d0d0d;color:var(--text-dark,#0d0d0d);' +
'box-shadow:0 4px 16px rgba(43,41,38,.18);pointer-events:
// full-bleed crop in both surfaces (declare border/margin — an
// omitted property lets a stale stacked stylesheet rule survive)
| |||