fix #2302 (Regression: Using find in Manage Favorite/Featured breaks layout)

This commit is contained in:
rolux 2014-02-13 15:53:26 +00:00 committed by j
parent 8424797cc4
commit cc5ee75564
4 changed files with 26 additions and 9 deletions

View file

@ -1,10 +1,15 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict'; 'use strict';
pandora.ui.folderBrowser = function(id, section) { pandora.ui.folderBrowser = function(id, section) {
var that = Ox.Element(); // Yes, we have to wait for the lists init event to decide if it is shown.
// This run-once init handler runs *after* the list's own init handler.
var i = Ox.getIndexById(pandora.site.sectionFolders[section], id),
that = Ox.Element();
pandora.site.sectionFolders[section][i].hasItems = null;
pandora.$ui.folderList[id] = pandora.ui.folderBrowserList(id, section) pandora.$ui.folderList[id] = pandora.ui.folderBrowserList(id, section)
.bindEvent({ .bindEventOnce({
init: function(data) { init: function(data) {
pandora.site.sectionFolders[section][i].hasItems = !!data.items;
if (data.items) { if (data.items) {
that.setElement( that.setElement(
Ox.SplitPanel({ Ox.SplitPanel({
@ -15,11 +20,18 @@ pandora.ui.folderBrowser = function(id, section) {
}, },
{ {
element: pandora.$ui.folderList[id] element: pandora.$ui.folderList[id]
},
{
element: Ox.Element().append(
pandora.ui.folderPlaceholder(id, section).updateText('public', true)
),
size: 0
} }
], ],
orientation: 'vertical' orientation: 'vertical'
}) })
); );
pandora.resizeFolders();
} else { } else {
// if there are no items, then the placeholder is already there // if there are no items, then the placeholder is already there
pandora.$ui.folderPlaceholder[id].updateText('public'); pandora.$ui.folderPlaceholder[id].updateText('public');

View file

@ -191,13 +191,16 @@ pandora.ui.folderBrowserList = function(id, section) {
init: function(data) { init: function(data) {
pandora.site.sectionFolders[section][i].items = data.items; pandora.site.sectionFolders[section][i].items = data.items;
pandora.$ui.folder[i].$content.css({ pandora.$ui.folder[i].$content.css({
height: (data.items ? 40 + data.items * 16 : 16) + 'px' height: 40 + (data.items || 1) * 16 + 'px'
}); });
pandora.$ui.folderList[id].css({ pandora.$ui.folderList[id].css({
height: 16 + data.items * 16 + 'px' height: 16 + data.items * 16 + 'px'
}); });
pandora.$ui.folderPlaceholder[id][data.items ? 'hide' : 'show'](); pandora.$ui.folderBrowser[id].size(2, data.items ? 0 : 16);
pandora.resizeFolders(); if (Ox.isBoolean(pandora.site.sectionFolders[section][i].hasItems)) {
// hasItems is set, so we're not on first init
pandora.resizeFolders();
}
}, },
paste: function(data) { paste: function(data) {
if (section == 'items') { if (section == 'items') {

View file

@ -7,11 +7,13 @@ pandora.ui.folderPlaceholder = function(id, section) {
height: '14px', height: '14px',
padding: '1px 4px', padding: '1px 4px',
}); });
that.updateText = function(string) { that.updateText = function(string, isFind) {
return that.html( return that.html(
Ox._( Ox._(
string != 'volumes' string != 'volumes'
? 'No ' + string + ' ' + (section == 'items' ? 'lists' : section) ? 'No ' + string + ' '
+ (section == 'items' ? 'lists' : section)
+ (isFind ? ' found' : '')
: 'No local volumes' : 'No local volumes'
) )
); );

View file

@ -1023,7 +1023,7 @@ pandora.getFoldersHeight = function(section) {
var height = 0; var height = 0;
pandora.site.sectionFolders[section].forEach(function(folder, i) { pandora.site.sectionFolders[section].forEach(function(folder, i) {
height += 16 + pandora.user.ui.showFolder[section][folder.id] * ( height += 16 + pandora.user.ui.showFolder[section][folder.id] * (
!!(folder.showBrowser && folder.items) * 40 + (folder.items || 1) * 16 !!(folder.showBrowser && folder.hasItems) * 40 + (folder.items || 1) * 16
); );
}); });
return height; return height;
@ -1035,7 +1035,7 @@ pandora.getFoldersWidth = function(section) {
if ( if (
pandora.$ui.appPanel pandora.$ui.appPanel
&& pandora.getFoldersHeight(section) && pandora.getFoldersHeight(section)
> window.innerHeight - 20 - 24 -16 - 1 - pandora.getInfoHeight(section) > window.innerHeight - 20 - 24 - 16 - 1 - pandora.getInfoHeight(section)
) { ) {
width -= Ox.UI.SCROLLBAR_SIZE; width -= Ox.UI.SCROLLBAR_SIZE;
} }