]> git.donarmstrong.com Git - dactyl.git/blob - common/content/help.js
Import r6923 from upstream hg supporting Firefox up to 22.0a1
[dactyl.git] / common / content / help.js
1 // Copyright (c) 2009-2012 Kris Maglione <kris@vimperator.org>
2 //
3 // This work is licensed for reuse under an MIT license. Details are
4 // given in the LICENSE.txt file included with this file.
5 "use strict";
6
7 function checkFragment() {
8     document.title = document.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "title")[0].textContent;
9
10     function action() {
11         content.scrollTo(0, content.scrollY + elem.getBoundingClientRect().top - 10); // 10px context
12     }
13
14     var frag = document.location.hash.substr(1);
15     if (frag) {
16         var elem = document.getElementById(frag);
17         if (elem) {
18             action();
19             setTimeout(action, 10);
20         }
21     }
22 }
23
24 document.addEventListener("load", checkFragment, true);
25 document.addEventListener("hashChange", checkFragment, true);
26
27 // vim: set fdm=marker sw=4 ts=4 et: