UI plugins: Fix side nav behavior

Due to usability issues, any UI plugins that add a main section (via the
addSection function) will now be shown in the 'Plugins' area by clicking
on the relevant tile. This is to prevent overflow of the side nav bar
caused by too many plugins being loaded.
This commit is contained in:
Brian Federle 2013-10-31 11:26:48 -07:00
parent addf5b0f8c
commit 152e23a00b
3 changed files with 25 additions and 5 deletions

View File

@ -51,7 +51,8 @@
},
addSection: function(section) {
cloudStack.sections[section.id] = $.extend(section, {
customIcon: 'plugins/' + section.id + '/icon.png'
customIcon: 'plugins/' + section.id + '/icon.png',
isPlugin: true
});
},
extend: function(obj) {

View File

@ -52,6 +52,14 @@
var $browser = $('#browser .container');
$plugin.click(function() {
var $mainSection = $('#navigation ul li').filter('.' + plugin.id);
if ($mainSection.size()) {
$mainSection.click();
return;
}
$browser.cloudBrowser('addPanel', {
title: plugin.title,
$parent: $('.panel:first'),

View File

@ -61,6 +61,10 @@
);
}
if (args.isPlugin) {
$li.hide();
}
$li.appendTo($navList);
return true;
@ -84,18 +88,25 @@
return $(this).hasClass(sectionID);
});
var data = args.sections[sectionID];
var isPlugin = data.isPlugin;
data.$browser = $browser;
$navItem.siblings().removeClass('active');
$navItem.addClass('active');
// Reset browser panels
$browser.cloudBrowser('removeAllPanels');
if (!isPlugin) {
$navItem.siblings().removeClass('active');
$navItem.addClass('active');
$browser.cloudBrowser('removeAllPanels');
}
$browser.cloudBrowser('addPanel', {
title: '<span class="section">' + _l(data.title) + '</span>' + '<span class="subsection"></span>',
data: '',
complete: function($panel, $breadcrumb) {
$breadcrumb.attr('title', _l(data.title));
if(!isPlugin) {
$breadcrumb.attr('title', _l(data.title));
}
data.$breadcrumb = $breadcrumb;
// Hide breadcrumb if this is the home section