make url controller handle listview change; properly set selected item when switching to and from clips view

This commit is contained in:
rolux 2011-09-18 21:46:37 +00:00
parent 9050feed9d
commit 4b523361fe
5 changed files with 19 additions and 10 deletions

View file

@ -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)

View file

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

View file

@ -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() {

View file

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

View file

@ -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;