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()
14 * Callback called when the mouse enters a menu anchor.
16 function enterMenuAnchor(event, anchor, menu, delay) {
17 if (!anchor.hasClassName("disabled")) {
18 clearTimeout(menu.timer);
21 menu.timer = setTimeout(function () { openMenu(anchor, menu) }, delay);
23 openMenu(event, menu);
29 * Callback called when the mouse leaves a menu anchor.
31 function leaveMenuAnchor(event, anchor, menu) {
32 var to = event.relatedTarget;
34 if (to != menu && !to.descendantOf(menu)) {
35 menu.style.display = "none";
38 clearTimeout(menu.timer);
42 * Callback called when the mouse leaves a menu.
44 function leaveMenu(event, anchor, menu) {
45 var to = event.relatedTarget;
47 if (to != anchor && !to.descendantOf(menu)) {
48 menu.style.display = "none";
51 clearTimeout(menu.timer);
55 * Setup a menu, triggered by hovering over an anchor for a given time.
57 function createMenu(anchorid, menuid, delay) {
58 var anchor = $(anchorid);
61 anchor.observe("mouseover", function (event) { enterMenuAnchor(anchor, anchor, menu, delay) });
62 anchor.observe("mouseout", function (event) { leaveMenuAnchor(event, anchor, menu) });
63 menu.observe("mouseout", function (event) { leaveMenu(event, anchor, menu) });