sync sort menu and text list
This commit is contained in:
parent
731aa82bf1
commit
784c6fdba7
6 changed files with 91 additions and 60 deletions
|
@ -106,9 +106,9 @@ pandora.Query = (function() {
|
||||||
}
|
}
|
||||||
if ('sort' in query) {
|
if ('sort' in query) {
|
||||||
sort = query.sort.split(',');
|
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,
|
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);
|
operator = hasOperator ? v[0]/*.replace('+', '')*/ : pandora.getSortOperator(key);
|
||||||
return {
|
return {
|
||||||
key: key,
|
key: key,
|
||||||
|
|
|
@ -4,25 +4,49 @@ pandora.ui.info = function(id) {
|
||||||
Ox.print('ID', id)
|
Ox.print('ID', id)
|
||||||
var that = Ox.Element()
|
var that = Ox.Element()
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
toggle: function(event, data) {
|
toggle: function(data) {
|
||||||
pandora.UI.set({showInfo: !data.collapsed});
|
pandora.UI.set({showInfo: !data.collapsed});
|
||||||
pandora.resizeFolders();
|
pandora.resizeFolders();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (id) {
|
if (id) {
|
||||||
pandora.api.get({id: id, keys:['stream']}, function(result) {
|
if (!pandora.user.ui.item && pandora.user.ui.lists[pandora.user.ui.list].listView == 'clip') {
|
||||||
var video = result.data.stream;
|
// Poster
|
||||||
height = Math.round(pandora.user.ui.sidebarSize / video.aspectRatio) + 16;
|
pandora.api.get({id: id, keys: ['poster']}, function(result) {
|
||||||
pandora.$ui.videoPreview && pandora.$ui.videoPreview.removeElement();
|
var ratio = result.data.poster.width / result.data.poster.height,
|
||||||
pandora.$ui.videoPreview = pandora.ui.videoPreview({
|
height = pandora.user.ui.sidebarSize;
|
||||||
id: id,
|
that.empty().append(
|
||||||
video: video
|
$('<img>').attr({
|
||||||
}).appendTo(pandora.$ui.info);
|
src: '/' + id + '/poster' + pandora.user.ui.sidebarSize + '.jpg'
|
||||||
pandora.user.infoRatio = video.aspectRatio;
|
}).css({
|
||||||
resize(height);
|
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;
|
||||||
|
pandora.$ui.videoPreview && pandora.$ui.videoPreview.removeElement();
|
||||||
|
pandora.$ui.videoPreview = pandora.ui.videoPreview({
|
||||||
|
id: id,
|
||||||
|
video: video
|
||||||
|
}).appendTo(pandora.$ui.info);
|
||||||
|
pandora.user.infoRatio = pandora.user.ui.sidebarSize / height;
|
||||||
|
resize(height);
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (pandora.$ui.leftPanel) {
|
} else if (pandora.$ui.leftPanel) {
|
||||||
resize(32);
|
pandora.user.infoRatio = 1;
|
||||||
|
resize(pandora.user.ui.sidebarSize);
|
||||||
}
|
}
|
||||||
function resize(height) {
|
function resize(height) {
|
||||||
!pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -height});
|
!pandora.user.ui.showInfo && pandora.$ui.leftPanel.css({bottom: -height});
|
||||||
|
|
|
@ -13,7 +13,7 @@ pandora.ui.leftPanel = function() {
|
||||||
collapsed: !pandora.user.ui.showInfo,
|
collapsed: !pandora.user.ui.showInfo,
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
element: pandora.$ui.info = pandora.ui.info(),
|
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',
|
id: 'leftPanel',
|
||||||
|
@ -22,7 +22,7 @@ pandora.ui.leftPanel = function() {
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
resize: function(event, data) {
|
resize: function(event, data) {
|
||||||
Ox.print('LEFT PANEL RESIZE')
|
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;
|
pandora.user.ui.sidebarSize = data;
|
||||||
if (data < pandora.site.sectionButtonsWidth && pandora.$ui.sectionButtons) {
|
if (data < pandora.site.sectionButtonsWidth && pandora.$ui.sectionButtons) {
|
||||||
pandora.$ui.sectionButtons.removeElement();
|
pandora.$ui.sectionButtons.removeElement();
|
||||||
|
|
|
@ -51,7 +51,7 @@ pandora.ui.list = function() { // fixme: remove view argument
|
||||||
sort: pandora.user.ui.lists[pandora.user.ui.list].sort
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
columnchange: function(event, data) {
|
columnchange: function(data) {
|
||||||
var columnWidth = {};
|
var columnWidth = {};
|
||||||
pandora.UI.set(['lists', pandora.user.ui.list, 'columns'].join('|'), data.ids);
|
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);
|
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);
|
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();
|
that.size();
|
||||||
},
|
},
|
||||||
sort: function(event, data) {
|
sort: function(data) {
|
||||||
pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), [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') {
|
} 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,
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
||||||
unique: 'id'
|
unique: 'id'
|
||||||
}).bindEvent({
|
}).bindEvent({
|
||||||
open: function(event, data) {
|
open: function(data) {
|
||||||
var id = data.ids[0],
|
var id = data.ids[0],
|
||||||
item = that.value(id, 'item'),
|
item = that.value(id, 'item'),
|
||||||
position = that.value(id, 'in');
|
position = that.value(id, 'in');
|
||||||
pandora.UI.set('videoPosition|' + item, position);
|
pandora.UI.set('videoPosition|' + item, position);
|
||||||
pandora.URL.set(item + '/timeline');
|
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') {
|
} else if (view == 'map') {
|
||||||
|
@ -208,8 +217,8 @@ pandora.ui.list = function() { // fixme: remove view argument
|
||||||
Ox.print('RATIO', data.aspectRatio);
|
Ox.print('RATIO', data.aspectRatio);
|
||||||
size = size || 128;
|
size = size || 128;
|
||||||
var width = data.aspectRatio < fixedRatio ? size : size * data.aspectRatio / fixedRatio,
|
var width = data.aspectRatio < fixedRatio ? size : size * data.aspectRatio / fixedRatio,
|
||||||
height = parseInt(width / data.aspectRatio),
|
height = width / data.aspectRatio,
|
||||||
url = '/' + data.item + '/' + height + 'p' + data['in'] + '.jpg';
|
url = '/' + data.item + '/' + width + '/' + data['in'] + '.jpg';
|
||||||
return {
|
return {
|
||||||
height: height,
|
height: height,
|
||||||
id: data.id,
|
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,
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
||||||
unique: 'id'
|
unique: 'id'
|
||||||
}).bindEvent({
|
}).bindEvent({
|
||||||
open: function(event, data) {
|
open: function(data) {
|
||||||
var id = data.ids[0],
|
var id = data.ids[0],
|
||||||
item = pandora.$ui.clips.value(id, 'item'),
|
item = pandora.$ui.clips.value(id, 'item'),
|
||||||
position = pandora.$ui.clips.value(id, 'in');
|
position = pandora.$ui.clips.value(id, 'in');
|
||||||
|
@ -301,12 +310,12 @@ pandora.ui.list = function() { // fixme: remove view argument
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).bindEvent({
|
}).bindEvent({
|
||||||
closepreview: function(event, data) {
|
closepreview: function(data) {
|
||||||
pandora.$ui.previewDialog.close();
|
pandora.$ui.previewDialog.close();
|
||||||
preview = false;
|
preview = false;
|
||||||
//delete pandora.$ui.previewDialog;
|
//delete pandora.$ui.previewDialog;
|
||||||
},
|
},
|
||||||
copy: function(event, data) {
|
copy: function(data) {
|
||||||
Ox.Clipboard.copy({
|
Ox.Clipboard.copy({
|
||||||
items: data.ids,
|
items: data.ids,
|
||||||
text: $.map(data.ids, function(id) {
|
text: $.map(data.ids, function(id) {
|
||||||
|
@ -314,13 +323,13 @@ pandora.ui.list = function() { // fixme: remove view argument
|
||||||
}).join('\n')
|
}).join('\n')
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'delete': function(event, data) {
|
'delete': function(data) {
|
||||||
pandora.getListData().editable && pandora.api.removeListItems({
|
pandora.getListData().editable && pandora.api.removeListItems({
|
||||||
list: pandora.user.ui.list,
|
list: pandora.user.ui.list,
|
||||||
items: data.ids
|
items: data.ids
|
||||||
}, pandora.reloadList);
|
}, pandora.reloadList);
|
||||||
},
|
},
|
||||||
init: function(event, data) {
|
init: function(data) {
|
||||||
pandora.$ui.total.html(pandora.ui.status('total', data));
|
pandora.$ui.total.html(pandora.ui.status('total', data));
|
||||||
data = [];
|
data = [];
|
||||||
$.each(pandora.site.totals, function(i, v) {
|
$.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));
|
pandora.$ui.selected.html(pandora.ui.status('selected', data));
|
||||||
},
|
},
|
||||||
open: function(event, data) {
|
open: function(data) {
|
||||||
var id = data.ids[0],
|
var id = data.ids[0],
|
||||||
title = that.value(id, 'title');
|
title = that.value(id, 'title');
|
||||||
pandora.URL.set(title, id);
|
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.cancel(pandora.requests.preview);
|
||||||
pandora.requests.preview = pandora.api.find({
|
pandora.requests.preview = pandora.api.find({
|
||||||
keys: ['director', 'id', 'poster', 'title'],
|
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({
|
data.items && pandora.getListData().editable && pandora.api.addListItems({
|
||||||
list: pandora.user.ui.list,
|
list: pandora.user.ui.list,
|
||||||
items: data.items
|
items: data.items
|
||||||
}, pandora.reloadList);
|
}, pandora.reloadList);
|
||||||
},
|
},
|
||||||
select: function(event, data) {
|
select: function(data) {
|
||||||
var $still, $timeline;
|
var $still, $timeline;
|
||||||
pandora.UI.set(['lists', pandora.user.ui.list, 'selected'].join('|'), data.ids);
|
pandora.UI.set(['lists', pandora.user.ui.list, 'selected'].join('|'), data.ids);
|
||||||
//pandora.user.ui.lists[pandora.user.ui.list].selected = 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) {
|
}, function(result) {
|
||||||
pandora.$ui.selected.html(pandora.ui.status('selected', result.data));
|
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?
|
that.display = function() { // fixme: used?
|
||||||
|
|
|
@ -102,7 +102,7 @@ pandora.ui.mainMenu = function() {
|
||||||
] },
|
] },
|
||||||
{ id: 'ordermovies', title: 'Order ' + pandora.site.itemName.plural, items: [
|
{ id: 'ordermovies', title: 'Order ' + pandora.site.itemName.plural, items: [
|
||||||
{ group: 'ordermovies', min: 1, max: 1, 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 == '-' }
|
{ 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: 'findMenu', title: 'Find', items: [
|
||||||
{ id: 'find', 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({
|
return Ox.extend({
|
||||||
checked: pandora.user.ui.findQuery.conditions.length &&
|
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 ||
|
||||||
(pandora.user.ui.findQuery.conditions[0].key === '' && key.id == 'all')),
|
(pandora.user.ui.findQuery.conditions[0].key === '' && key.id == 'all')
|
||||||
}, key)
|
) : key.id == 'all',
|
||||||
|
}, key);
|
||||||
}) }
|
}) }
|
||||||
] },
|
] },
|
||||||
{ id: 'advancedfind', title: 'Advanced Find...', keyboard: 'shift control f' }
|
{ id: 'advancedfind', title: 'Advanced Find...', keyboard: 'shift control f' }
|
||||||
|
@ -154,13 +155,25 @@ pandora.ui.mainMenu = function() {
|
||||||
else
|
else
|
||||||
url(id);
|
url(id);
|
||||||
} else if (data.id == 'ordermovies') {
|
} 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') {
|
} else if (data.id == 'sortmovies') {
|
||||||
var operator = pandora.getSortOperator(value);
|
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.sortSelect.selectItem(value);
|
||||||
pandora.$ui.list.sortList(value, operator);
|
pandora.$ui.list.options({
|
||||||
pandora.URL.set(pandora.Query.toString());
|
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') {
|
} else if (data.id == 'viewicons') {
|
||||||
var $list;
|
var $list;
|
||||||
pandora.UI.set({icons: value});
|
pandora.UI.set({icons: value});
|
||||||
|
|
|
@ -25,7 +25,7 @@ pandora.ui.sortSelect = function() {
|
||||||
sort: [{key: key, operator: operator}]
|
sort: [{key: key, operator: operator}]
|
||||||
});
|
});
|
||||||
// fixme: why does this not work??
|
// fixme: why does this not work??
|
||||||
//pandora.UI.set(['lists', pandora.user.ui.list, 'sort'].join('|'), [{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.user.ui.lists[pandora.user.ui.list].sort[0] = {key: key, operator: operator};
|
||||||
pandora.URL.push(pandora.Query.toString());
|
pandora.URL.push(pandora.Query.toString());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue