From 8c5bbfd7169054ac8b1dc2704fbc9bbb71cdc195 Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 30 Jan 2012 20:48:04 +0000 Subject: [PATCH] fix and optimize video preview --- static/js/pandora/UI.js | 5 ++++- static/js/pandora/utils.js | 4 ++-- static/js/pandora/videoPreview.js | 9 ++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index 18aac2b23..be8a48e6a 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -1,4 +1,5 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript + pandora.UI = (function() { var self = {}, that = {}; @@ -94,7 +95,7 @@ pandora.UI = (function() { // (but don't trigger an additional event) add.listSelection = []; } else if (['text', 'position'].indexOf(pandora.user.ui.listSort[0].key) > -1) { - // when switchin to a non-clip view, with a sort key + // when switching to a non-clip view, with a sort key // that only exists in clip view, reset sort to default args.listSort = pandora.site.user.ui.listSort; } @@ -149,6 +150,7 @@ pandora.UI = (function() { } } + // items in args trigger events, items in add do not [args, add].forEach(function(obj, isAdd) { Ox.forEach(obj, function(val, key) { Ox.Log('', 'key/val', key, val) @@ -186,6 +188,7 @@ pandora.UI = (function() { pandora.URL.update(Object.keys( !pandora.$ui.appPanel ? args : trigger )); + }; return that; diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index b60ffc62c..9287f8a7b 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -1004,13 +1004,13 @@ pandora.resizeWindow = function() { } else if (pandora.user.ui.itemView == 'clips') { pandora.$ui.clipList.size(); } else if (pandora.user.ui.itemView == 'video') { - pandora.$ui.player.options({ + pandora.$ui.player && pandora.$ui.player.options({ // fixme: duplicated height: pandora.$ui.contentPanel.size(1), width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 }); } else if (pandora.user.ui.itemView == 'timeline') { - pandora.$ui.editor.options({ + pandora.$ui.editor && pandora.$ui.editor.options({ // fixme: duplicated height: pandora.$ui.contentPanel.size(1), width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 diff --git a/static/js/pandora/videoPreview.js b/static/js/pandora/videoPreview.js index cadf3ba45..198d11747 100644 --- a/static/js/pandora/videoPreview.js +++ b/static/js/pandora/videoPreview.js @@ -6,9 +6,12 @@ pandora.ui.videoPreview = function(data) { var that = Ox.VideoPreview({ duration: data.duration, getFrame: function(position) { - var resolution = Ox.filter(pandora.site.video.resolutions, function(resolution, i) { - return resolution >= data.height || i == pandora.site.video.resolutions.length - 1; - })[0]; + var resolutions = Ox.filter(pandora.site.video.resolutions, function(resolution, i) { + return resolution >= data.height; + }), + resolution = resolutions.length + ? Math.min(resolutions) + : Math.max(pandora.site.video.resolutions); return '/' + data.id + '/' + resolution + 'p' + ( Ox.isUndefined(position) ? '' : position ) + '.jpg';