# HG changeset patch # User Dan # Date 1231727667 18000 # Node ID 543c05f86303be8fb187172c8708a8c7179f7b4c # Parent b2dc28b9f367d634c489195b4064d2c620f291c7 jBox: When an anchor in a menu is clicked, menu is now hidden diff -r b2dc28b9f367 -r 543c05f86303 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.