From 0ebf24ca764ebe3a58c224189c721385968e3d38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tino=20V=C3=A1zquez?= Date: Fri, 15 Jul 2011 18:51:09 +0200 Subject: [PATCH] Missing sunstone changes --- src/sunstone/public/js/layout.js | 12 +++++++++-- src/sunstone/public/js/sunstone-util.js | 5 ++++- src/sunstone/public/js/sunstone.js | 28 +++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/sunstone/public/js/layout.js b/src/sunstone/public/js/layout.js index 2f0340cc10..aaf21f9b1c 100644 --- a/src/sunstone/public/js/layout.js +++ b/src/sunstone/public/js/layout.js @@ -57,11 +57,19 @@ function showTab(tabname){ $(document).ready(function () { $(".tab").hide(); - $(".outer-west ul li a").live("click",function(){ + $(".outer-west ul li.subTab a").live("click",function(){ var tab = $(this).attr('href'); showTab(tab); return false; - }) + }); + + $(".outer-west ul li.topTab a").live("click",function(){ + var tab = $(this).attr('href'); + //toggle subtabs trick + $('li.'+tab.substr(1)).toggle(); + showTab(tab); + return false; + }); outerLayout = $('body').layout({ applyDefaultStyles: false diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index 845ba1c647..dadc422efb 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -670,4 +670,7 @@ function True(){ } function False(){ return false; -} \ No newline at end of file +} + +function Empty(){ +}; diff --git a/src/sunstone/public/js/sunstone.js b/src/sunstone/public/js/sunstone.js index 02d808c99d..c642261d6f 100644 --- a/src/sunstone/public/js/sunstone.js +++ b/src/sunstone/public/js/sunstone.js @@ -283,6 +283,7 @@ $(document).ready(function(){ //Insert the tabs in the DOM and their buttons. insertTabs(); + //hideSubTabs(); insertButtons(); //Enhace the look of select buttons @@ -381,7 +382,10 @@ function setLogin(){ $("#user").html(username); $("#logout").click(function(){ - OpenNebula.Auth.logout({ + //todo, this is ugly + var f_logout = typeof(OpenNebula)!="undefined"? + OpenNebula.Auth.logout : oZones.Auth.logout; + f_logout({ success:function(){ window.location.href = "login"; } @@ -405,14 +409,34 @@ function insertTabs(){ function insertTab(tab_name){ var tab_info = SunstoneCfg["tabs"][tab_name]; var condition = tab_info["condition"]; + var tabClass = tab_info["tabClass"]; + var parent = ""; + + if (!tabClass) { + tabClass="topTab"; + } else if (tabClass=="subTab") { + parent = tab_info["parentTab"]; + }; + //skip this tab if we do not meet the condition if (condition && !condition()) {return;} $("div.inner-center").append('
'); $('div#'+tab_name).html(tab_info.content); - $('ul#navigation').append('
  • '+tab_info.title+'
  • '); + $('ul#navigation').append('
  • '+tab_info.title+'
  • '); } +function hideSubTabs(){ + for (tab in SunstoneCfg["tabs"]){ + var tab_info = SunstoneCfg["tabs"][tab]; + var tabClass = tab_info["tabClass"]; + if (tabClass=="subTab"){ + $('#li_'+tab).hide(); + }; + }; +} + + //Inserts the buttons of all tabs. function insertButtons(){