From 74e3d1f48bab315bd5c2bbcc118fdaff925905a2 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Fri, 28 Aug 2015 14:21:23 +0200 Subject: [PATCH] (mvc/menu) hide empty menu options for second level containers as well --- src/opnsense/mvc/app/views/layouts/default.volt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/opnsense/mvc/app/views/layouts/default.volt b/src/opnsense/mvc/app/views/layouts/default.volt index 8b13404a4..7ff1687e8 100644 --- a/src/opnsense/mvc/app/views/layouts/default.volt +++ b/src/opnsense/mvc/app/views/layouts/default.volt @@ -53,9 +53,18 @@ }); // hide empty menu items - $('#mainmenu > div > .collapse').each(function(){ + $('#mainmenu > div > .collapse').each(function () { + // cleanup empty second level menu containers + $(this).find("div.collapse").each(function () { + if ($(this).children().length == 0) { + $("#mainmenu").find('[href="#' + $(this).attr('id') + '"]').remove(); + $(this).remove(); + } + }); + + // cleanup empty first level menu items if ($(this).children().length == 0) { - $("#mainmenu").find('[href="#'+$(this).attr('id')+'"]').remove(); + $("#mainmenu").find('[href="#' + $(this).attr('id') + '"]').remove(); } });