| 1 |
var menu_timeout = null; |
| 2 |
|
| 3 |
function set_visible(menu, b) |
| 4 |
{ |
| 5 |
var category = menu.children[0]; |
| 6 |
var dropdown = menu.children[1]; |
| 7 |
// category.style['border-radius'] = b && dropdown != null ? '4px 4px 0px 0px' : '4px'; |
| 8 |
if (dropdown != null) { |
| 9 |
dropdown.style.visibility = b ? 'visible' : 'hidden'; |
| 10 |
} |
| 11 |
} |
| 12 |
|
| 13 |
function find_enclosing_menu(el) |
| 14 |
{ |
| 15 |
while (!el.classList.contains('menu')) { |
| 16 |
el = el.parentNode; |
| 17 |
} |
| 18 |
return el; |
| 19 |
} |
| 20 |
|
| 21 |
/* Find the menu above this element and open its popup. */ |
| 22 |
function menu_open_popup(el) |
| 23 |
{ |
| 24 |
menu_close_all(); |
| 25 |
set_visible(el, true); |
| 26 |
} |
| 27 |
|
| 28 |
function menu_leave() |
| 29 |
{ |
| 30 |
if (menu_timeout != null) { |
| 31 |
window.clearTimeout(menu_timeout); |
| 32 |
} |
| 33 |
menu_timeout = window.setTimeout(menu_close_all, 300); |
| 34 |
} |
| 35 |
|
| 36 |
function menu_close_all() |
| 37 |
{ |
| 38 |
for (let menu of document.getElementsByClassName('menu')) { |
| 39 |
set_visible(menu, false); |
| 40 |
} |
| 41 |
if (menu_timeout != null) { |
| 42 |
window.clearTimeout(menu_timeout); |
| 43 |
menu_timeout = null; |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
document.onclick = menu_close_all(); |