1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 22:47:59 +01:00
Files
pentadactyl-pm/vimperator/locale/en-US/help.js
Doug Kearns 1e7158b397 Fix accessing help topics on the current help page.
Only those beneath the current page position were accessible.
2009-03-04 17:25:18 +11:00

25 lines
858 B
JavaScript

function checkFragment()
{
let frag = document.location.hash.substr(1);
if (!frag || document.getElementById(frag))
return;
let elem = document.evaluate('//*[@class="tag" and text()="' + frag + '"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotItem(0);
if (elem)
window.content.scrollTo(0, window.content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context
}
document.addEventListener("load", checkFragment, true);
window.addEventListener("message", function (event) {
if (event.data == "fragmentChange")
checkFragment();
}, true);
document.addEventListener("click", function (event) {
let evt = document.createEvent("UIEvents");
evt.initEvent("liberatorHelpLink", true, true);
event.target.dispatchEvent(evt);
}, true);
// vim: set fdm=marker sw=4 ts=4 et: