fix bug when switching to a view that doesn't have the current sort key; update view movies menu when switching view

This commit is contained in:
rolux 2011-10-09 13:13:11 +00:00
parent d066835061
commit 55b517b54b
3 changed files with 25 additions and 6 deletions

View file

@ -149,9 +149,10 @@ pandora.ui.list = function() {
ui.icons == 'posters' ui.icons == 'posters'
? (ui.showSitePoster ? 'siteposter' : 'poster') : 'icon' ? (ui.showSitePoster ? 'siteposter' : 'poster') : 'icon'
) + size + '.jpg', ) + size + '.jpg',
format, info, sortKey; sortKey = sort[0].key,
if (['title', 'director'].indexOf(sort[0].key) > -1) { format, info;
info = data['year'] if (['title', 'director'].indexOf(sortKey) > -1) {
info = data['year'];
} else { } else {
sortKey = sort[0].key, sortKey = sort[0].key,
format = pandora.getSortKeyData(sortKey).format, format = pandora.getSortKeyData(sortKey).format,

View file

@ -210,7 +210,14 @@ pandora.ui.mainMenu = function() {
} else if (data.id == 'viewicons') { } else if (data.id == 'viewicons') {
pandora.UI.set({icons: value}); pandora.UI.set({icons: value});
} else if (data.id == 'viewmovies') { } else if (data.id == 'viewmovies') {
pandora.UI.set('listView', value); var set = {listView: value};
if (
!pandora.isClipView(key, pandora.user.ui.item)
&& ['title', 'position'].indexOf(pandora.user.ui.listSort[0].key) > -1
) {
set.listSort = pandora.site.user.ui.listSort;
}
pandora.UI.set(set);
} else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(value) > -1) { } else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(value) > -1) {
pandora.UI.set({list: value.substr(8)}); pandora.UI.set({list: value.substr(8)});
} }
@ -277,6 +284,7 @@ pandora.ui.mainMenu = function() {
that[data.value.length ? 'enableItem' : 'disableItem']('newlistfromselection'); that[data.value.length ? 'enableItem' : 'disableItem']('newlistfromselection');
}, },
pandora_listview: function(data) { pandora_listview: function(data) {
pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + data.value);
if (pandora.isClipView() != pandora.isClipView(data.previousValue)) { if (pandora.isClipView() != pandora.isClipView(data.previousValue)) {
that.replaceMenu('sortMenu', getSortMenu()); that.replaceMenu('sortMenu', getSortMenu());
} }

View file

@ -1,7 +1,8 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.viewSelect = function() { pandora.ui.viewSelect = function() {
var viewKey = !pandora.user.ui.item ? 'listView' : 'itemView', var sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort',
viewKey = !pandora.user.ui.item ? 'listView' : 'itemView',
that = Ox.Select({ that = Ox.Select({
id: 'viewSelect', id: 'viewSelect',
items: Ox.map(pandora.site[viewKey + 's'], function(view) { items: Ox.map(pandora.site[viewKey + 's'], function(view) {
@ -22,7 +23,16 @@ pandora.ui.viewSelect = function() {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
pandora.UI.set(viewKey, data.selected[0].id); 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;
}
pandora.UI.set(set);
}, },
pandora_listview: function(data) { pandora_listview: function(data) {
that.selectItem(data.value); that.selectItem(data.value);