From 8d68721a590603e0591bb989e67a2b48e49b8f75 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 26 Mar 2012 13:10:47 +0200 Subject: [PATCH] Sunstone: Append submenus after parents menu. Allows more freedom in the loading order of plugins. Submenus will always be added after parent menu item, or after parents submenus items (so it keeps order). --- src/sunstone/etc/sunstone-plugins.yaml | 10 +++++----- src/sunstone/public/js/sunstone.js | 14 +++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/sunstone/etc/sunstone-plugins.yaml b/src/sunstone/etc/sunstone-plugins.yaml index 7330791c4e..edde7af592 100644 --- a/src/sunstone/etc/sunstone-plugins.yaml +++ b/src/sunstone/etc/sunstone-plugins.yaml @@ -53,6 +53,11 @@ :ALL: true :user: :group: +- plugins/clusters-tab.js: + :ALL: false + :user: + :group: + oneadmin: true - plugins/hosts-tab.js: :ALL: true :user: @@ -65,8 +70,3 @@ :ALL: true :user: :group: -- plugins/clusters-tab.js: - :ALL: false - :user: - :group: - oneadmin: true diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index df9659a96c..20e82c3909 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -465,7 +465,19 @@ function insertTab(tab_name){ $('div#'+tab_name,main_tabs_context).html(tab_info.content); - $('div#menu ul#navigation').append('
  • '+tab_info.title+'
  • '); + var li_item = '
  • '+tab_info.title+'
  • '; + + //if this is a submenu... + if (parent.length) { + var children = $('div#menu ul#navigation li.'+parent); + //if there are other submenus, insert after last of them + if (children.length) + $(children[children.length-1]).after(li_item); + else //instert after parent menu + $('div#menu ul#navigation li#li_'+parent).after(li_item); + } else { //not a submenu, instert in the end + $('div#menu ul#navigation').append(li_item); + }; if (parent){ //this is a subtab $('div#menu li#li_'+tab_name).hide();//hide by default