Added code to automhide all open menus on other menu click

This commit is contained in:
Andre Lorbach 2014-10-29 11:00:07 +01:00
parent 0ce99c2545
commit 8ba569b1eb

View File

@ -447,9 +447,15 @@ function CreateMenuFunction ( szbuttonobjid, szmenuobjid, bHide )
// Hide
menu.hide();
}
$(szbuttonobjid).button()
.click(function() {
/* Hide all other Menus first!*/
$('ul[id^="menu"]').each(function () {
$(this).hide();
});
// Make use of the general purpose show and position operations
// open and place the menu where we want.
menu.show().position({
@ -462,14 +468,14 @@ function CreateMenuFunction ( szbuttonobjid, szmenuobjid, bHide )
// Register a click outside the menu to close it
$( document ).on( "click", function() {
menu.hide();
menu.hide();
});
// Helper function to close a menu by escape key
$( document ).keyup(function(e) {
if (e.keyCode == 27) {
menu.hide();
}
}
});
// Helper function to click a link by keypress
@ -488,8 +494,7 @@ function CreateMenuFunction ( szbuttonobjid, szmenuobjid, bHide )
}
});
// Make sure to return false here or the click registration
// above gets invoked.
// Make sure to return false here or the click registration above gets invoked.
return false;
})
}