mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
doc: allow pressing / to focus search bar (#10522)
* type / to focus search; rename unused variables * use ev.preventDefault() instead of setTimeout() * delete doc.js_
This commit is contained in:
parent
21fe91e508
commit
984551227b
@ -20,7 +20,7 @@ function setupScrollSpy() {
|
||||
sectionPositions.push(section.offsetTop);
|
||||
});
|
||||
var scrollPos = 0;
|
||||
window.addEventListener('scroll', function (e) {
|
||||
window.addEventListener('scroll', function (_) {
|
||||
// Reset classes
|
||||
document.querySelectorAll('.doc-toc a[class="active"]').forEach(function (link) {
|
||||
link.classList.remove('active');
|
||||
@ -52,7 +52,7 @@ function setupScrollSpy() {
|
||||
|
||||
function setupMobileToggle() {
|
||||
var toggle = document.getElementById('toggle-menu');
|
||||
toggle.addEventListener('click', function (ev) {
|
||||
toggle.addEventListener('click', function (_) {
|
||||
var docNav = document.querySelector('.doc-nav');
|
||||
var isHidden = docNav.classList.contains('hidden');
|
||||
docNav.classList.toggle('hidden');
|
||||
@ -225,3 +225,11 @@ function debounce(func, timeout) {
|
||||
timer = setTimeout(next, timeout > 0 ? timeout : 300);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('keypress', (ev) => {
|
||||
if (ev.key == '/') {
|
||||
let search = document.getElementById('search');
|
||||
ev.preventDefault();
|
||||
search.focus();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user