jBox: When an anchor in a menu is clicked, menu is now hidden
authorDan
Sun, 11 Jan 2009 21:34:27 -0500
changeset 806 543c05f86303
parent 805 b2dc28b9f367
child 807 34e8bf0f25e1
jBox: When an anchor in a menu is clicked, menu is now hidden
includes/clientside/static/dropdown.js
--- a/includes/clientside/static/dropdown.js	Sun Jan 11 21:32:24 2009 -0500
+++ b/includes/clientside/static/dropdown.js	Sun Jan 11 21:34:27 2009 -0500
@@ -83,6 +83,19 @@
                 domObjChangeOpac(0, ul);
                 ul.style.display = 'block';
                 ul.style.zIndex = getHighestZ() + 2;
+                var links = ul.getElementsByTagName('a');
+                for ( var j = 0; j < links.length; j++ )
+                {
+                  links[j].onmouseup = function()
+                  {
+                    var ul = this;
+                    while ( ul.tagName != 'UL' && ul.tagName != 'DIV' && ul.tagName != 'BODY' )
+                      ul = ul.parentNode;
+                    if ( ul.tagName == 'BODY' )
+                      return false;
+                    jBoxHideMenu(ul.previousSibling, ul);
+                  }
+                }
                 var dim = fetch_dimensions(ul);
                 if ( !ul.id )
                   ul.id = 'jBoxmenuobj_' + Math.floor(Math.random() * 10000000);
@@ -204,22 +217,26 @@
   
   if (!isOverObj(a, false, event) && !isOverObj(ul, true, event))
   {
-    $dynano(a).rmClass('liteselected');
-    
-    if ( jBox_slide_enable )
-    {
-      slideIn(ul);
-    }
-    else
-    {
-      ul.style.display = 'none';
-    }
-    
+    jBoxHideMenu(a, ul);
   }
   
   return true;
 }
 
+function jBoxHideMenu(a, ul)
+{
+  $dynano(a).rmClass('liteselected');
+    
+  if ( jBox_slide_enable )
+  {
+    slideIn(ul);
+  }
+  else
+  {
+    ul.style.display = 'none';
+  }
+}
+
 // Slide an element downwards until it is at full height.
 // First parameter should be a DOM object with style.display = block and opacity = 0.