2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.browser = function() {
|
2011-08-24 06:19:34 +00:00
|
|
|
var sizes, that;
|
2011-06-06 15:48:11 +00:00
|
|
|
if (!pandora.user.ui.item) {
|
2011-08-24 06:19:34 +00:00
|
|
|
pandora.user.ui.groupsSizes = pandora.getGroupsSizes();
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.groups = pandora.ui.groups();
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.SplitPanel({
|
2011-05-25 19:42:45 +00:00
|
|
|
elements: [
|
|
|
|
{
|
2011-06-06 15:48:11 +00:00
|
|
|
element: pandora.$ui.groups[0],
|
2011-08-24 06:19:34 +00:00
|
|
|
size: pandora.user.ui.groupsSizes[0]
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
{
|
2011-06-06 15:48:11 +00:00
|
|
|
element: pandora.$ui.groupsInnerPanel = pandora.ui.groupsInnerPanel()
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
{
|
2011-06-06 15:48:11 +00:00
|
|
|
element: pandora.$ui.groups[4],
|
2011-08-24 06:19:34 +00:00
|
|
|
size: pandora.user.ui.groupsSizes[4]
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
id: 'browser',
|
|
|
|
orientation: 'horizontal'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: function(event, data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.user.ui.groupsSize = data;
|
|
|
|
$.each(pandora.$ui.groups, function(i, list) {
|
2011-05-25 19:42:45 +00:00
|
|
|
list.size();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
resizeend: function(event, data){
|
|
|
|
pandora.UI.set({groupsSize: data});
|
|
|
|
},
|
|
|
|
toggle: function(event, data) {
|
|
|
|
pandora.UI.set({showGroups: !data.collapsed});
|
2011-06-06 15:48:11 +00:00
|
|
|
data.collapsed && pandora.$ui.list.gainFocus();
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2011-06-19 17:49:25 +00:00
|
|
|
var that = Ox.IconList({
|
2011-08-17 15:52:58 +00:00
|
|
|
borderRadius: pandora.user.ui.icons == 'posters' ? 0 : 8,
|
2011-05-25 19:42:45 +00:00
|
|
|
centered: true,
|
2011-08-07 20:25:33 +00:00
|
|
|
defaultRatio: pandora.user.ui.icons == 'posters' ? 5/8 : 1,
|
2011-09-04 12:43:59 +00:00
|
|
|
draggable: true,
|
2011-05-25 19:42:45 +00:00
|
|
|
id: 'list',
|
|
|
|
item: function(data, sort, size) {
|
2011-08-07 20:25:33 +00:00
|
|
|
var icons = pandora.user.ui.icons,
|
2011-08-19 12:33:02 +00:00
|
|
|
ratio = icons == 'posters' ? data.posterRatio : 1;
|
2011-05-25 19:42:45 +00:00
|
|
|
size = size || 64;
|
|
|
|
return {
|
|
|
|
height: ratio <= 1 ? size : size / ratio,
|
2011-08-07 20:25:33 +00:00
|
|
|
id: data.id,
|
2011-05-25 19:42:45 +00:00
|
|
|
info: data[['title', 'director'].indexOf(sort[0].key) > -1 ? 'year' : sort[0].key],
|
|
|
|
title: data.title + (data.director ? ' (' + data.director + ')' : ''),
|
2011-08-07 20:25:33 +00:00
|
|
|
url: icons == 'posters'
|
|
|
|
? '/' + data.id + '/poster' + size + '.jpg'
|
|
|
|
: '/' + data.id + '/icon' + size + '.jpg',
|
2011-05-25 19:42:45 +00:00
|
|
|
width: ratio >= 1 ? size : size * ratio
|
|
|
|
};
|
|
|
|
},
|
|
|
|
items: function(data, callback) {
|
2011-08-24 08:25:08 +00:00
|
|
|
pandora.api.find(Ox.extend(data, {
|
|
|
|
query: pandora.user.ui.query
|
2011-05-25 19:42:45 +00:00
|
|
|
}), callback);
|
|
|
|
},
|
2011-08-19 12:33:02 +00:00
|
|
|
keys: ['director', 'id', 'posterRatio', 'title', 'year'],
|
2011-05-25 19:42:45 +00:00
|
|
|
max: 1,
|
|
|
|
min: 1,
|
|
|
|
orientation: 'horizontal',
|
2011-06-06 15:48:11 +00:00
|
|
|
selected: [pandora.user.ui.item],
|
2011-05-25 19:42:45 +00:00
|
|
|
size: 64,
|
2011-06-06 15:48:11 +00:00
|
|
|
sort: pandora.user.ui.lists[pandora.user.ui.list].sort,
|
2011-05-25 19:42:45 +00:00
|
|
|
unique: 'id'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
open: function(event, data) {
|
|
|
|
that.scrollToSelection();
|
|
|
|
},
|
|
|
|
select: function(event, data) {
|
2011-08-17 09:29:42 +00:00
|
|
|
pandora.UI.set('lists|' + pandora.user.ui.list + '|selected', data.ids);
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.URL.set(data.ids[0]);
|
|
|
|
},
|
|
|
|
toggle: function(event, data) {
|
|
|
|
pandora.UI.set({showMovies: !data.collapsed});
|
|
|
|
if (data.collapsed) {
|
2011-06-06 15:48:11 +00:00
|
|
|
if (pandora.user.ui.itemView == 'timeline') {
|
|
|
|
pandora.$ui.editor.gainFocus();
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2011-09-04 12:43:59 +00:00
|
|
|
pandora.enableDragAndDrop(that, false);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
that.update = function() {
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser());
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|