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