cloudBrowser / list view UI: Show subsection in breadcrumb

If in a section with multiple subsections, show active subsection in
the breadcrumb.

For example, if in storage->snapshots, display 'Storage - Snapshots'
based on the 'title' attribute for the main section and subsetion.

-- Note: this disables the 'fixSize' functionality which resizes long
   breadcrumb trails, due to incompatibility with this new feature. It
   is going to be reimplemented anyway, as it is fairly glitchy in its
   current incarnation.
This commit is contained in:
Brian Federle 2012-08-01 13:24:19 -07:00
parent e49f07e0e3
commit f6cc891831
3 changed files with 19 additions and 43 deletions

View File

@ -70,17 +70,20 @@
return $(this).hasClass(sectionID);
});
var data = args.sections[sectionID];
data.$browser = $browser;
$navItem.siblings().removeClass('active');
$navItem.addClass('active');
// Reset browser panels
$browser.cloudBrowser('removeAllPanels');
$browser.cloudBrowser('addPanel', {
title: _l(data.title),
title: '<span class="section">' + _l(data.title) + '</span>' + '<span class="subsection"></span>',
data: '',
complete: function($panel) {
complete: function($panel, $breadcrumb) {
$breadcrumb.attr('title', _l(data.title));
data.$breadcrumb = $breadcrumb;
// Hide breadcrumb if this is the home section
if (args.home === sectionID) {
$('#breadcrumbs').find('li:first, div.end:last').hide();

View File

@ -17,41 +17,6 @@
* Breadcrumb-related functions
*/
var _breadcrumb = cloudStack.ui.widgets.browser.breadcrumb = {
fixSize: function($breadcrumbContainer) {
var width = 0;
var containerWidth = $breadcrumbContainer.width();
var $elems = $breadcrumbContainer.find('ul li, div');
$elems.each(function() {
width += $(this).width();
});
if (width > containerWidth) {
$elems.filter('li').each(function() {
var targetWidth = $(this).width() - (
(width - containerWidth) / $elems.filter('li').size()
) - 10;
$(this).width(targetWidth);
// Concatenate title
var $text = $(this).find('span');
var text = $(this).attr('title');
$text.html(
text
.substring(0, text.length - targetWidth / 15)
.concat('...')
);
});
} else {
$elems.css({ width: '' });
$elems.find('span').each(function() {
$(this).html($(this).closest('li').attr('title'));
});
}
},
/**
* Generate new breadcrumb
*/
@ -240,7 +205,6 @@
.removeClass('maximized')
.addClass('reduced')
).removeClass('active maximized');
_breadcrumb.fixSize($('#breadcrumbs'));
$toRemove.animate(
_panel.initialState($container),
@ -323,8 +287,6 @@
.addClass('active')
.appendTo('#breadcrumbs ul');
_breadcrumb.fixSize($('#breadcrumbs'));
// Reduced appearance for previous panels
$panel.siblings().filter(function() {
return $(this).index() < $panel.index();
@ -345,7 +307,7 @@
$panel.css(
{ left: targetPosition }
);
if (args.complete) args.complete($panel);
if (args.complete) args.complete($panel, _breadcrumb.filter($panel));
} else {
// Animate slide-in
$panel.animate({ left: targetPosition }, {
@ -372,7 +334,6 @@
this.element.find('div.panel').remove();
$('#breadcrumbs').find('ul li').remove();
$('#breadcrumbs').find('ul div.end').remove();
_breadcrumb.fixSize($('#breadcrumbs'));
}
});

View File

@ -1115,6 +1115,18 @@
if (section) {
listViewData = args.sections[section].listView;
var sectionTitle = _l(args.title);
var subsectionTitle = _l(args.sections[section].title);
// Show subsection in breadcrumb
if ((sectionTitle && subsectionTitle) && (sectionTitle != subsectionTitle)) {
args.$breadcrumb.find('span.subsection').html(' - ' + subsectionTitle);
args.$breadcrumb.attr('title', sectionTitle + ' - ' + subsectionTitle);
} else {
args.$breadcrumb.find('span.subsection').html('');
args.$breadcrumb.attr('title', sectionTitle);
}
}
// Create table and other elems