4 function openMenu(anchor, menu) {
5 menu.style.display = "block";
7 menu.clonePosition(anchor, {
8 setLeft: true, setTop: true, setWidth: false, setHeight: false,
9 offsetLeft: 0, offsetTop: anchor.getHeight()
16 function closeMenu(menu) {
17 clearTimeout(menu.timer);
18 menu.style.display = "none";
22 * Callback called when the mouse enters a menu anchor.
24 function enterMenuAnchor(event, anchor, menu, delay) {
25 if (!anchor.hasClassName("disabled")) {
26 clearTimeout(menu.timer);
29 menu.timer = setTimeout(function () { openMenu(anchor, menu) }, delay);
31 openMenu(event, menu);
37 * Callback called when the mouse leaves a menu anchor.
39 function leaveMenuAnchor(event, anchor, menu) {
40 var to = event.relatedTarget;
42 if (to != menu && !to.descendantOf(menu)) {
43 menu.style.display = "none";
46 clearTimeout(menu.timer);
50 * Callback called when the mouse leaves a menu.
52 function leaveMenu(event, anchor, menu) {
53 var to = event.relatedTarget;
55 if (to != anchor && !to.descendantOf(menu)) {
56 menu.style.display = "none";
59 clearTimeout(menu.timer);
63 * Setup a menu, triggered by hovering over an anchor for a given time.
65 function createMenu(anchorid, menuid, delay) {
66 var anchor = $(anchorid);
69 anchor.observe("mouseup", function (event) { closeMenu(menu) });
70 anchor.observe("mouseover", function (event) { enterMenuAnchor(anchor, anchor, menu, delay) });
71 anchor.observe("mouseout", function (event) { leaveMenuAnchor(event, anchor, menu) });
72 menu.observe("mouseup", function (event) { closeMenu(menu) });
73 menu.observe("mouseout", function (event) { leaveMenu(event, anchor, menu) });