fix bugs with navigation to or away from view list as clips

This commit is contained in:
rolux 2011-10-13 10:39:22 +00:00
parent 545fa1acfc
commit 199211c6aa
2 changed files with 18 additions and 10 deletions

View file

@ -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);
},

View file

@ -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']