add clips query

This commit is contained in:
rolux 2011-10-19 16:40:52 +00:00
parent 6362b4df39
commit 906aec4301
2 changed files with 17 additions and 7 deletions

View file

@ -12,26 +12,28 @@ pandora.ui.itemClips = function(options) {
}); });
self.options = Ox.extend({ self.options = Ox.extend({
clips: 5, clips: [],
duration: 0, duration: 0,
id: '', id: '',
ratio: 8/5 ratio: 8/5
}, options); }, options);
self.clips = pandora.getClipPoints(self.options.duration, self.options.clips);
self.size = 128; self.size = 128;
self.width = self.options.ratio > 1 ? self.size : Math.round(self.size * self.options.ratio); self.width = self.options.ratio > 1 ? self.size : Math.round(self.size * self.options.ratio);
self.height = self.options.ratio > 1 ? Math.round(self.size / self.options.ratio) : self.size; self.height = self.options.ratio > 1 ? Math.round(self.size / self.options.ratio) : self.size;
self.clips.forEach(function(clip, i) { self.options.clips.forEach(function(clip, i) {
var id = self.options.id + '/' + clip['in'], var id = self.options.id + '/' + clip['in'],
title = Ox.map(clip.annotations, function(annotation) {
return annotation.layer == 'subtitles' ? annotation.value : 0
}),
url = '/' + self.options.id + '/' + self.height + 'p' + clip['in'] + '.jpg', url = '/' + self.options.id + '/' + self.height + 'p' + clip['in'] + '.jpg',
$item = Ox.IconItem({ $item = Ox.IconItem({
imageHeight: self.height, imageHeight: self.height,
imageWidth: self.width, imageWidth: self.width,
id: id, id: id,
info: Ox.formatDuration(clip['in']) + ' - ' + Ox.formatDuration(clip.out), info: Ox.formatDuration(clip['in']) + ' - ' + Ox.formatDuration(clip.out),
title: '', title: title[0] || '',
url: url, url: url,
}) })
.addClass('OxInfoIcon') .addClass('OxInfoIcon')

View file

@ -207,6 +207,7 @@ pandora.ui.list = function() {
.apply(this, Ox.merge([data[sortKey]], format.args || [])) .apply(this, Ox.merge([data[sortKey]], format.args || []))
: data[sortKey]; : data[sortKey];
} }
Ox.print('CLIPS::', data.clips)
return { return {
icon: { icon: {
height: Math.round(ratio <= 1 ? size : size / ratio), height: Math.round(ratio <= 1 ? size : size / ratio),
@ -220,7 +221,7 @@ pandora.ui.list = function() {
element: pandora.ui.itemClips, element: pandora.ui.itemClips,
id: data.id, id: data.id,
options: { options: {
clips: 5, clips: data.clips,
duration: data.duration, duration: data.duration,
id: data.id, id: data.id,
ratio: data.videoRatio ratio: data.videoRatio
@ -231,10 +232,17 @@ pandora.ui.list = function() {
items: function(data, callback) { items: function(data, callback) {
pandora.api.find(Ox.extend(data, { pandora.api.find(Ox.extend(data, {
query: pandora.user.ui.find, query: pandora.user.ui.find,
// clipsQuery: ... clips: {
query: {
conditions: [],
operator: '&'
},
items: 5,
keys: []
}
}), callback); }), callback);
}, },
keys: ['director', 'duration', 'id', 'posterRatio', 'title', 'videoRatio', 'year'], keys: ['clips', 'director', 'duration', 'id', 'posterRatio', 'title', 'videoRatio', 'year'],
selected: pandora.user.ui.listSelection, selected: pandora.user.ui.listSelection,
size: 192, size: 192,
sort: pandora.user.ui.listSort, sort: pandora.user.ui.listSort,