diff --git a/static/js/pandora/pandora.js b/static/js/pandora/pandora.js index 2bf57113..60cd3f8a 100644 --- a/static/js/pandora/pandora.js +++ b/static/js/pandora/pandora.js @@ -323,10 +323,11 @@ pandora.getListData = function() { }; pandora.getSortMenu = function() { - var list = pandora.user.ui.lists[pandora.user.ui.list]; + var list = pandora.user.ui.lists[pandora.user.ui.list], + isClipView = pandora.isClipView(list.listView); return { id: 'sortMenu', title: 'Sort', items: [ - { id: 'sortmovies', title: 'Sort ' + (list.listView == 'clip' ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [ - { group: 'sortmovies', min: 1, max: 1, items: Ox.merge(list.listView == 'clip' ? Ox.merge(pandora.site.clipKeys.map(function(key) { + { id: 'sortmovies', title: 'Sort ' + (isClipView ? 'Clips' : pandora.site.itemName.plural) + ' by', items: [ + { group: 'sortmovies', min: 1, max: 1, items: Ox.merge(isClipView ? Ox.merge(pandora.site.clipKeys.map(function(key) { return Ox.extend(Ox.clone(key), { checked: list.sort[0].key == key.id }); @@ -336,7 +337,7 @@ pandora.getSortMenu = function() { }, key); })) } ] }, - { id: 'ordermovies', title: 'Order ' + (list.listView == 'clip' ? 'Clips' : pandora.site.itemName.plural), items: [ + { id: 'ordermovies', title: 'Order ' + (isClipView ? 'Clips' : pandora.site.itemName.plural), items: [ { group: 'ordermovies', min: 1, max: 1, items: [ { id: 'ascending', title: 'Ascending', checked: (list.sort[0].operator || pandora.getSortOperator(list.sort[0].key)) == '+' }, { id: 'descending', title: 'Descending', checked: (list.sort[0].operator || pandora.getSortOperator(list.sort[0].key)) == '-' } @@ -383,6 +384,10 @@ pandora.getVideoPartsAndPoints = function(durations, points) { return ret; }; +pandora.isClipView = function(view) { + return ['calendar', 'clip', 'map'].indexOf(view) > -1; +}; + pandora.signin = function(data) { pandora.user = data.user; pandora.Query.updateGroups(); diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js index 8bfd3c95..a0e7eef8 100644 --- a/static/js/pandora/ui/menu.js +++ b/static/js/pandora/ui/menu.js @@ -200,12 +200,17 @@ pandora.ui.mainMenu = function() { defaultRatio: value == 'posters' ? 5/8 : 1 }).reloadList(true); } else if (data.id == 'viewmovies') { + var isClipView = pandora.isClipView(value), + wasClipView = pandora.isClipView(pandora.user.ui.lists[pandora.user.ui.list].listView); pandora.UI.set(['lists', pandora.user.ui.list, 'listView'].join('|'), value); + if (isClipView != wasClipView) { + pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu()); + pandora.$ui.sortSelect.replaceWith(pandora.$ui.sortSelect = pandora.ui.sortSelect()); + } pandora.$ui.viewSelect.options({value: value}); pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.list = pandora.ui.list()); pandora.URL.push('/' + value + '/' + document.location.search); - //pandora.URL.set('/' + value + '/' + document.location.search); } }, click: function(data) { diff --git a/static/js/pandora/ui/sortSelect.js b/static/js/pandora/ui/sortSelect.js index 7055426f..f79f7eb7 100644 --- a/static/js/pandora/ui/sortSelect.js +++ b/static/js/pandora/ui/sortSelect.js @@ -8,7 +8,7 @@ pandora.ui.sortSelect = function() { }); }), that; - if (list.listView == 'clip') { + if (pandora.isClipView(list.listView)) { items = Ox.merge(pandora.site.clipKeys.map(function(key) { return Ox.extend(Ox.clone(key), { checked: list.sort[0].key == key.id, diff --git a/static/js/pandora/ui/viewSelect.js b/static/js/pandora/ui/viewSelect.js index f0b0c79f..d0a65385 100644 --- a/static/js/pandora/ui/viewSelect.js +++ b/static/js/pandora/ui/viewSelect.js @@ -22,10 +22,11 @@ pandora.ui.viewSelect = function() { .bindEvent({ change: !pandora.user.ui.item ? function(data) { var view = data.selected[0].id, - wasClipView = pandora.user.ui.lists[pandora.user.ui.list].listView == 'clip'; + 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); pandora.$ui.mainMenu.checkItem('viewMenu_movies_' + view); - if (view == 'clip' || wasClipView) { + if (isClipView != wasClipView) { pandora.$ui.mainMenu.replaceMenu('sortMenu', pandora.getSortMenu()); pandora.$ui.sortSelect.replaceWith(pandora.$ui.sortSelect = pandora.ui.sortSelect()); }