4 function openMenu(anchor, menu, align) {
9 } else if (align == "right") {
10 offset = anchor.getWidth() - menu.getWidth();
13 menu.clonePosition(anchor, {
14 setLeft: true, setTop: true, setWidth: false, setHeight: false,
15 offsetLeft: offset, offsetTop: anchor.getHeight()
18 menu.style.display = "block";
24 function closeMenu(menu) {
25 clearTimeout(menu.timer);
26 menu.style.display = "none";
30 * Callback called when the mouse enters a menu anchor.
32 function enterMenuAnchor(event, anchor, menu, delay, align) {
33 if (!anchor.hasClassName("disabled")) {
34 clearTimeout(menu.timer);
37 menu.timer = setTimeout(function () { openMenu(anchor, menu, align) }, delay);
39 openMenu(event, menu, align);
45 * Callback called when the mouse leaves a menu anchor.
47 function leaveMenuAnchor(event, anchor, menu) {
48 var to = event.relatedTarget;
50 if (to != menu && !to.descendantOf(menu)) {
51 menu.style.display = "none";
54 clearTimeout(menu.timer);
58 * Callback called when the mouse leaves a menu.
60 function leaveMenu(event, anchor, menu) {
61 var to = event.relatedTarget;
63 if (to != anchor && !to.descendantOf(menu)) {
64 menu.style.display = "none";
67 clearTimeout(menu.timer);
71 * Setup a menu, triggered by hovering over an anchor for a given time.
73 function createMenu(anchorid, menuid, delay, align) {
74 var anchor = $(anchorid);
77 anchor.observe("mouseup", function (event) { closeMenu(menu) });
78 anchor.observe("mouseover", function (event) { enterMenuAnchor(anchor, anchor, menu, delay, align) });
79 anchor.observe("mouseout", function (event) { leaveMenuAnchor(event, anchor, menu) });
80 menu.observe("mouseup", function (event) { closeMenu(menu) });
81 menu.observe("mouseout", function (event) { leaveMenu(event, anchor, menu) });