File: menu.js

package info (click to toggle)
jsonnet 0.20.0%2Bds-3.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 16,776 kB
  • sloc: cpp: 23,318; python: 1,788; javascript: 1,003; ansic: 885; sh: 745; makefile: 194; java: 140
file content (47 lines) | stat: -rw-r--r-- 988 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var menu_timeout = null;

function set_visible(menu, b)
{
  var category = menu.children[0];
  var dropdown = menu.children[1];
  // category.style['border-radius'] = b && dropdown != null ? '4px 4px 0px 0px' : '4px';
  if (dropdown != null) {
    dropdown.style.visibility = b ? 'visible' : 'hidden';
  }
}

function find_enclosing_menu(el)
{
  while (!el.classList.contains('menu')) {
    el = el.parentNode;
  }
  return el;
}

/* Find the menu above this element and open its popup. */
function menu_open_popup(el)
{
  menu_close_all();
  set_visible(el, true);
}

function menu_leave()
{
  if (menu_timeout != null) {
    window.clearTimeout(menu_timeout);
  }
  menu_timeout = window.setTimeout(menu_close_all, 300);
}

function menu_close_all()
{
  for (let menu of document.getElementsByClassName('menu')) {
    set_visible(menu, false);
  }
  if (menu_timeout != null) {
    window.clearTimeout(menu_timeout);
    menu_timeout = null;
  }
}

document.onclick = menu_close_all();