From 8086fb4b3c351679ec8875ac485125d1d267dccb Mon Sep 17 00:00:00 2001 From: Johannes Wollert Date: Fri, 6 Dec 2013 13:21:11 +0100 Subject: [PATCH] enable possibility to have multiple active top menus --- app/assets/javascripts/top_menu.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/top_menu.js b/app/assets/javascripts/top_menu.js index dfc1925399..dbcebfe1bd 100644 --- a/app/assets/javascripts/top_menu.js +++ b/app/assets/javascripts/top_menu.js @@ -240,9 +240,22 @@ } }); + // this holds all top menus currently active. + // if one opens, all others are closed. + var top_menus = []; $.fn.top_menu = function () { + var new_menu; $(this).each(function () { - new TopMenu($(this)); + new_menu = new TopMenu($(this)); + top_menus.each(function (menu) { + menu.menu_container.on("openedMenu", function () { + new_menu.closing(); + }); + new_menu.menu_container.on("openedMenu", function () { + menu.closing(); + }); + }); + top_menus.push(new_menu); }); } }(jQuery));