lbry.tech/app/dist/scripts/api.js

43 lines
1,014 B
JavaScript
Raw Normal View History

2019-01-17 21:41:26 +01:00
"use strict"; /* global document, Jets */
2018-08-02 00:18:39 +02:00
2018-10-02 00:11:20 +02:00
// Initiate search functionality
2018-08-02 00:18:39 +02:00
let jets = new Jets({
contentTag: "#toc",
searchTag: "#input-search"
2018-08-02 00:18:39 +02:00
});
2018-10-02 00:11:20 +02:00
// Reset search on page load
document.getElementById("input-search").value = "";
2018-08-02 00:18:39 +02:00
2018-10-02 00:11:20 +02:00
// Activate search
document.getElementById("input-search").addEventListener("keyup", () => {
if (document.getElementById("input-search").value)
document.querySelector(".api__toc__search__clear").classList.add("active");
else
document.querySelector(".api__toc__search__clear").classList.remove("active");
2018-08-02 00:18:39 +02:00
});
2018-10-02 00:11:20 +02:00
// Cancel search
document.querySelector(".api__toc__search__clear").addEventListener("click", () => {
document.getElementById("input-search").value = "";
document.querySelector(".api__toc__search__clear").classList.remove("active");
2018-08-02 00:18:39 +02:00
jets.destroy();
reinitJets();
});
// H E L P E R
function reinitJets() {
jets = new Jets({
contentTag: "#toc",
searchTag: "#input-search"
2018-08-02 00:18:39 +02:00
});
2018-10-02 00:11:20 +02:00
document.getElementById("input-search").focus();
2018-08-02 00:18:39 +02:00
}