doc: decrease letter count for search to 2 (#10214)
parent
607dbd36d7
commit
9ee1d8c848
|
@ -1,4 +1,4 @@
|
||||||
(function() {
|
(function () {
|
||||||
if (document.body.scrollIntoView) {
|
if (document.body.scrollIntoView) {
|
||||||
var docnav = document.querySelector('.doc-nav');
|
var docnav = document.querySelector('.doc-nav');
|
||||||
var active = docnav.querySelector('li.active');
|
var active = docnav.querySelector('li.active');
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
function setupScrollSpy() {
|
function setupScrollSpy() {
|
||||||
var sectionPositions = [];
|
var sectionPositions = [];
|
||||||
var sections = document.querySelectorAll('section');
|
var sections = document.querySelectorAll('section');
|
||||||
sections.forEach(function(section) {
|
sections.forEach(function (section) {
|
||||||
sectionPositions.push(section.offsetTop);
|
sectionPositions.push(section.offsetTop);
|
||||||
});
|
});
|
||||||
var scrollPos = 0;
|
var scrollPos = 0;
|
||||||
window.addEventListener('scroll', function(e) {
|
window.addEventListener('scroll', function (e) {
|
||||||
// Reset classes
|
// Reset classes
|
||||||
document.querySelectorAll('.doc-toc a[class="active"]').forEach(function(link) {
|
document.querySelectorAll('.doc-toc a[class="active"]').forEach(function (link) {
|
||||||
link.classList.remove('active');
|
link.classList.remove('active');
|
||||||
});
|
});
|
||||||
// Set current menu link as active
|
// Set current menu link as active
|
||||||
|
@ -52,7 +52,7 @@ function setupScrollSpy() {
|
||||||
|
|
||||||
function setupMobileToggle() {
|
function setupMobileToggle() {
|
||||||
var toggle = document.getElementById('toggle-menu');
|
var toggle = document.getElementById('toggle-menu');
|
||||||
toggle.addEventListener('click', function(ev) {
|
toggle.addEventListener('click', function (ev) {
|
||||||
var docNav = document.querySelector('.doc-nav');
|
var docNav = document.querySelector('.doc-nav');
|
||||||
var isHidden = docNav.classList.contains('hidden');
|
var isHidden = docNav.classList.contains('hidden');
|
||||||
docNav.classList.toggle('hidden');
|
docNav.classList.toggle('hidden');
|
||||||
|
@ -73,7 +73,7 @@ function setupMobileToggle() {
|
||||||
function setupDarkMode() {
|
function setupDarkMode() {
|
||||||
var html = document.getElementsByTagName('html')[0];
|
var html = document.getElementsByTagName('html')[0];
|
||||||
var darkModeToggle = document.getElementById('dark-mode-toggle');
|
var darkModeToggle = document.getElementById('dark-mode-toggle');
|
||||||
darkModeToggle.addEventListener('click', function() {
|
darkModeToggle.addEventListener('click', function () {
|
||||||
html.classList.toggle('dark');
|
html.classList.toggle('dark');
|
||||||
var isDarkModeEnabled = html.classList.contains('dark');
|
var isDarkModeEnabled = html.classList.contains('dark');
|
||||||
localStorage.setItem('dark-mode', isDarkModeEnabled);
|
localStorage.setItem('dark-mode', isDarkModeEnabled);
|
||||||
|
@ -87,7 +87,7 @@ function setupDarkMode() {
|
||||||
|
|
||||||
function setupSearch() {
|
function setupSearch() {
|
||||||
var searchInput = document.getElementById('search');
|
var searchInput = document.getElementById('search');
|
||||||
var onInputChange = debounce(function(e) {
|
var onInputChange = debounce(function (e) {
|
||||||
var searchValue = e.target.value.toLowerCase();
|
var searchValue = e.target.value.toLowerCase();
|
||||||
var menu = document.querySelector('.doc-nav > .content');
|
var menu = document.querySelector('.doc-nav > .content');
|
||||||
var search = document.querySelector('.doc-nav > .search');
|
var search = document.querySelector('.doc-nav > .search');
|
||||||
|
@ -98,8 +98,8 @@ function setupSearch() {
|
||||||
search.classList.add('hidden');
|
search.classList.add('hidden');
|
||||||
search.classList.remove('has-results');
|
search.classList.remove('has-results');
|
||||||
}
|
}
|
||||||
} else if (searchValue.length > 2) {
|
} else if (searchValue.length >= 2) {
|
||||||
// search for less than 3 characters can display too much results
|
// search for less than 2 characters can display too much results
|
||||||
search.innerHTML = '';
|
search.innerHTML = '';
|
||||||
menu.style.display = 'none';
|
menu.style.display = 'none';
|
||||||
if (search.classList.contains('hidden')) {
|
if (search.classList.contains('hidden')) {
|
||||||
|
@ -156,7 +156,7 @@ function setupSearch() {
|
||||||
title: prefix + ' ' + title,
|
title: prefix + ' ' + title,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
results.sort(function(a, b) {
|
results.sort(function (a, b) {
|
||||||
if (a.title < b.title) {
|
if (a.title < b.title) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ function setupCollapse() {
|
||||||
var dropdownArrows = document.querySelectorAll('.dropdown-arrow');
|
var dropdownArrows = document.querySelectorAll('.dropdown-arrow');
|
||||||
for (var i = 0; i < dropdownArrows.length; i++) {
|
for (var i = 0; i < dropdownArrows.length; i++) {
|
||||||
var dropdownArrow = dropdownArrows[i];
|
var dropdownArrow = dropdownArrows[i];
|
||||||
dropdownArrow.addEventListener('click', function(e) {
|
dropdownArrow.addEventListener('click', function (e) {
|
||||||
var parent = e.target.parentElement.parentElement.parentElement;
|
var parent = e.target.parentElement.parentElement.parentElement;
|
||||||
parent.classList.toggle('open');
|
parent.classList.toggle('open');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue