cablegates/static/js/pandora/ui/info.js

63 lines
2.3 KiB
JavaScript
Raw Normal View History

2011-07-29 18:37:11 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-08-08 13:58:28 +00:00
pandora.ui.info = function(id) {
id = id || pandora.user.ui.item;
Ox.print('ID', id)
2011-06-19 17:49:25 +00:00
var that = Ox.Element()
2011-05-25 19:42:45 +00:00
.bindEvent({
2011-08-18 07:54:46 +00:00
toggle: function(data) {
2011-06-04 16:46:39 +00:00
pandora.UI.set({showInfo: !data.collapsed});
2011-05-25 19:42:45 +00:00
pandora.resizeFolders();
}
});
2011-08-08 13:58:28 +00:00
if (id) {
2011-08-18 07:54:46 +00:00
if (!pandora.user.ui.item && pandora.user.ui.lists[pandora.user.ui.list].listView == 'clip') {
// Poster
pandora.api.get({id: id, keys: ['poster']}, function(result) {
var ratio = result.data.poster.width / result.data.poster.height,
height = pandora.user.ui.sidebarSize;
that.empty().append(
$('<img>').attr({
src: '/' + id + '/poster' + pandora.user.ui.sidebarSize + '.jpg'
}).css({
position: 'absolute',
left: 0,
top: 0,
right: 0,
bottom: 0,
margin: 'auto'
})
);
pandora.user.infoRatio = 1;
resize(height);
});
} else {
// Video Preview
pandora.api.get({id: id, keys: ['stream']}, function(result) {
var video = result.data.stream;
height = Math.round(pandora.user.ui.sidebarSize / video.aspectRatio) + 16;
pandora.$ui.videoPreview && pandora.$ui.videoPreview.removeElement();
pandora.$ui.videoPreview = pandora.ui.videoPreview({
id: id,
video: video
}).appendTo(pandora.$ui.info);
pandora.user.infoRatio = pandora.user.ui.sidebarSize / height;
resize(height);
});
}
2011-08-08 13:58:28 +00:00
} else if (pandora.$ui.leftPanel) {
2011-08-18 07:54:46 +00:00
pandora.user.infoRatio = 1;
resize(pandora.user.ui.sidebarSize);
2011-08-08 13:58:28 +00:00
}
function resize(height) {
!pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -height});
pandora.$ui.leftPanel.size(2, height);
that.animate({
height: height + 'px'
}, 250, function() {
pandora.resizeFolders();
2011-05-25 19:42:45 +00:00
});
}
return that;
};