sync sort menu and text list

This commit is contained in:
rlx 2011-08-18 07:54:46 +00:00
parent 39a5219267
commit fe8e821095
6 changed files with 91 additions and 60 deletions

View file

@ -106,9 +106,9 @@ pandora.Query = (function() {
}
if ('sort' in query) {
sort = query.sort.split(',');
pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), $.map(query.sort.split(','), function(v, i) {
pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), query.sort.split(',').map(function(v) {
var hasOperator = '+-'.indexOf(v[0]) > -1,
key = hasOperator ? query.sort.substr(1) : query.sort,
key = hasOperator ? v.substr(1) : v,
operator = hasOperator ? v[0]/*.replace('+', '')*/ : pandora.getSortOperator(key);
return {
key: key,

View file

@ -4,12 +4,34 @@ pandora.ui.info = function(id) {
Ox.print('ID', id)
var that = Ox.Element()
.bindEvent({
toggle: function(event, data) {
toggle: function(data) {
pandora.UI.set({showInfo: !data.collapsed});
pandora.resizeFolders();
}
});
if (id) {
if (!pandora.user.ui.item && pandora.user.ui.lists[pandora.user.ui.list].listView == 'clip') {
// Poster
pandora.api.get({id: id, keys: ['poster']}, function(result) {
var ratio = result.data.poster.width / result.data.poster.height,
height = pandora.user.ui.sidebarSize;
that.empty().append(
$('<img>').attr({
src: '/' + id + '/poster' + pandora.user.ui.sidebarSize + '.jpg'
}).css({
position: 'absolute',
left: 0,
top: 0,
right: 0,
bottom: 0,
margin: 'auto'
})
);
pandora.user.infoRatio = 1;
resize(height);
});
} else {
// Video Preview
pandora.api.get({id: id, keys: ['stream']}, function(result) {
var video = result.data.stream;
height = Math.round(pandora.user.ui.sidebarSize / video.aspectRatio) + 16;
@ -18,11 +40,13 @@ pandora.ui.info = function(id) {
id: id,
video: video
}).appendTo(pandora.$ui.info);
pandora.user.infoRatio = video.aspectRatio;
pandora.user.infoRatio = pandora.user.ui.sidebarSize / height;
resize(height);
});
}
} else if (pandora.$ui.leftPanel) {
resize(32);
pandora.user.infoRatio = 1;
resize(pandora.user.ui.sidebarSize);
}
function resize(height) {
!pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -height});

View file

@ -13,7 +13,7 @@ pandora.ui.leftPanel = function() {
collapsed: !pandora.user.ui.showInfo,
collapsible: true,
element: pandora.$ui.info = pandora.ui.info(),
size: pandora.user.ui.sidebarSize / pandora.user.infoRatio + 16
size: Math.round(pandora.user.ui.sidebarSize / pandora.user.infoRatio)
}
],
id: 'leftPanel',
@ -22,7 +22,7 @@ pandora.ui.leftPanel = function() {
.bindEvent({
resize: function(event, data) {
Ox.print('LEFT PANEL RESIZE')
var infoSize = Math.round(data / pandora.user.infoRatio) + 16;
var infoSize = Math.round(data / pandora.user.infoRatio);
pandora.user.ui.sidebarSize = data;
if (data < pandora.site.sectionButtonsWidth && pandora.$ui.sectionButtons) {
pandora.$ui.sectionButtons.removeElement();

View file

@ -51,7 +51,7 @@ pandora.ui.list = function() { // fixme: remove view argument
sort: pandora.user.ui.lists[pandora.user.ui.list].sort
})
.bindEvent({
columnchange: function(event, data) {
columnchange: function(data) {
var columnWidth = {};
pandora.UI.set(['lists', pandora.user.ui.list, 'columns'].join('|'), data.ids);
/*
@ -63,14 +63,19 @@ pandora.ui.list = function() { // fixme: remove view argument
pandora.UI.set(['lists', pandora.user.ui.list, 'columnWidth'].join('|'), columnWidth);
*/
},
columnresize: function(event, data) {
columnresize: function(data) {
pandora.UI.set(['lists', pandora.user.ui.list, 'columnWidth', data.id].join('|'), data.width);
},
resize: function(event, data) { // this is the resize event of the split panel
resize: function(data) { // this is the resize event of the split panel
that.size();
},
sort: function(event, data) {
pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), [data]);
sort: function(data) {
Ox.print('---- SORT ----', data)
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + data.key);
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (data.operator == '+' ? 'ascending' : 'descending'));
pandora.$ui.sortSelect.selectItem(data.key);
pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), [{key: data.key, operator: data.operator}]);
pandora.URL.push(pandora.Query.toString());
}
});
} else if (view == 'icons') {
@ -154,12 +159,16 @@ pandora.ui.list = function() { // fixme: remove view argument
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
unique: 'id'
}).bindEvent({
open: function(event, data) {
open: function(data) {
var id = data.ids[0],
item = that.value(id, 'item'),
position = that.value(id, 'in');
pandora.UI.set('videoPosition|' + item, position);
pandora.URL.set(item + '/timeline');
},
select: function(data) {
// fixme: clips ids should be 'itemId/annotationId'
pandora.$ui.leftPanel.replaceElement(2, pandora.$ui.info = pandora.ui.info('1135952'));
}
});
} else if (view == 'map') {
@ -208,8 +217,8 @@ pandora.ui.list = function() { // fixme: remove view argument
Ox.print('RATIO', data.aspectRatio);
size = size || 128;
var width = data.aspectRatio < fixedRatio ? size : size * data.aspectRatio / fixedRatio,
height = parseInt(width / data.aspectRatio),
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg';
height = width / data.aspectRatio,
url = '/' + data.item + '/' + width + '/' + data['in'] + '.jpg';
return {
height: height,
id: data.id,
@ -226,7 +235,7 @@ pandora.ui.list = function() { // fixme: remove view argument
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
unique: 'id'
}).bindEvent({
open: function(event, data) {
open: function(data) {
var id = data.ids[0],
item = pandora.$ui.clips.value(id, 'item'),
position = pandora.$ui.clips.value(id, 'in');
@ -301,12 +310,12 @@ pandora.ui.list = function() { // fixme: remove view argument
});
}
}).bindEvent({
closepreview: function(event, data) {
closepreview: function(data) {
pandora.$ui.previewDialog.close();
preview = false;
//delete pandora.$ui.previewDialog;
},
copy: function(event, data) {
copy: function(data) {
Ox.Clipboard.copy({
items: data.ids,
text: $.map(data.ids, function(id) {
@ -314,13 +323,13 @@ pandora.ui.list = function() { // fixme: remove view argument
}).join('\n')
});
},
'delete': function(event, data) {
'delete': function(data) {
pandora.getListData().editable && pandora.api.removeListItems({
list: pandora.user.ui.list,
items: data.ids
}, pandora.reloadList);
},
init: function(event, data) {
init: function(data) {
pandora.$ui.total.html(pandora.ui.status('total', data));
data = [];
$.each(pandora.site.totals, function(i, v) {
@ -328,12 +337,12 @@ pandora.ui.list = function() { // fixme: remove view argument
});
pandora.$ui.selected.html(pandora.ui.status('selected', data));
},
open: function(event, data) {
open: function(data) {
var id = data.ids[0],
title = that.value(id, 'title');
pandora.URL.set(title, id);
},
openpreview: function(event, data) {
openpreview: function(data) {
pandora.requests.preview && pandora.api.cancel(pandora.requests.preview);
pandora.requests.preview = pandora.api.find({
keys: ['director', 'id', 'poster', 'title'],
@ -407,13 +416,13 @@ pandora.ui.list = function() { // fixme: remove view argument
}
});
},
paste: function(event, data) {
paste: function(data) {
data.items && pandora.getListData().editable && pandora.api.addListItems({
list: pandora.user.ui.list,
items: data.items
}, pandora.reloadList);
},
select: function(event, data) {
select: function(data) {
var $still, $timeline;
pandora.UI.set(['lists', pandora.user.ui.list, 'selected'].join('|'), data.ids);
//pandora.user.ui.lists[pandora.user.ui.list].selected = data.ids;
@ -439,21 +448,6 @@ pandora.ui.list = function() { // fixme: remove view argument
}, function(result) {
pandora.$ui.selected.html(pandora.ui.status('selected', result.data));
});
},
sort: function(event, data) {
Ox.print('--SORT--', pandora.user.ui.sort[0].key)
/* some magic has already set user.ui.sort
Ox.print(':', user.ui.sort[0])
if (data.key != user.ui.sort[0].key) {
pandora.$ui.mainMenu.checkItem('sort_sortmovies_' + data.key);
}
if (data.operator != user.ui.sort[0].operator) {
pandora.$ui.mainMenu.checkItem('sort_ordermovies_' + data.operator === '' ? 'ascending' : 'descending');
}
user.ui.sort[0] = data;
*/
pandora.$ui.mainMenu.checkItem('sortMenu_sortmovies_' + data.key);
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (data.operator === '' ? 'ascending' : 'descending'));
}
});
that.display = function() { // fixme: used?

View file

@ -102,7 +102,7 @@ pandora.ui.mainMenu = function() {
] },
{ id: 'ordermovies', title: 'Order ' + pandora.site.itemName.plural, items: [
{ group: 'ordermovies', min: 1, max: 1, items: [
{ id: 'ascending', title: 'Ascending', checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].operator === '' },
{ id: 'ascending', title: 'Ascending', checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].operator == '+' },
{ id: 'descending', title: 'Descending', checked: pandora.user.ui.lists[pandora.user.ui.list].sort[0].operator == '-' }
]}
] },
@ -112,12 +112,13 @@ pandora.ui.mainMenu = function() {
] },
{ id: 'findMenu', title: 'Find', items: [
{ id: 'find', title: 'Find', items: [
{ group: 'find', min: 1, max: 1, items: $.map(pandora.site.findKeys, function(key, i) {
{ group: 'find', min: 1, max: 1, items: pandora.site.findKeys.map(function(key, i) {
return Ox.extend({
checked: pandora.user.ui.findQuery.conditions.length &&
(pandora.user.ui.findQuery.conditions[0].key == key.id ||
(pandora.user.ui.findQuery.conditions[0].key === '' && key.id == 'all')),
}, key)
checked: pandora.user.ui.findQuery.conditions.length ? (
pandora.user.ui.findQuery.conditions[0].key == key.id ||
(pandora.user.ui.findQuery.conditions[0].key === '' && key.id == 'all')
) : key.id == 'all',
}, key);
}) }
] },
{ id: 'advancedfind', title: 'Advanced Find...', keyboard: 'shift control f' }
@ -154,13 +155,25 @@ pandora.ui.mainMenu = function() {
else
url(id);
} else if (data.id == 'ordermovies') {
pandora.$ui.list.sortList(pandora.user.ui.lists[pandora.user.ui.list].sort[0].key, value == 'ascending' ? '' : '-');
var key = pandora.user.ui.lists[pandora.user.ui.list].sort[0].key,
operator = value == 'ascending' ? '+' : '-';
pandora.$ui.list.options({
sort: [{key: key, operator: operator}]
});
pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), [{key: key, operator: operator}]);
//pandora.user.ui.lists[pandora.user.ui.list].sort[0] = {key: key, operator: operator};
pandora.URL.push(pandora.Query.toString());
} else if (data.id == 'sortmovies') {
var operator = pandora.getSortOperator(value);
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator === '' ? 'ascending' : 'descending'));
pandora.$ui.mainMenu.checkItem('sortMenu_ordermovies_' + (operator == '+' ? 'ascending' : 'descending'));
pandora.$ui.sortSelect.selectItem(value);
pandora.$ui.list.sortList(value, operator);
pandora.URL.set(pandora.Query.toString());
pandora.$ui.list.options({
sort: [{key: value, operator: operator}]
});
pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), [{key: value, operator: operator}]);
//pandora.user.ui.lists[pandora.user.ui.list].sort[0] = {key: key, operator: operator};
pandora.URL.push(pandora.Query.toString());
} else if (data.id == 'viewicons') {
var $list;
pandora.UI.set({icons: value});