]> git.openstreetmap.org Git - rails.git/blobdiff - public/javascripts/menu.js
Use configuration variables for limiting nearby users, and bump the number to 30
[rails.git] / public / javascripts / menu.js
index 7a0cbf4198042fcb658e53e499147f222444a189..9f88f0e0cbea4ba8096e74a53533af3d6f0e3763 100644 (file)
@@ -14,12 +14,14 @@ function openMenu(anchor, menu) {
  * Callback called when the mouse enters a menu anchor.
  */
 function enterMenuAnchor(event, anchor, menu, delay) {
-  clearTimeout(menu.timer);
+  if (!anchor.hasClassName("disabled")) {
+    clearTimeout(menu.timer);
 
-  if (delay > 0) {
-    menu.timer = setTimeout(function () { openMenu(anchor, menu) }, delay);
-  } else {
-    openMenu(event, menu);
+    if (delay > 0) {
+      menu.timer = setTimeout(function () { openMenu(anchor, menu) }, delay);
+    } else {
+      openMenu(event, menu);
+    }
   }
 }
 
@@ -27,7 +29,7 @@ function enterMenuAnchor(event, anchor, menu, delay) {
  * Callback called when the mouse leaves a menu anchor.
  */
 function leaveMenuAnchor(event, anchor, menu) {
-  var to = event.relatedTarget || event.toElement;
+  var to = event.relatedTarget;
 
   if (to != menu && !to.descendantOf(menu)) {
     menu.style.display = "none";
@@ -40,7 +42,7 @@ function leaveMenuAnchor(event, anchor, menu) {
  * Callback called when the mouse leaves a menu.
  */
 function leaveMenu(event, anchor, menu) {
-  var to = event.relatedTarget || event.toElement;
+  var to = event.relatedTarget;
 
   if (to != anchor && !to.descendantOf(menu)) {
     menu.style.display = "none";
@@ -56,7 +58,7 @@ function createMenu(anchorid, menuid, delay) {
   var anchor = $(anchorid);
   var menu = $(menuid);
 
-  anchor.onmouseover = function (event) { enterMenuAnchor(anchor, anchor, menu, delay) };
-  anchor.onmouseout = function (event) { leaveMenuAnchor(event, anchor, menu) };
-  menu.onmouseout = function (event) { leaveMenu(event, anchor, menu) };
+  anchor.observe("mouseover", function (event) { enterMenuAnchor(anchor, anchor, menu, delay) });
+  anchor.observe("mouseout", function (event) { leaveMenuAnchor(event, anchor, menu) });
+  menu.observe("mouseout", function (event) { leaveMenu(event, anchor, menu) });
 }