From 4b523361fe8f58053357c202bad3128adc394e6f Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 18 Sep 2011 21:46:37 +0000 Subject: [PATCH] make url controller handle listview change; properly set selected item when switching to and from clips view --- static/js/pandora/URL.js | 9 ++++++++- static/js/pandora/pandora.js | 1 + static/js/pandora/ui/info.js | 7 ++++--- static/js/pandora/ui/list.js | 5 +++-- static/js/pandora/ui/viewSelect.js | 7 +++---- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 73af136dc..7e805e9e2 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -211,8 +211,15 @@ pandora.URL = (function() { Ox.print('EQUAL', pandora.user.ui.findQuery, oldUserUI.findQuery) pandora.$ui.contentPanel.replaceElement(1, pandora.ui.list()); } else { + if (pandora.isClipView()) { + pandora.UI.set('lists|' + pandora.user.ui.list + '|selected', []); + } pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info()); - pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel()); + if (pandora.user.ui.list == oldUserUI.list) { + pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list()); + } else { + pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel()); + } } // fixme: should list selection and deselection happen here? // (home and menu may cause a list switch) diff --git a/static/js/pandora/pandora.js b/static/js/pandora/pandora.js index f7f879c07..0b25b5092 100644 --- a/static/js/pandora/pandora.js +++ b/static/js/pandora/pandora.js @@ -445,6 +445,7 @@ pandora.getVideoPartsAndPoints = function(durations, points) { }; pandora.isClipView = function(view) { + view = view || pandora.user.ui.lists[pandora.user.ui.list].listView; return ['calendar', 'clip', 'map'].indexOf(view) > -1; }; diff --git a/static/js/pandora/ui/info.js b/static/js/pandora/ui/info.js index e120e06d1..59b591a92 100644 --- a/static/js/pandora/ui/info.js +++ b/static/js/pandora/ui/info.js @@ -1,7 +1,7 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript -pandora.ui.info = function(id) { +pandora.ui.info = function() { var list = pandora.user.ui.lists[pandora.user.ui.list], - id = id || pandora.user.ui.item || (list.selected.length ? list.selected[list.selected.length - 1] : null), + id = pandora.user.ui.item || (list.selected.length ? list.selected[list.selected.length - 1] : null), view = getView(), that = Ox.Element() .css({overflowX: 'hidden', overflowY: 'auto'}) @@ -11,6 +11,7 @@ pandora.ui.info = function(id) { pandora.resizeFolders(); } }); + Ox.print('INFO', view) if (view == 'list') { that.empty().append(pandora.$ui.listInfo = pandora.ui.listInfo(list)); } else if (view == 'poster') { @@ -36,7 +37,7 @@ pandora.ui.info = function(id) { pandora.$ui.leftPanel && resize(); function getView() { return !id ? 'list' - : !pandora.user.ui.item && pandora.isClipView(list.listView) ? 'poster' + : !pandora.user.ui.item && pandora.isClipView() ? 'poster' : 'video'; } function resize() { diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 558c6df05..177e6ea9e 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -292,8 +292,8 @@ pandora.ui.list = function() { // fixme: remove view argument item = id.split('/')[0], width, height, $img = $('.OxItem.OxSelected > .OxIcon > img'), $video = $('.OxItem.OxSelected > .OxIcon > .OxVideoPlayer'); - pandora.UI.set(['lists', pandora.user.ui.list, 'selected'].join('|'), item); - pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info(data.ids[0].split('/')[0])); + pandora.UI.set('lists|' + pandora.user.ui.list + '|selected', [item]); + pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info()); if ($img.length) { var width = parseInt($img.css('width')), height = parseInt($img.css('height')); @@ -333,6 +333,7 @@ pandora.ui.list = function() { // fixme: remove view argument }, 300); } } else { + pandora.UI.set('lists|' + pandora.user.ui.list + '|selected', []); pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info()); $('.OxSelectedVideo').removeClass('OxSelectedVideo'); } diff --git a/static/js/pandora/ui/viewSelect.js b/static/js/pandora/ui/viewSelect.js index d0a65385e..5c82b38dc 100644 --- a/static/js/pandora/ui/viewSelect.js +++ b/static/js/pandora/ui/viewSelect.js @@ -23,15 +23,14 @@ pandora.ui.viewSelect = function() { change: !pandora.user.ui.item ? function(data) { var view = data.selected[0].id, isClipView = pandora.isClipView(view), - wasClipView = pandora.isClipView(pandora.user.ui.lists[pandora.user.ui.list].listView); - pandora.UI.set(['lists', pandora.user.ui.list, 'listView'].join('|'), view); + wasClipView = pandora.isClipView(); + pandora.UI.set('lists|' + pandora.user.ui.list + '|listView', view); pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + view); if (isClipView != wasClipView) { pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu()); pandora.$ui.sortSelect.replaceWith(pandora.$ui.sortSelect = pandora.ui.sortSelect()); } - pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list()); - pandora.URL.push('/' + view + '/' + document.location.search); + pandora.URL.set(view + '/' + document.location.search); // pandora.URL.set('/' + view + '/' + document.location.search); } : function(data) { var view = data.selected[0].id;