-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.js
67 lines (55 loc) · 1.59 KB
/
menu.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var timeout = 200; // no 2 actions can be performed within this period
var menutimer = new Object;
var ddmenuitem = new Object;
var menucolored = new Object;
// open hidden layer
function mopen(menu,id)
{
// document.getElementById('debug').innerHTML+= "mopen"+menu+"/"+id+"<br/>";
// close old layer
mclose(menu);
// get new layer and show it
ddmenuitem[menu] = document.getElementById(id);
ddmenuitem[menu].removeAttribute('hidden');
}
// close showed layer
function mclose(menu)
{
// cancel timer
mcanceltimer(menu);
if (ddmenuitem[menu]) ddmenuitem[menu].hidden = true; // as usual true means nothing here
ddmenuitem[menu]=null;
menutimer[menu] = window.setTimeout(mnothing, timeout,menu);
}
function mnothing(menu) // temporarily deactive clicking
{
menutimer[menu]=null;
}
// go close timer
function mclosetime(menu)
{
menutimer[menu] = window.setTimeout(mclose, timeout,menu);
}
// cancel close timer
function mcanceltimer(menu)
{
if (menutimer[menu])
{
window.clearTimeout(menutimer[menu]);
menutimer[menu] = null;
}
}
// toggle open/close of a given menu
function mtoggle(menu,id)
{
// document.getElementById('debug').innerHTML= "mtoggle"+ddmenuitem[menu]+"<br/>";
if (menutimer[menu]==null) // only if not busy
if (document.getElementById(id)==ddmenuitem[menu]) mclose(menu); else mopen(menu,id);
}
// style differently the selected title
function mstyle(menu,caller)
{
if (menucolored[menu]) menucolored[menu].className="menu-title";
caller.className="menu-title-active";
menucolored[menu]=caller;
}