2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-09-18 21:46:37 +00:00
|
|
|
pandora.ui.info = function() {
|
2011-09-30 10:33:45 +00:00
|
|
|
|
|
|
|
var ui = pandora.user.ui,
|
2011-09-18 21:18:05 +00:00
|
|
|
view = getView(),
|
2011-09-30 10:33:45 +00:00
|
|
|
|
2011-09-18 21:18:05 +00:00
|
|
|
that = Ox.Element()
|
|
|
|
.css({overflowX: 'hidden', overflowY: 'auto'})
|
|
|
|
.bindEvent({
|
|
|
|
toggle: function(data) {
|
|
|
|
pandora.UI.set({showInfo: !data.collapsed});
|
2011-10-09 14:52:53 +00:00
|
|
|
pandora.$ui.mainMenu.getItem('viewMenu_toggleinfo').toggleTitle();
|
2011-09-18 21:18:05 +00:00
|
|
|
pandora.resizeFolders();
|
2011-09-30 10:33:45 +00:00
|
|
|
},
|
|
|
|
pandora_find: function() {
|
|
|
|
if (pandora.user.ui._list != pandora.UI.getPrevious('_list')) {
|
|
|
|
updateInfo();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
pandora_item: updateInfo,
|
|
|
|
pandora_listselection: updateInfo
|
2011-08-18 07:54:46 +00:00
|
|
|
});
|
2011-09-30 10:33:45 +00:00
|
|
|
|
|
|
|
//pandora.$ui.leftPanel && resize();
|
|
|
|
|
|
|
|
updateInfo();
|
|
|
|
|
|
|
|
function getId() {
|
|
|
|
return ui.item || (
|
|
|
|
ui.listSelection.length
|
|
|
|
? ui.listSelection[ui.listSelection.length - 1]
|
|
|
|
: null
|
|
|
|
);
|
2011-09-18 21:18:05 +00:00
|
|
|
}
|
2011-09-30 10:33:45 +00:00
|
|
|
|
2011-09-18 21:18:05 +00:00
|
|
|
function getView() {
|
2011-09-30 10:33:45 +00:00
|
|
|
return !getId() ? 'list'
|
|
|
|
: !ui.item && pandora.isClipView() ? 'poster'
|
2011-09-18 21:18:05 +00:00
|
|
|
: 'video';
|
|
|
|
}
|
2011-09-30 10:33:45 +00:00
|
|
|
|
|
|
|
function resizeInfo() {
|
2011-09-18 21:18:05 +00:00
|
|
|
var height = pandora.getInfoHeight();
|
2011-09-30 10:33:45 +00:00
|
|
|
!pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -height});
|
|
|
|
pandora.$ui.leftPanel.size(2, height, function() {
|
|
|
|
pandora.resizeFolders();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateInfo() {
|
|
|
|
var id = getId(),
|
|
|
|
previousView = view;
|
|
|
|
view = getView();
|
|
|
|
if (view == 'list') {
|
|
|
|
that.empty().append(pandora.$ui.listInfo = pandora.ui.listInfo(ui._list));
|
|
|
|
previousView == 'video' && resizeInfo();
|
|
|
|
} else if (view == 'poster') {
|
|
|
|
pandora.api.get({id: id, keys: ['director', 'posterRatio', 'title']}, function(result) {
|
|
|
|
var ratio = result.data.posterRatio,
|
|
|
|
height = pandora.getInfoHeight();
|
|
|
|
that.empty().append(
|
|
|
|
pandora.$ui.posterInfo = pandora.ui.posterInfo(Ox.extend(result.data, {id: id}))
|
|
|
|
);
|
|
|
|
previousView == 'video' && resizeInfo();
|
|
|
|
});
|
|
|
|
} else if (view == 'video') {
|
|
|
|
pandora.api.get({id: id, keys: ['duration', 'videoRatio']}, function(result) {
|
|
|
|
if (result.data) {
|
|
|
|
pandora.$ui.videoPreview && pandora.$ui.videoPreview.removeElement();
|
|
|
|
pandora.$ui.videoPreview = pandora.ui.videoPreview({
|
|
|
|
duration: result.data.duration,
|
|
|
|
frameRatio: result.data.videoRatio,
|
|
|
|
height: pandora.getInfoHeight(),
|
|
|
|
id: id,
|
|
|
|
width: ui.sidebarSize
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(data) {
|
|
|
|
pandora.UI.set(
|
|
|
|
'videoPoints.' + id,
|
|
|
|
{'in': 0, out: 0, position: data.position}
|
|
|
|
);
|
|
|
|
if (ui.item && ['video', 'timeline'].indexOf(ui.itemView) > -1) {
|
|
|
|
pandora.$ui[
|
|
|
|
ui.itemView == 'video' ? 'player' : 'editor'
|
|
|
|
].options({
|
|
|
|
position: data.position
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
pandora.UI.set({
|
|
|
|
item: id,
|
|
|
|
itemView: ui.videoView
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(pandora.$ui.info);
|
|
|
|
previousView != 'video' && resizeInfo();
|
|
|
|
}
|
|
|
|
});
|
2011-08-18 07:54:46 +00:00
|
|
|
}
|
2011-09-18 21:18:05 +00:00
|
|
|
}
|
2011-09-30 10:33:45 +00:00
|
|
|
|
2011-09-18 21:18:05 +00:00
|
|
|
that.resizeInfo = function() {
|
2011-09-30 10:33:45 +00:00
|
|
|
var view = getView();
|
2011-09-18 21:18:05 +00:00
|
|
|
if (view == 'list') {
|
|
|
|
pandora.$ui.listInfo.resizeIcon();
|
|
|
|
} else if (view == 'poster') {
|
|
|
|
pandora.$ui.posterInfo.resizePoster();
|
|
|
|
} else if (view == 'video') {
|
|
|
|
pandora.$ui.videoPreview.options({
|
|
|
|
height: pandora.getInfoHeight(),
|
2011-09-30 10:33:45 +00:00
|
|
|
width: ui.sidebarSize
|
2011-09-29 17:25:04 +00:00
|
|
|
});
|
2011-09-18 21:18:05 +00:00
|
|
|
}
|
|
|
|
};
|
2011-09-30 10:33:45 +00:00
|
|
|
|
2011-09-18 21:18:05 +00:00
|
|
|
return that;
|
2011-09-30 10:33:45 +00:00
|
|
|
|
2011-09-18 21:18:05 +00:00
|
|
|
};
|
|
|
|
|
2011-10-05 17:35:16 +00:00
|
|
|
pandora.ui.listInfo = function(list) {
|
2011-09-18 21:18:05 +00:00
|
|
|
var that = $('<div>').css({padding: '16px', textAlign: 'center'});
|
|
|
|
var $icon = $('<img>')
|
2011-09-29 17:25:04 +00:00
|
|
|
.attr({
|
2011-10-05 17:35:16 +00:00
|
|
|
src: list
|
|
|
|
? '/list/' + list + '/icon256.jpg?' + Ox.uid()
|
|
|
|
: '/static/png/icon256.png'
|
2011-09-29 17:25:04 +00:00
|
|
|
})
|
2011-09-18 21:18:05 +00:00
|
|
|
.css(getIconCSS())
|
2011-10-05 17:35:16 +00:00
|
|
|
.appendTo(that),
|
|
|
|
title = list ? list.replace(':', ': ') : 'All ' + pandora.site.itemName.plural,
|
|
|
|
description = '';
|
|
|
|
|
|
|
|
$('<div>').css({padding: '16px 0 16px 0', fontWeight: 'bold'}).html(title).appendTo(that);
|
|
|
|
//fixme: allow editing
|
|
|
|
//pandora.api.editList({id: list, description: 'foobbar'}, callback)
|
|
|
|
//pandora.api.editPage({name: 'allItems', body: 'foobar'}, callback)
|
|
|
|
if(list) {
|
|
|
|
pandora.api.findLists({
|
|
|
|
query: { conditions: [{key: 'id', value: list, operator:'=='}] },
|
|
|
|
keys:['description']
|
|
|
|
}, function(result) {
|
|
|
|
$('<div>').css({textAlign: 'left'})
|
|
|
|
.html(result.data.items[0].description)
|
|
|
|
.appendTo(that);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pandora.api.getPage({name: 'allItems'}, function(result) {
|
|
|
|
$('<div>').css({textAlign: 'left'})
|
|
|
|
.html(result.data.body)
|
|
|
|
.appendTo(that);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-09-18 21:18:05 +00:00
|
|
|
function getIconCSS() {
|
|
|
|
var size = Math.round(pandora.user.ui.sidebarSize / 2);
|
2011-09-29 17:25:04 +00:00
|
|
|
return {
|
|
|
|
width: size + 'px',
|
|
|
|
height: size + 'px',
|
|
|
|
borderRadius: Math.round(size / 4) + 'px'
|
|
|
|
};
|
2011-09-18 21:18:05 +00:00
|
|
|
}
|
|
|
|
that.resizeIcon = function() {
|
|
|
|
$icon.css(getIconCSS());
|
2011-10-05 17:35:16 +00:00
|
|
|
};
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
2011-09-18 21:18:05 +00:00
|
|
|
pandora.ui.posterInfo = function(data) {
|
|
|
|
var $poster = $('<img>')
|
|
|
|
.attr({src: '/' + data.id + '/poster512.jpg'})
|
|
|
|
.css(getPosterCSS()),
|
|
|
|
$text = $('<div>')
|
|
|
|
.css({
|
|
|
|
width: pandora.user.ui.sidebarSize - 8 + 'px',
|
|
|
|
height: '12px',
|
|
|
|
padding: '2px 4px 2px 4px',
|
|
|
|
fontSize: '9px',
|
|
|
|
textAlign: 'center',
|
|
|
|
textOverflow: 'ellipsis',
|
|
|
|
overflow: 'hidden'
|
|
|
|
})
|
|
|
|
.html(
|
|
|
|
data.title + (
|
|
|
|
data.director ? ' (' + data.director.join(', ') + ')' : ''
|
|
|
|
)
|
2011-09-30 10:33:45 +00:00
|
|
|
),
|
2011-09-18 21:18:05 +00:00
|
|
|
that = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: $('<div>').append($poster)
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: Ox.Bar({size: 16}).append($text),
|
|
|
|
size: 16
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
});
|
|
|
|
function getPosterCSS() {
|
|
|
|
var css = {},
|
|
|
|
ratio = pandora.user.ui.sidebarSize / (pandora.user.ui.sidebarSize - 16);
|
|
|
|
if (data.posterRatio < ratio) {
|
|
|
|
css.height = pandora.user.ui.sidebarSize - 16;
|
|
|
|
css.width = Math.round(css.height * data.posterRatio);
|
|
|
|
css.marginLeft = Math.floor((pandora.user.ui.sidebarSize - css.width) / 2);
|
|
|
|
} else {
|
|
|
|
css.width = pandora.user.ui.sizebarSize;
|
|
|
|
css.height = Math.round(css.width / data.posterRatio);
|
|
|
|
css.marginTop = Math.floor((pandora.user.ui.sidebarSize - 16 - css.height) / 2);
|
|
|
|
}
|
|
|
|
return Ox.map(css, function(value) {
|
|
|
|
return value + 'px';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
that.resizePoster = function() {
|
|
|
|
$poster.css(getPosterCSS());
|
|
|
|
$text.css({width: pandora.user.ui.sidebarSize - 8 + 'px'})
|
|
|
|
}
|
|
|
|
return that;
|
|
|
|
};
|