pandora/static/js/pandora/sequencesDialog.js

110 lines
4.6 KiB
JavaScript
Raw Normal View History

2012-06-06 13:18:03 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.ui.sequencesDialog = function(id, position) {
var dialogHeight = Math.round((window.innerHeight - 48) * 0.9),
dialogWidth = Math.round(window.innerWidth * 0.9),
mode = pandora.user.ui.sequenceMode,
sidebarWidth = 144,
$tabPanel = Ox.TabPanel({
content: function(mode) {
var $splitPanel = Ox.SplitPanel({
elements: [
{
element: Ox.Element(),
size: sidebarWidth
},
{
element: Ox.Element()
}
],
orientation: 'horizontal'
});
pandora.api.getSequence({id: id, mode: mode, position: position}, function(result) {
// result.data: {hash, in, out}
var fixedRatio = 16/9,
2012-06-06 19:49:32 +00:00
hash = result.data.hash,
2012-06-06 13:18:03 +00:00
$sidebar = Ox.Element(), // add video player
$list = Ox.IconList({
2012-06-06 13:23:53 +00:00
fixedRatio: fixedRatio,
2012-06-06 13:18:03 +00:00
item: function(data, sort, size) {
var ratio = data.videoRatio,
width = ratio > fixedRatio ? size : Math.round(size * ratio / fixedRatio),
height = Math.round(width / ratio);
return {
height: height,
id: data.id,
info: Ox.formatDuration(data['in']) + ' - ' + Ox.formatDuration(data.out),
title: data.title + (data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
2012-06-06 13:23:53 +00:00
url: '/' + data.id.split('/')[0] + '/' + height + 'p' + data['in'] + '.jpg',
2012-06-06 13:18:03 +00:00
width: width
};
},
items: function(data, callback) {
pandora.api.findSequences(Ox.extend(data, {
query: {
2012-06-06 19:49:32 +00:00
conditions: [
{key: 'mode', value: mode, operator: '=='},
{key: 'hash', value: hash, operator: '=='}
],
2012-06-06 13:18:03 +00:00
operator: '&'
}
}), callback);
},
keys: ['director', 'id', 'title', 'videoRatio'],
max: 1,
orientation: 'both',
size: 128,
sort: pandora.user.ui.sequenceSort,
unique: 'id'
})
.bindEvent({
open: function(data) {
// ...
},
openpreview: function(data) {
// ...
},
select: function(data) {
// ...
}
});
2012-06-06 19:49:32 +00:00
$splitPanel.replaceElement(0, $sidebar);
$splitPanel.replaceElement(1, $list);
2012-06-06 13:18:03 +00:00
});
return $splitPanel;
},
tabs: [
2012-06-06 19:49:32 +00:00
{id: 'shape', title: 'Similar Shapes'},
{id: 'color', title: 'Similar Colors'}
2012-06-06 13:18:03 +00:00
]
}),
$dialog = Ox.Dialog({
buttons: [
Ox.Button({
id: 'close',
title: 'Close'
}).bindEvent({
click: function() {
2012-06-06 19:49:32 +00:00
$dialog.close();
2012-06-06 13:18:03 +00:00
}
})
],
closeButton: true,
content: $tabPanel,
height: dialogHeight,
keys: {escape: 'close'},
maximizeButton: true,
padding: 0,
removeOnClose: true,
title: 'Similar Clips',
width: dialogWidth
});
return $dialog;
2012-06-06 19:49:32 +00:00
};