From e1fb2d806465e7ba47203d7488735e18e7ab32a5 Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 17 Oct 2011 10:19:17 +0000 Subject: [PATCH] add functionality to timelines view --- static/js/pandora/UI.js | 7 ++++++- static/js/pandora/ui/account.js | 2 +- static/js/pandora/ui/list.js | 27 +++++++++++++++++++++++---- static/js/pandora/ui/viewSelect.js | 1 + 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index 7fe06830c..a2b19a7e4 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -69,7 +69,8 @@ pandora.UI = (function() { if (Object.keys(listSettings).indexOf(key) > -1) { // if applicable, copy setting to list setting add['lists.' + that.encode(pandora.user.ui._list || '') + '.' + listSettings[key]] = val; - } else if (key == 'item' && val) { + } + if (key == 'item' && val) { // when switching to an item, update list selection add['listSelection'] = [val]; add['lists.' + that.encode(pandora.user.ui._list || '') + '.selection'] = [val]; @@ -88,6 +89,10 @@ pandora.UI = (function() { key == 'item' ? val : pandora.user.ui.item )] = {'in': 0, out: 0, position: 0}; } + if (key == 'itemView' && ['video', 'timeline'].indexOf(val) > -1) { + // when switching to a video view, add it as default video view + add.videoView = val; + } }); [args, add].forEach(function(obj, isAdd) { Ox.forEach(obj, function(val, key) { diff --git a/static/js/pandora/ui/account.js b/static/js/pandora/ui/account.js index c995c80bc..ac403e801 100644 --- a/static/js/pandora/ui/account.js +++ b/static/js/pandora/ui/account.js @@ -76,7 +76,7 @@ pandora.ui.accountDialogOptions = function(action, value) { return { buttons: Ox.merge(buttons[action].map(function(type) { return button(type); - }), [button('cancel'), button('submit')]), + }), [{}, button('cancel'), button('submit')]), content: Ox.Element() .append( $('') diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index ed3c9ee51..70ac7a40e 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -218,14 +218,29 @@ pandora.ui.list = function() { width: Math.round(ratio >= 1 ? size : size * ratio) }, info: { + /* css: { - margin: '-4px 0 0 -4px' + margin: '4px' }, + */ element: Ox.BlockVideoTimeline, + events: { + position: function(event) { + //that.options({selected: [data.id]}); + pandora.$ui.videoPreview.options({ + position: event.position + }); + pandora.UI.set('videoPoints.' + data.id + '.position', event.position); + } + }, id: data.id, options: { duration: data.duration, - getImageURL: '/' + data.id + '/timeline16p.png' + getImageURL: function(i) { + return '/' + data.id + '/timeline16p' + i + '.png'; + }, + position: pandora.user.ui.videoPoints[data.id] + ? pandora.user.ui.videoPoints[data.id].position : 0 } } }; @@ -294,7 +309,11 @@ pandora.ui.list = function() { pandora.$ui.selected.html(pandora.ui.status('selected', data)); }, open: function(data) { - pandora.UI.set({item: data.ids[0]}); + pandora.UI.set(Ox.extend({ + item: data.ids[0] + }, view == 'timelines' && data.isSpecialTarget ? { + itemView: pandora.user.ui.videoView + } : {})); }, openpreview: function(data) { pandora.requests.preview && pandora.api.cancel(pandora.requests.preview); @@ -409,7 +428,7 @@ pandora.ui.list = function() { } - if (pandora.user.ui.listView == 'grid') { + if (['grid', 'timelines'].indexOf(pandora.user.ui.listView) > -1) { that.bindEvent({ pandora_icons: function(data) { that.options({ diff --git a/static/js/pandora/ui/viewSelect.js b/static/js/pandora/ui/viewSelect.js index 2398142ab..4b3fc95e0 100644 --- a/static/js/pandora/ui/viewSelect.js +++ b/static/js/pandora/ui/viewSelect.js @@ -27,6 +27,7 @@ pandora.ui.viewSelect = function() { var key = data.selected[0].id, set = {}; set[viewKey] = key; + // FIXME: this may not work on page load, and would then have to be part of UI.js if (!ui.item) { // when changing the list view ... if (pandora.isClipView(key)) {