From c836392051be3efb278f7a17d19123cd20184d6c Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 20 Oct 2011 11:54:35 +0000 Subject: [PATCH] fix bugs with setting list selection and video points on load --- static/js/pandora/UI.js | 22 +++++++--------------- static/js/pandora/ui/item.js | 18 ++++++++++++------ static/js/pandora/ui/list.js | 1 - static/js/pandora/utils.js | 8 -------- 4 files changed, 19 insertions(+), 30 deletions(-) diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index d3c41dde..27d5a831 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -73,22 +73,12 @@ pandora.UI = (function() { } if (key == 'item' && val) { // when switching to an item, update list selection + var list = pandora.user.ui._list || ''; add['listSelection'] = [val]; - add['lists.' + that.encode(pandora.user.ui._list || '') + '.selection'] = [val]; - } - if (( - key == 'item' - && ['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1 - && !pandora.user.ui.videoPoints[val] - ) || ( - key == 'itemView' - && ['video', 'timeline'].indexOf(val) > -1 - && !pandora.user.ui.videoPoints[pandora.user.ui.item] - )) { - // when switching to a video view, add default videoPoints - add['videoPoints.' + ( - key == 'item' ? val : pandora.user.ui.item - )] = {'in': 0, out: 0, position: 0}; + if (!pandora.user.ui.lists[list]) { + add['lists.' + that.encode(list)] = {}; + } + add['lists.' + that.encode(list) + '.selection'] = [val]; } if (key == 'itemView' && ['video', 'timeline'].indexOf(val) > -1) { // when switching to a video view, add it as default video view @@ -97,6 +87,7 @@ pandora.UI = (function() { }); [args, add].forEach(function(obj, isAdd) { Ox.forEach(obj, function(val, key) { + Ox.print('key/val', key, val) // make sure to not split at escaped dots ('\.') var keys = key.replace(/\\\./g, '\n').split('.').map(function(key) { return key.replace(/\n/g, '.') @@ -105,6 +96,7 @@ pandora.UI = (function() { while (keys.length > 1) { ui = ui[keys.shift()]; } + Ox.print(keys[0]) if (!Ox.isEqual(ui[keys[0]], val)) { if (val === null) { delete ui[keys[0]] diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index 477336a8..4861064d 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -124,10 +124,13 @@ pandora.ui.item = function() { return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png'; }, height: pandora.$ui.contentPanel.size(1), - 'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'], + 'in': pandora.user.ui.videoPoints[pandora.user.ui.item] + ? pandora.user.ui.videoPoints[pandora.user.ui.item]['in'] : 0, muted: pandora.user.ui.videoMuted, - out: pandora.user.ui.videoPoints[pandora.user.ui.item].out, - position: pandora.user.ui.videoPoints[pandora.user.ui.item].position, + out: pandora.user.ui.videoPoints[pandora.user.ui.item] + ? pandora.user.ui.videoPoints[pandora.user.ui.item].out : 0, + position: pandora.user.ui.videoPoints[pandora.user.ui.item] + ? pandora.user.ui.videoPoints[pandora.user.ui.item].position : 0, scaleToFill: pandora.user.ui.videoScale == 'fill', showAnnotations: pandora.user.ui.showAnnotations, showControls: pandora.user.ui.showControls, @@ -197,11 +200,14 @@ pandora.ui.item = function() { }, height: pandora.$ui.contentPanel.size(1), id: 'editor', - 'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'], + 'in': pandora.user.ui.videoPoints[pandora.user.ui.item] + ? pandora.user.ui.videoPoints[pandora.user.ui.item]['in'] : 0, layers: layers, muted: pandora.user.ui.videoMuted, - out: pandora.user.ui.videoPoints[pandora.user.ui.item].out, - position: pandora.user.ui.videoPoints[pandora.user.ui.item].position, + out: pandora.user.ui.videoPoints[pandora.user.ui.item] + ? pandora.user.ui.videoPoints[pandora.user.ui.item].out : 0, + position: pandora.user.ui.videoPoints[pandora.user.ui.item] + ? pandora.user.ui.videoPoints[pandora.user.ui.item].position : 0, posterFrame: parseInt(video.duration / 2), showAnnotations: pandora.user.ui.showAnnotations, showLargeTimeline: true, diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 236f0475..79a0b4ab 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -207,7 +207,6 @@ pandora.ui.list = function() { .apply(this, Ox.merge([data[sortKey]], format.args || [])) : data[sortKey]; } - Ox.print('CLIPS::', data.clips) return { icon: { height: Math.round(ratio <= 1 ? size : size / ratio), diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index d01f419f..1402df39 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -416,14 +416,6 @@ pandora.exitFullscreen = function() { pandora.user.ui.showBrowser && pandora.$ui.contentPanel.size(0, 112 + Ox.UI.SCROLLBAR_SIZE); }; -pandora.getClipPoints = function(duration, number) { - var step = Math.max(Math.floor((duration - 5) / 60 / (number + 1)), 1) * 60; - Ox.print('STEP', step) - return Ox.range(step, duration - 4.999, step).map(function(position) { - return {'in': position, 'out': position + 5}; - }); -}; - pandora.getFoldersHeight = function() { var height = 0; pandora.site.sectionFolders[pandora.user.ui.section].forEach(function(folder, i) {