From 199211c6aade647deb3130e6767cbe6270ee425f Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 13 Oct 2011 10:39:22 +0000 Subject: [PATCH] fix bugs with navigation to or away from view list as clips --- static/js/pandora/ui/viewSelect.js | 26 ++++++++++++++++---------- static/js/pandora/utils.js | 2 ++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/static/js/pandora/ui/viewSelect.js b/static/js/pandora/ui/viewSelect.js index 6deca0ca..2c247202 100644 --- a/static/js/pandora/ui/viewSelect.js +++ b/static/js/pandora/ui/viewSelect.js @@ -1,8 +1,9 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript pandora.ui.viewSelect = function() { - var sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort', - viewKey = !pandora.user.ui.item ? 'listView' : 'itemView', + var ui = pandora.user.ui, + sortKey = !ui.item ? 'listSort' : 'itemSort', + viewKey = !ui.item ? 'listView' : 'itemView', that = Ox.Select({ id: 'viewSelect', items: Ox.map(pandora.site[viewKey + 's'], function(view) { @@ -10,12 +11,12 @@ pandora.ui.viewSelect = function() { || ['data', 'files'].indexOf(view.id) == -1 || pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level] ? Ox.extend(Ox.clone(view), { - checked: view.id == pandora.user.ui[viewKey], + checked: view.id == ui[viewKey], title: 'View ' + view.title }) : null; }), - width: !pandora.user.ui.item ? 144 : 128 + width: !ui.item ? 144 : 128 }) .css({ float: 'left', @@ -25,12 +26,17 @@ pandora.ui.viewSelect = function() { change: function(data) { var key = data.selected[0].id, set = {}; - set[viewKey] = key - if ( - !pandora.isClipView(key, pandora.user.ui.item) - && ['title', 'position'].indexOf(pandora.user.ui[sortKey][0].key) > -1 - ) { - set[sortKey] = pandora.site.user.ui.listSort; + set[viewKey] = key; + if (!ui.item) { + // when changing the list view ... + if (pandora.isClipView(key)) { + // ... to a clip view, set listSelection to empty + set.listSelection = []; + } else if (['title', 'position'].indexOf(ui.listSort[0].key) > -1) { + // ... to a non-clip view, with a sort key that only exists + // in clip views, reset listSort to the default listSort + set.listSort = pandora.site.user.ui.listSort; + } } pandora.UI.set(set); }, diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index f682f9a2..890f9096 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -632,6 +632,8 @@ pandora.isClipView = function(view, item) { if (arguments.length == 0) { item = pandora.user.ui.item; view = !item ? pandora.user.ui.listView : pandora.user.ui.itemView; + } else if (arguments.length == 1) { + item = pandora.user.ui.item; } return ( !item ? ['calendar', 'clip', 'map'] : ['calendar', 'clips', 'map']