2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.browser = function() {
|
2011-09-20 04:11:25 +00:00
|
|
|
var that;
|
2011-06-06 15:48:11 +00:00
|
|
|
if (!pandora.user.ui.item) {
|
2011-11-06 08:28:10 +00:00
|
|
|
pandora.user.ui.filterSizes = pandora.getFilterSizes();
|
|
|
|
pandora.$ui.filters = pandora.ui.filters();
|
2011-06-19 17:49:25 +00:00
|
|
|
that = Ox.SplitPanel({
|
2011-05-25 19:42:45 +00:00
|
|
|
elements: [
|
|
|
|
{
|
2011-11-06 08:28:10 +00:00
|
|
|
element: pandora.$ui.filters[0],
|
|
|
|
size: pandora.user.ui.filterSizes[0]
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
{
|
2011-11-06 08:28:10 +00:00
|
|
|
element: pandora.$ui.filtersInnerPanel = pandora.ui.filtersInnerPanel()
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
{
|
2011-11-06 08:28:10 +00:00
|
|
|
element: pandora.$ui.filters[4],
|
|
|
|
size: pandora.user.ui.filterSizes[4]
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
id: 'browser',
|
|
|
|
orientation: 'horizontal'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-09-17 17:40:15 +00:00
|
|
|
resize: function(data) {
|
2011-11-06 08:28:10 +00:00
|
|
|
pandora.$ui.filters.forEach(function(list) {
|
2011-05-25 19:42:45 +00:00
|
|
|
list.size();
|
|
|
|
});
|
2011-10-03 00:08:00 +00:00
|
|
|
if (pandora.user.ui.listView == 'map') {
|
|
|
|
pandora.$ui.map.resizeMap();
|
|
|
|
} else if (pandora.user.ui.listView == 'calendar') {
|
2011-10-08 19:09:25 +00:00
|
|
|
pandora.$ui.calendar.resizeCalendar();
|
2013-07-09 22:49:01 +00:00
|
|
|
} else if (pandora.user.ui.listView == 'video') {
|
|
|
|
pandora.$ui.list.size();
|
2011-10-01 13:51:18 +00:00
|
|
|
}
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
2011-09-17 17:40:15 +00:00
|
|
|
resizeend: function(data) {
|
2011-11-06 08:28:10 +00:00
|
|
|
pandora.UI.set({filtersSize: data.size});
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
2011-09-17 17:40:15 +00:00
|
|
|
toggle: function(data) {
|
2011-06-06 15:48:11 +00:00
|
|
|
data.collapsed && pandora.$ui.list.gainFocus();
|
2011-11-06 08:28:10 +00:00
|
|
|
pandora.UI.set({showFilters: !data.collapsed});
|
2012-04-22 12:50:03 +00:00
|
|
|
if (!data.collapsed) {
|
|
|
|
pandora.$ui.filters.forEach(function($filter) {
|
2012-04-24 06:15:20 +00:00
|
|
|
var selected = $filter.options('_selected');
|
|
|
|
if (selected) {
|
|
|
|
$filter.bindEventOnce({
|
|
|
|
load: function() {
|
|
|
|
$filter.options({
|
|
|
|
_selected: false,
|
|
|
|
selected: selected
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}).reloadList();
|
2012-04-22 12:50:03 +00:00
|
|
|
}
|
|
|
|
});
|
2013-01-04 15:07:58 +00:00
|
|
|
pandora.$ui.filters.updateMenus();
|
2012-04-22 12:50:03 +00:00
|
|
|
}
|
2011-10-03 00:08:00 +00:00
|
|
|
if (pandora.user.ui.listView == 'map') {
|
|
|
|
pandora.$ui.map.resizeMap();
|
|
|
|
} else if (pandora.user.ui.listView == 'calendar') {
|
2011-10-08 19:09:25 +00:00
|
|
|
pandora.$ui.calendar.resizeCalendar();
|
2013-07-09 22:49:01 +00:00
|
|
|
} else if (pandora.user.ui.listView == 'video') {
|
|
|
|
pandora.$ui.list.size();
|
2011-10-03 00:08:00 +00:00
|
|
|
}
|
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,
|
2013-07-08 12:40:23 +00:00
|
|
|
defaultRatio: pandora.user.ui.icons == 'posters' ? pandora.site.posters.ratio : 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-10-13 12:24:13 +00:00
|
|
|
size = size || 64;
|
2011-09-23 10:44:54 +00:00
|
|
|
var ui = pandora.user.ui,
|
|
|
|
ratio = ui.icons == 'posters'
|
2013-07-08 12:40:23 +00:00
|
|
|
? (ui.showSitePosters ? pandora.site.posters.ratio : data.posterRatio) : 1,
|
2011-10-13 12:24:13 +00:00
|
|
|
url = '/' + data.id + '/' + (
|
2011-09-23 10:44:54 +00:00
|
|
|
ui.icons == 'posters'
|
2012-03-20 11:56:30 +00:00
|
|
|
? (ui.showSitePosters ? 'siteposter' : 'poster') : 'icon'
|
2013-05-10 11:59:20 +00:00
|
|
|
) + '128.jpg?' + data.modified,
|
2011-10-14 22:18:51 +00:00
|
|
|
format, info, sortKey = sort[0].key;
|
2012-03-08 18:18:26 +00:00
|
|
|
if (['title', 'director', 'random'].indexOf(sortKey) > -1) {
|
2011-10-13 12:24:13 +00:00
|
|
|
info = data['year'];
|
|
|
|
} else {
|
2011-10-26 14:52:23 +00:00
|
|
|
// fixme: this is duplicated many times
|
2011-10-13 12:24:13 +00:00
|
|
|
format = pandora.getSortKeyData(sortKey).format;
|
2011-10-26 14:52:23 +00:00
|
|
|
if (format) {
|
|
|
|
info = (
|
|
|
|
/^color/.test(format.type.toLowerCase()) ? Ox.Theme : Ox
|
|
|
|
)['format' + Ox.toTitleCase(format.type)].apply(
|
2012-05-24 08:22:56 +00:00
|
|
|
this, [data[sortKey]].concat(format.args || [])
|
2011-10-26 14:52:23 +00:00
|
|
|
);
|
2013-03-03 12:38:41 +00:00
|
|
|
if (sortKey == 'rightslevel') {
|
2013-07-15 12:30:41 +00:00
|
|
|
info.css({width: size * 0.75 + 'px'});
|
2013-03-03 12:38:41 +00:00
|
|
|
}
|
2011-10-26 14:52:23 +00:00
|
|
|
} else {
|
|
|
|
info = data[sortKey];
|
|
|
|
}
|
2011-10-13 12:24:13 +00:00
|
|
|
}
|
|
|
|
return {
|
|
|
|
height: ratio <= 1 ? size : size / ratio,
|
|
|
|
id: data.id,
|
|
|
|
info: info,
|
|
|
|
title: data.title + (data.director.length ? ' (' + data.director.join(', ') + ')' : ''),
|
|
|
|
url: url,
|
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, {
|
2011-09-23 10:44:54 +00:00
|
|
|
query: pandora.user.ui.find
|
2011-05-25 19:42:45 +00:00
|
|
|
}), callback);
|
|
|
|
},
|
2013-05-10 11:59:20 +00:00
|
|
|
keys: ['director', 'id', 'modified', 'posterRatio', 'title', 'year'],
|
2011-05-25 19:42:45 +00:00
|
|
|
max: 1,
|
|
|
|
min: 1,
|
|
|
|
orientation: 'horizontal',
|
2011-10-28 17:44:52 +00:00
|
|
|
pageLength: 32,
|
2011-06-06 15:48:11 +00:00
|
|
|
selected: [pandora.user.ui.item],
|
2011-05-25 19:42:45 +00:00
|
|
|
size: 64,
|
2013-02-11 08:04:55 +00:00
|
|
|
sort: getSort(),
|
2011-05-25 19:42:45 +00:00
|
|
|
unique: 'id'
|
|
|
|
})
|
2012-12-29 16:40:02 +00:00
|
|
|
.addClass('OxMedia')
|
2011-05-25 19:42:45 +00:00
|
|
|
.bindEvent({
|
2013-07-15 09:58:43 +00:00
|
|
|
copy: function() {
|
|
|
|
Ox.Clipboard.copy(pandora.user.ui.item, 'item');
|
|
|
|
},
|
|
|
|
copyadd: function() {
|
|
|
|
Ox.Clipboard.add(pandora.user.ui.item, 'item');
|
|
|
|
},
|
2011-09-17 17:40:15 +00:00
|
|
|
open: function() {
|
2011-05-25 19:42:45 +00:00
|
|
|
that.scrollToSelection();
|
|
|
|
},
|
2012-04-24 08:16:45 +00:00
|
|
|
openpreview: function() {
|
2013-08-02 15:08:16 +00:00
|
|
|
if (pandora.isVideoView()) {
|
2012-04-24 08:16:45 +00:00
|
|
|
pandora.$ui[itemView].gainFocus().triggerEvent('key_space');
|
|
|
|
}
|
|
|
|
},
|
2011-09-17 17:40:15 +00:00
|
|
|
select: function(data) {
|
2012-02-18 20:45:13 +00:00
|
|
|
data.ids.length && pandora.UI.set({
|
2011-10-29 17:46:46 +00:00
|
|
|
'item': data.ids[0]
|
2011-09-23 10:44:54 +00:00
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
},
|
2011-09-17 17:40:15 +00:00
|
|
|
toggle: function(data) {
|
2011-10-13 10:12:00 +00:00
|
|
|
pandora.UI.set({showBrowser: !data.collapsed});
|
2011-05-25 19:42:45 +00:00
|
|
|
if (data.collapsed) {
|
2012-04-17 13:43:14 +00:00
|
|
|
// fixme: can we do this for timeline and player too?
|
2012-04-17 07:06:19 +00:00
|
|
|
if (pandora.user.ui.itemView == 'editor') {
|
2012-06-06 14:22:07 +00:00
|
|
|
pandora.$ui.editor && pandora.$ui.editor.gainFocus();
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-17 13:43:14 +00:00
|
|
|
if (pandora.user.ui.itemView == 'timeline') {
|
|
|
|
pandora.$ui.timeline.options({
|
|
|
|
height: pandora.$ui.contentPanel.size(1)
|
|
|
|
});
|
|
|
|
} else if (pandora.user.ui.itemView == 'map') {
|
2011-10-04 02:45:29 +00:00
|
|
|
pandora.$ui.map.resizeMap();
|
2011-10-03 00:08:00 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'calendar') {
|
2011-10-08 19:09:25 +00:00
|
|
|
pandora.$ui.calendar.resizeCalendar();
|
2011-10-03 00:08:00 +00:00
|
|
|
}
|
2011-09-27 23:30:13 +00:00
|
|
|
},
|
|
|
|
pandora_icons: function(data) {
|
2011-09-23 10:44:54 +00:00
|
|
|
that.options({
|
2011-09-27 23:30:13 +00:00
|
|
|
borderRadius: data.value == 'posters' ? 0 : 8,
|
2013-07-08 12:40:23 +00:00
|
|
|
defaultRatio: data.value == 'posters' ? pandora.site.posters.ratio : 1
|
2013-02-11 09:26:27 +00:00
|
|
|
}).reloadList();
|
2011-09-23 10:44:54 +00:00
|
|
|
},
|
2011-09-28 17:32:03 +00:00
|
|
|
pandora_item: function(data) {
|
|
|
|
that.options({selected: [data.value]});
|
2013-02-11 09:18:18 +00:00
|
|
|
if (['accessed', 'timesaccessed'].indexOf(pandora.user.ui.listSort[0].key) > -1) {
|
2013-02-11 09:24:21 +00:00
|
|
|
Ox.Request.clearCache('find');
|
2013-02-11 09:26:27 +00:00
|
|
|
that.reloadList();
|
2013-02-11 09:18:18 +00:00
|
|
|
}
|
2011-09-28 17:32:03 +00:00
|
|
|
},
|
2013-02-11 08:04:55 +00:00
|
|
|
pandora_listsort: function() {
|
|
|
|
that.options({sort: getSort()})
|
|
|
|
},
|
2012-03-20 12:01:26 +00:00
|
|
|
pandora_showsiteposters: function() {
|
2011-09-28 00:10:26 +00:00
|
|
|
pandora.user.ui.icons == 'posters' && that.reloadList(true);
|
2011-09-23 10:44:54 +00:00
|
|
|
}
|
2012-04-24 08:16:45 +00:00
|
|
|
})
|
|
|
|
.bindEventOnce({
|
|
|
|
load: function() {
|
|
|
|
// gain focus if we're on page load or if we've just switched
|
|
|
|
// to an item and the not-yet-garbage-collected list still has
|
|
|
|
// focus
|
|
|
|
if (Ox.Focus.focused() === null || (
|
|
|
|
pandora.$ui.list && pandora.$ui.list.hasFocus()
|
|
|
|
)) {
|
|
|
|
that.gainFocus();
|
|
|
|
}
|
|
|
|
}
|
2011-09-23 10:44:54 +00:00
|
|
|
});
|
2011-11-11 16:53:05 +00:00
|
|
|
that.css({overflowY: 'hidden'}); // this fixes a bug in firefox
|
2011-09-27 23:30:13 +00:00
|
|
|
pandora.enableDragAndDrop(that, false);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
2013-02-11 08:04:55 +00:00
|
|
|
function getSort() {
|
|
|
|
return ['text', 'position'].indexOf(pandora.user.ui.listSort[0].key) > -1
|
|
|
|
? pandora.site.user.ui.listSort: pandora.user.ui.listSort
|
|
|
|
}
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|