cablegates/static/js/pandora/ui/leftPanel.js

54 lines
2.2 KiB
JavaScript
Raw Normal View History

2011-05-25 19:42:45 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=js
pandora.ui.leftPanel = function() {
var that = new Ox.SplitPanel({
elements: [
{
2011-06-06 15:48:11 +00:00
element: pandora.$ui.sectionbar = pandora.ui.sectionbar('buttons'),
2011-05-25 19:42:45 +00:00
size: 24
},
{
2011-06-06 15:48:11 +00:00
element: pandora.$ui.folders = pandora.ui.folders()
2011-05-25 19:42:45 +00:00
},
{
2011-06-06 15:48:11 +00:00
collapsed: !pandora.user.ui.showInfo,
2011-05-25 19:42:45 +00:00
collapsible: true,
2011-06-06 15:48:11 +00:00
element: pandora.$ui.info = pandora.ui.info(),
size: pandora.user.ui.sidebarSize / pandora.user.infoRatio + 16
2011-05-25 19:42:45 +00:00
}
],
id: 'leftPanel',
orientation: 'vertical'
})
.bindEvent({
resize: function(event, data) {
2011-06-06 15:48:11 +00:00
var infoSize = Math.round(data / pandora.user.infoRatio) + 16;
pandora.user.ui.sidebarSize = data;
if (data < pandora.site.sectionButtonsWidth && pandora.$ui.sectionButtons) {
pandora.$ui.sectionButtons.removeElement();
delete pandora.$ui.sectionButtons;
pandora.$ui.sectionbar.append(pandora.$ui.sectionSelect = pandora.ui.sectionSelect());
} else if (data >= pandora.site.sectionButtonsWidth && pandora.$ui.sectionSelect) {
pandora.$ui.sectionSelect.removeElement();
delete pandora.$ui.sectionSelect;
pandora.$ui.sectionbar.append(pandora.$ui.sectionButtons = pandora.ui.sectionButtons());
2011-05-25 19:42:45 +00:00
}
2011-06-06 15:48:11 +00:00
!pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -infoSize});
pandora.$ui.leftPanel.size(2, infoSize);
2011-05-25 19:42:45 +00:00
pandora.resizeFolders();
},
resizeend: function(event, data) {
pandora.UI.set({sidebarSize: data});
},
toggle: function(event, data) {
pandora.UI.set({showSidebar: !data.collapsed});
if (data.collapsed) {
2011-06-06 15:48:11 +00:00
$.each(pandora.$ui.folderList, function(k, $list) {
2011-05-25 19:42:45 +00:00
$list.loseFocus();
});
}
}
});
return that;
};