1
Fork 0

Fix navbar click while in a search

This commit is contained in:
Guillaume Gomez 2017-11-06 21:14:37 +01:00
parent 58557fafae
commit acd5e8cd4e

View file

@ -122,6 +122,7 @@
}
function highlightSourceLines(ev) {
var search = document.getElementById("search");
var i, from, to, match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
if (match) {
from = parseInt(match[1], 10);
@ -145,6 +146,14 @@
for (i = from; i <= to; ++i) {
addClass(document.getElementById(i), 'line-highlighted');
}
} else if (ev !== null && search && !hasClass(search, "hidden") && ev.newURL) {
addClass(search, "hidden");
removeClass(document.getElementById("main"), "hidden");
var hash = ev.newURL.slice(ev.newURL.indexOf('#') + 1);
var elem = document.getElementById(hash);
if (elem) {
elem.scrollIntoView();
}
}
}
highlightSourceLines(null);