Update html/map.ejs
This commit is contained in:
parent
ceb84e0aea
commit
83ab99d0d7
39
html/map.ejs
39
html/map.ejs
@ -792,32 +792,25 @@ if (bar) {
|
|||||||
closeSearch.style.cursor = "pointer";
|
closeSearch.style.cursor = "pointer";
|
||||||
closeSearch.style.zIndex = "999";
|
closeSearch.style.zIndex = "999";
|
||||||
|
|
||||||
// Add floating X on the suggestions (places) div
|
// attach to search container
|
||||||
const sugg = document.querySelector(".suggest");
|
const searchDiv = document.querySelector(".search");
|
||||||
if (sugg) {
|
searchDiv.style.position = "relative";
|
||||||
const closeBtn = document.createElement("button");
|
searchDiv.appendChild(closeSearch);
|
||||||
closeBtn.textContent = "✕";
|
|
||||||
closeBtn.title = "Clear suggestions";
|
|
||||||
|
|
||||||
// Style: float top-right, no background
|
closeSearch.addEventListener("click", () => {
|
||||||
Object.assign(closeBtn.style, {
|
|
||||||
position: "absolute",
|
document.querySelector("#suggestions").style.display = "none";
|
||||||
top: "6px",
|
|
||||||
right: "8px",
|
|
||||||
border: "none",
|
|
||||||
background: "none",
|
|
||||||
color: "#fff",
|
|
||||||
fontSize: "18px",
|
|
||||||
cursor: "pointer",
|
|
||||||
zIndex: "10"
|
|
||||||
});
|
});
|
||||||
|
|
||||||
sugg.style.position = "relative"; // anchor button inside
|
// shortcut to re-open with `/`
|
||||||
sugg.appendChild(closeBtn);
|
document.addEventListener("keydown", e => {
|
||||||
|
if (e.key === "/") {
|
||||||
closeBtn.addEventListener("click", () => {
|
if (searchDiv.style.display === "none") {
|
||||||
// just clear the list items, keep div visible
|
searchDiv.style.display = "flex";
|
||||||
sugg.querySelectorAll("li").forEach(li => li.remove());
|
document.querySelector("#q").focus();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user