Use prototype to capture events so the menus work on IE

This commit is contained in:
Tom Hughes 2010-11-17 15:47:59 +00:00
parent 9c2de4039c
commit 918dd5679f

View file

@ -27,7 +27,7 @@ function enterMenuAnchor(event, anchor, menu, delay) {
* Callback called when the mouse leaves a menu anchor. * Callback called when the mouse leaves a menu anchor.
*/ */
function leaveMenuAnchor(event, anchor, menu) { function leaveMenuAnchor(event, anchor, menu) {
var to = event.relatedTarget || event.toElement; var to = event.relatedTarget;
if (to != menu && !to.descendantOf(menu)) { if (to != menu && !to.descendantOf(menu)) {
menu.style.display = "none"; menu.style.display = "none";
@ -40,7 +40,7 @@ function leaveMenuAnchor(event, anchor, menu) {
* Callback called when the mouse leaves a menu. * Callback called when the mouse leaves a menu.
*/ */
function leaveMenu(event, anchor, menu) { function leaveMenu(event, anchor, menu) {
var to = event.relatedTarget || event.toElement; var to = event.relatedTarget;
if (to != anchor && !to.descendantOf(menu)) { if (to != anchor && !to.descendantOf(menu)) {
menu.style.display = "none"; menu.style.display = "none";
@ -56,7 +56,7 @@ function createMenu(anchorid, menuid, delay) {
var anchor = $(anchorid); var anchor = $(anchorid);
var menu = $(menuid); var menu = $(menuid);
anchor.onmouseover = function (event) { enterMenuAnchor(anchor, anchor, menu, delay) }; anchor.observe("mouseover", function (event) { enterMenuAnchor(anchor, anchor, menu, delay) });
anchor.onmouseout = function (event) { leaveMenuAnchor(event, anchor, menu) }; anchor.observe("mouseout", function (event) { leaveMenuAnchor(event, anchor, menu) });
menu.onmouseout = function (event) { leaveMenu(event, anchor, menu) }; menu.observe("mouseout", function (event) { leaveMenu(event, anchor, menu) });
} }