MediaWiki:Gadget-GrAnnotations.js: Difference between revisions
No edit summary |
No edit summary |
||
| Line 820: | Line 820: | ||
setTimeout(function(){ | setTimeout(function(){ | ||
var $card = $paneBookmarks.find('[data-gra-id="'+id+'"]'); | var $card = $paneBookmarks.find('[data-gra-id="'+id+'"]'); | ||
if ($card.length) $card[0].scrollIntoView({behavior:'smooth', block:'nearest'}); | // CHANGED: was missing the gra-card-active flash entirely (only | ||
// notes and footnotes had it) — a separate inconsistency from | |||
// the CSS gap below. Now matches the other two exactly. | |||
if ($card.length) { | |||
$card.addClass('gra-card-active'); | |||
$card[0].scrollIntoView({behavior:'smooth', block:'nearest'}); | |||
setTimeout(function(){ $card.removeClass('gra-card-active'); }, 2000); | |||
} | |||
}, 100); | }, 100); | ||
}); | }); | ||
| Line 926: | Line 933: | ||
} | } | ||
// | // CHANGED: was targeting .gra-hl-active — the WRONG class. That one is | ||
// | // used by scrollToHighlight (panel card clicked -> scrolls to text in | ||
// | // the document), which was already working correctly. The actual | ||
// the | // reported gap is the OTHER direction — clicking a footnote/bookmark | ||
// | // IN THE DOCUMENT should scroll to and flash-highlight the | ||
// | // corresponding card in the panel — and that direction uses a | ||
// | // DIFFERENT class, .gra-card-active (see the three highlight click | ||
// .gra- | // handlers above). Confirmed directly: the note, bookmark, and | ||
// .gra- | // footnote click handlers are structurally identical in code (same | ||
// .gra- | // addClass/scrollIntoView/removeClass sequence) — the gap can only be | ||
// | // CSS, most likely .gra-card-active having a rule scoped to | ||
// .gra-note-card (the oldest, most established of the three) but no | |||
// matching rule for .gra-bookmark-card or .gra-footnote-card. This | |||
// rule is unconditional across all three card classes. | |||
function injectAnnotationCss() { | function injectAnnotationCss() { | ||
if (document.getElementById('gra-hl-active-css')) return; | if (document.getElementById('gra-hl-active-css')) return; | ||
var css = [ | var css = [ | ||
'.gra-hl-active{background:#fff176!important;border-radius:2px;box-shadow:0 0 0 2px #ffb300!important;transition:background 0.3s,box-shadow 0.3s;}', | '.gra-hl-active{background:#fff176!important;border-radius:2px;box-shadow:0 0 0 2px #ffb300!important;transition:background 0.3s,box-shadow 0.3s;}', | ||
'.gra-note-card.gra-card-active,.gra-bookmark-card.gra-card-active,.gra-footnote-card.gra-card-active{background:#fdf0eb!important;box-shadow:0 0 0 2px #b5451b!important;transition:background 0.3s,box-shadow 0.3s;}', | |||
].join('\n'); | ].join('\n'); | ||
var style = document.createElement('style'); | var style = document.createElement('style'); | ||