Hash fix for API page and inline documentation
This commit is contained in:
parent
a92480742a
commit
d31d26b2df
2 changed files with 46 additions and 7 deletions
|
@ -2,20 +2,34 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiate search functionality
|
||||||
|
*/
|
||||||
|
|
||||||
let jets = new Jets({
|
let jets = new Jets({
|
||||||
searchTag: "#input-search",
|
contentTag: "#toc",
|
||||||
contentTag: "#toc"
|
searchTag: "#input-search"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset search on page load
|
||||||
|
*/
|
||||||
|
|
||||||
|
$("#input-search")[0].value = "";
|
||||||
|
|
||||||
$("#input-search")[0].value = ""; // reset on page load
|
/**
|
||||||
|
* Activate search
|
||||||
|
*/
|
||||||
|
|
||||||
$("#input-search").on("keyup", () => {
|
$("#input-search").on("keyup", () => {
|
||||||
if ($("#input-search").val()) $(".api__toc__search__clear").addClass("active");
|
if ($("#input-search").val()) $(".api__toc__search__clear").addClass("active");
|
||||||
else $(".api__toc__search__clear").removeClass("active");
|
else $(".api__toc__search__clear").removeClass("active");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cancel search
|
||||||
|
*/
|
||||||
|
|
||||||
$(".api__toc__search__clear").on("click", () => {
|
$(".api__toc__search__clear").on("click", () => {
|
||||||
$("#input-search")[0].value = "";
|
$("#input-search")[0].value = "";
|
||||||
$(".api__toc__search__clear").removeClass("active");
|
$(".api__toc__search__clear").removeClass("active");
|
||||||
|
@ -23,14 +37,27 @@ $(".api__toc__search__clear").on("click", () => {
|
||||||
reinitJets();
|
reinitJets();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add hash to URL bar when sidebar links are clicked
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(".api__toc__item a").on("click", event => {
|
||||||
|
const hash = event.currentTarget.href.split("#")[1];
|
||||||
|
history.replaceState({}, "", `#${hash}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// H E L P E R
|
// H E L P E R
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reinitialize search functionality
|
||||||
|
*/
|
||||||
|
|
||||||
function reinitJets() {
|
function reinitJets() {
|
||||||
jets = new Jets({
|
jets = new Jets({
|
||||||
searchTag: "#input-search",
|
contentTag: "#toc",
|
||||||
contentTag: "#toc"
|
searchTag: "#input-search"
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#input-search").focus();
|
$("#input-search").focus();
|
||||||
|
|
|
@ -2,13 +2,25 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add page-specific styling
|
||||||
|
*/
|
||||||
|
|
||||||
document.getElementsByTagName("body")[0].classList.add("glossary");
|
document.getElementsByTagName("body")[0].classList.add("glossary");
|
||||||
|
|
||||||
$("[data-action='toggle glossary sidebar']").on("click", () => { // Toggle sidebar
|
/**
|
||||||
|
* Toggle sidebar
|
||||||
|
*/
|
||||||
|
|
||||||
|
$("[data-action='toggle glossary sidebar']").on("click", () => {
|
||||||
$("body").toggleClass("sidebar-closed");
|
$("body").toggleClass("sidebar-closed");
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".component--glossary-toc li a").on("click", event => { // Add hash to URL bar
|
/**
|
||||||
|
* Add hash to URL bar when sidebar links are clicked
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(".component--glossary-toc li a").on("click", event => {
|
||||||
const hash = event.currentTarget.href.split("#")[1];
|
const hash = event.currentTarget.href.split("#")[1];
|
||||||
history.replaceState({}, "", `#${hash}`);
|
history.replaceState({}, "", `#${hash}`);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue