From fd116dbb70c4f28b58cc48c3d267909078f8d493 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 20 Oct 2011 13:33:18 +0000 Subject: [PATCH] fix bugs in timelines view --- static/js/pandora/ui/item.js | 11 ++++++++--- static/js/pandora/ui/list.js | 25 ++++++++++++++----------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index 477336a81..efb0078b7 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -104,7 +104,9 @@ pandora.ui.item = function() { } else if (pandora.user.ui.itemView == 'video') { pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) { // fixme: duplicated - var layers = [], + var clipsQuery = pandora.getClipsQuery(), + isClipsQuery = !!clipsQuery.conditions.length, + layers = [], video = {}; pandora.site.layers.forEach(function(layer, i) { layers[i] = Ox.extend({}, layer, {items: r.data.layers[layer.id]}); @@ -120,6 +122,7 @@ pandora.ui.item = function() { annotationsSize: pandora.user.ui.annotationsSize, cuts: result.data.cuts || [], duration: result.data.duration, + find: isClipsQuery ? clipsQuery.conditions[0].value : '', getTimelineImageURL: function(i) { return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png'; }, @@ -170,7 +173,9 @@ pandora.ui.item = function() { } else if (pandora.user.ui.itemView == 'timeline') { pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) { - var layers = [], + var clipsQuery = pandora.getClipsQuery(), + isClipsQuery = !!clipsQuery.conditions.length, + layers = [], video = {}; pandora.site.layers.forEach(function(layer) { layers.push(Ox.extend({items: r.data.layers[layer.id]}, layer)); @@ -185,7 +190,7 @@ pandora.ui.item = function() { annotationsSize: pandora.user.ui.annotationsSize, cuts: result.data.cuts || [], duration: result.data.duration, - find: '', + find: isClipsQuery ? clipsQuery.conditions[0].value : '', getFrameURL: function(position) { return '/' + pandora.user.ui.item + '/' + Ox.last(pandora.site.video.resolutions) + 'p' + position + '.jpg'; }, diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 5782bce3c..0459e3191 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -253,8 +253,6 @@ 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, @@ -262,7 +260,9 @@ pandora.ui.list = function() { id: 'list', item: function(data, sort, size) { size = 128; - var ui = pandora.user.ui, + var clipsQuery = pandora.getClipsQuery(), + isClipsQuery = !!clipsQuery.conditions.length, + ui = pandora.user.ui, ratio = ui.icons == 'posters' ? (ui.showSitePoster ? 5/8 : data.posterRatio) : 1, url = '/' + data.id + '/' + ( @@ -296,22 +296,26 @@ pandora.ui.list = function() { pandora.$ui.videoPreview.options({ position: event.position }); - pandora.UI.set('videoPoints.' + data.id + '.position', event.position); + if (pandora.user.ui.videoPoints[data.id]) { + pandora.UI.set('videoPoints.' + data.id + '.position', event.position); + } else { + pandora.UI.set('videoPoints.' + data.id, {'in': 0, out: 0, position: event.position}); + } } }, id: data.id, options: { duration: data.duration, - find: 'cinema', + find: isClipsQuery ? clipsQuery.conditions[0].value : '', getImageURL: function(i) { return '/' + data.id + '/timeline16p' + i + '.png'; }, position: pandora.user.ui.videoPoints[data.id] ? pandora.user.ui.videoPoints[data.id].position : 0, - results: data.clips ? data.clips.map(function(clip) { + results: isClipsQuery ? data.clips.map(function(clip) { return {'in': clip['in'], out: clip.out}; }) : [], - subtitles: data.clips ? data.clips.map(function(clip) { + subtitles: isClipsQuery ? data.clips.map(function(clip) { return {'in': clip['in'], out: clip.out, text: clip.annotations[0].value}; }) : [] } @@ -319,6 +323,8 @@ pandora.ui.list = function() { }; }, items: function(data, callback) { + var clipsQuery = pandora.getClipsQuery(), + isClipsQuery = !!clipsQuery.conditions.length; pandora.api.find(Ox.extend(data, Ox.extend({ query: pandora.user.ui.find }, isClipsQuery ? {clips: { @@ -327,10 +333,7 @@ pandora.ui.list = function() { keys: [] }} : {})), callback); }, - keys: Ox.merge( - ['director', 'duration', 'id', 'posterRatio', 'title', 'year'], - isClipsQuery ? ['clips'] : [] - ), + keys: ['clips', 'director', 'duration', 'id', 'posterRatio', 'title', 'year'], selected: pandora.user.ui.listSelection, size: 192, sort: pandora.user.ui.listSort,