Add a dedicated background_click function.
This commit is contained in:
parent
635bf27c1e
commit
da0e6a59f7
2 changed files with 15 additions and 2 deletions
|
@ -250,7 +250,8 @@ function create(photo, view)
|
||||||
photo_card.appendChild(toolbutton);
|
photo_card.appendChild(toolbutton);
|
||||||
|
|
||||||
const photo_card_tools = document.createElement("div");
|
const photo_card_tools = document.createElement("div");
|
||||||
photo_card_tools.className = "photo_card_tools";
|
photo_card_tools.classList.add("photo_card_tools");
|
||||||
|
photo_card_tools.classList.add("contextmenu");
|
||||||
photo_card_tools.onclick = "event.stopPropagation(); return;";
|
photo_card_tools.onclick = "event.stopPropagation(); return;";
|
||||||
photo_card.appendChild(photo_card_tools);
|
photo_card.appendChild(photo_card_tools);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
const contextmenus = {};
|
const contextmenus = {};
|
||||||
|
|
||||||
|
contextmenus.background_click =
|
||||||
|
function background_click(event)
|
||||||
|
{
|
||||||
|
const contextmenu = event.target.closest(".contextmenu");
|
||||||
|
if (! contextmenu)
|
||||||
|
{
|
||||||
|
contextmenus.hide_open_menus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
contextmenus.hide_open_menus =
|
contextmenus.hide_open_menus =
|
||||||
function hide_open_menus()
|
function hide_open_menus()
|
||||||
{
|
{
|
||||||
|
@ -32,6 +44,6 @@ function show_menu(event, menu)
|
||||||
|
|
||||||
function on_pageload()
|
function on_pageload()
|
||||||
{
|
{
|
||||||
document.body.addEventListener("click", contextmenus.hide_open_menus);
|
document.body.addEventListener("click", contextmenus.background_click);
|
||||||
}
|
}
|
||||||
document.addEventListener("DOMContentLoaded", on_pageload);
|
document.addEventListener("DOMContentLoaded", on_pageload);
|
||||||
|
|
Loading…
Reference in a new issue