From 96f60e4184579e8c4b7b9334ffb539015e9e1a0b Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 20 Oct 2011 12:58:21 +0000 Subject: [PATCH] show results in timelines view --- static/js/pandora/ui/list.js | 32 +++++++++++++++++++++----------- static/js/pandora/utils.js | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 79a0b4ab..5782bce3 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -232,10 +232,7 @@ pandora.ui.list = function() { pandora.api.find(Ox.extend(data, { query: pandora.user.ui.find, clips: { - query: { - conditions: [], - operator: '&' - }, + query: pandora.getClipsQuery(), items: 5, keys: [] } @@ -256,6 +253,8 @@ pandora.ui.list = function() { } }); } else if (view == 'timelines') { + var clipsQuery = pandora.getClipsQuery(), + isClipsQuery = clipsQuery.conditions.length; that = Ox.InfoList({ borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 16, defaultRatio: pandora.user.ui.icons == 'posters' ? 5/8 : 1, @@ -303,24 +302,35 @@ pandora.ui.list = function() { id: data.id, options: { duration: data.duration, - // find: '...', + find: 'cinema', getImageURL: function(i) { return '/' + data.id + '/timeline16p' + i + '.png'; }, position: pandora.user.ui.videoPoints[data.id] ? pandora.user.ui.videoPoints[data.id].position : 0, - // subtitles: data.subtitles + results: data.clips ? data.clips.map(function(clip) { + return {'in': clip['in'], out: clip.out}; + }) : [], + subtitles: data.clips ? data.clips.map(function(clip) { + return {'in': clip['in'], out: clip.out, text: clip.annotations[0].value}; + }) : [] } } }; }, items: function(data, callback) { - pandora.api.find(Ox.extend(data, { - query: pandora.user.ui.find, - // clipsQuery: ... - }), callback); + pandora.api.find(Ox.extend(data, Ox.extend({ + query: pandora.user.ui.find + }, isClipsQuery ? {clips: { + query: clipsQuery, + items: 1000000, + keys: [] + }} : {})), callback); }, - keys: ['director', 'duration', 'id', 'posterRatio', 'title', 'year'], + keys: Ox.merge( + ['director', 'duration', 'id', 'posterRatio', 'title', 'year'], + isClipsQuery ? ['clips'] : [] + ), selected: pandora.user.ui.listSelection, size: 192, sort: pandora.user.ui.listSort, diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 1402df39..c63acf66 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -416,6 +416,27 @@ pandora.exitFullscreen = function() { pandora.user.ui.showBrowser && pandora.$ui.contentPanel.size(0, 112 + Ox.UI.SCROLLBAR_SIZE); }; +pandora.getClipsQuery = function() { + function addClipsConditions(conditions) { + conditions.forEach(function(condition) { + if (condition.conditions) { + addClipsConditions(condition.conditions); + } else if ( + Ox.getPositionById(pandora.site.layers, condition.key) > -1 + && condition.operator == '=' + ) { + clipsQuery.conditions.push(condition); + } + }); + } + var clipsQuery = { + conditions: [] + }; + addClipsConditions(pandora.user.ui.find.conditions); + clipsQuery.operator = clipsQuery.conditions.length ? '|' : '&'; + return clipsQuery; +}; + pandora.getFoldersHeight = function() { var height = 0; pandora.site.sectionFolders[pandora.user.ui.section].forEach(function(folder, i) {