2011-10-03 13:23:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2012-03-21 03:09:24 +00:00
|
|
|
|
2011-11-05 17:04:10 +00:00
|
|
|
'use strict';
|
2012-03-21 03:09:24 +00:00
|
|
|
|
2011-10-03 13:23:11 +00:00
|
|
|
pandora.ui.navigationView = function(type, videoRatio) {
|
|
|
|
|
|
|
|
var ui = pandora.user.ui,
|
2013-03-01 11:24:22 +00:00
|
|
|
isEmbed = pandora.isEmbedURL(),
|
2011-10-03 13:23:11 +00:00
|
|
|
itemName = type == 'map' ? 'place' : 'event',
|
|
|
|
listSizes = [
|
|
|
|
144 + Ox.UI.SCROLLBAR_SIZE,
|
|
|
|
280 + Ox.UI.SCROLLBAR_SIZE,
|
|
|
|
416 + Ox.UI.SCROLLBAR_SIZE
|
|
|
|
],
|
2013-07-12 20:31:34 +00:00
|
|
|
listSize = listSizes[ui.clipColumns - 1],
|
2011-10-03 13:23:11 +00:00
|
|
|
|
|
|
|
$element = Ox.Element(),
|
|
|
|
|
|
|
|
$toolbar = Ox.Bar({size: 24})
|
2011-10-31 13:20:42 +00:00
|
|
|
.append(
|
2013-03-01 06:08:51 +00:00
|
|
|
pandora.$ui.sortElement = pandora.ui.sortElement(true)
|
2013-07-08 11:30:33 +00:00
|
|
|
)
|
|
|
|
.bindEvent({
|
|
|
|
doubleclick: function(e) {
|
|
|
|
if ($(e.target).is('.OxBar')) {
|
|
|
|
$list.animate({scrollTop: 0}, 250);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}),
|
2011-10-03 13:23:11 +00:00
|
|
|
|
|
|
|
$list = pandora.ui.clipList(videoRatio)
|
|
|
|
.bindEvent({
|
|
|
|
init: function(data) {
|
|
|
|
updateStatusbar(data.items);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
$status = $('<div>')
|
|
|
|
.css({
|
|
|
|
width: '100%',
|
|
|
|
marginTop: '2px',
|
|
|
|
fontSize: '9px',
|
|
|
|
textAlign: 'center',
|
|
|
|
textOverflow: 'ellipsis'
|
|
|
|
}),
|
|
|
|
|
|
|
|
$statusbar = Ox.Bar({size: 16}).append($status),
|
|
|
|
|
|
|
|
$listPanel = Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: $toolbar,
|
|
|
|
size: 24
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $list
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $statusbar,
|
|
|
|
size: 16
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2011-10-30 21:05:57 +00:00
|
|
|
resize: function() {
|
|
|
|
$list.size()
|
2011-10-03 13:23:11 +00:00
|
|
|
},
|
|
|
|
resizeend: function(data) {
|
|
|
|
var size = data.size;
|
|
|
|
if (listSizes.indexOf(size) == -1) {
|
|
|
|
if (size <= (listSizes[0] + listSizes[1]) / 2) {
|
|
|
|
size = listSizes[0];
|
|
|
|
} else if (size < (listSizes[1] + listSizes[2]) / 2) {
|
|
|
|
size = listSizes[1];
|
|
|
|
} else {
|
|
|
|
size = listSizes[2];
|
|
|
|
}
|
|
|
|
that.size(1, size, function() {
|
|
|
|
// strangely, the animation may still not be fully
|
|
|
|
// finished, causing the list size to be off by one
|
|
|
|
setTimeout(function() {
|
|
|
|
$element['resize' + Ox.toTitleCase(type)]();
|
|
|
|
$list.size();
|
|
|
|
}, 0);
|
|
|
|
});
|
|
|
|
}
|
2013-07-12 20:31:34 +00:00
|
|
|
pandora.UI.set({clipColumns: listSizes.indexOf(size) + 1});
|
2011-10-03 13:23:11 +00:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2013-03-01 11:24:22 +00:00
|
|
|
that = !isEmbed ? Ox.SplitPanel({
|
2011-10-03 13:23:11 +00:00
|
|
|
elements: [
|
|
|
|
{
|
2012-05-26 15:46:24 +00:00
|
|
|
element: $element
|
2011-10-03 13:23:11 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $listPanel,
|
|
|
|
resizable: true,
|
|
|
|
resize: listSizes,
|
|
|
|
size: listSize,
|
2013-05-09 10:13:58 +00:00
|
|
|
tooltip: Ox._('clips')
|
2011-10-03 13:23:11 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
2013-03-01 11:24:22 +00:00
|
|
|
}) : Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: $element
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $listPanel,
|
|
|
|
size: 188 + Ox.UI.SCROLLBAR_SIZE
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
2011-10-03 13:23:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (type == 'map') {
|
|
|
|
|
|
|
|
that.replaceElement(0,
|
|
|
|
$element = Ox.Map({
|
2011-10-30 21:05:57 +00:00
|
|
|
// clickable: pandora.site.capabilities.canClickMap[pandora.user.level],
|
2011-10-03 13:23:11 +00:00
|
|
|
find: ui.mapFind,
|
2012-04-23 06:31:44 +00:00
|
|
|
// 20 px menu + 24 px toolbar + 1px resizbar + 16px statusbar (if !item)
|
2013-03-01 11:24:22 +00:00
|
|
|
height: isEmbed ? window.innerHeight - 40
|
|
|
|
: !ui.item ? window.innerHeight - ui.showFilters * ui.filtersSize - 61
|
2012-04-23 06:31:44 +00:00
|
|
|
: window.innerHeight - ui.showBrowser * (112 + Ox.UI.SCROLLBAR_SIZE) - 45,
|
2011-10-03 13:23:11 +00:00
|
|
|
places: function(data, callback) {
|
2011-10-19 16:20:12 +00:00
|
|
|
var itemsQuery;
|
2011-10-03 13:23:11 +00:00
|
|
|
if (!ui.item) {
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery = ui.find;
|
2011-10-03 13:23:11 +00:00
|
|
|
} else {
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery = {
|
2011-10-03 13:23:11 +00:00
|
|
|
conditions: [{key: 'id', value: ui.item, operator: '=='}],
|
|
|
|
operator: '&'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return pandora.api.findPlaces(Ox.extend({
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery: itemsQuery
|
2011-10-03 13:23:11 +00:00
|
|
|
}, data), callback);
|
|
|
|
},
|
|
|
|
selected: ui.mapSelection,
|
2011-10-04 02:26:54 +00:00
|
|
|
showControls: ui.showMapControls,
|
|
|
|
showLabels: ui.showMapLabels,
|
2011-10-03 13:23:11 +00:00
|
|
|
showTypes: true,
|
|
|
|
toolbar: true,
|
2013-03-01 11:24:22 +00:00
|
|
|
width: isEmbed ? window.innerWidth
|
|
|
|
: window.innerWidth - ui.showSidebar * ui.sidebarSize - listSize - 2,
|
2011-10-03 13:23:11 +00:00
|
|
|
zoombar: true
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: function() {
|
|
|
|
$element.resizeMap();
|
|
|
|
},
|
2011-10-04 02:26:54 +00:00
|
|
|
selectplace: selectItem,
|
|
|
|
togglecontrols: function(data) {
|
2013-07-14 15:36:49 +00:00
|
|
|
pandora.UI.set({showMapControls: data.visible});
|
2011-10-04 02:26:54 +00:00
|
|
|
},
|
|
|
|
togglelabels: function(data) {
|
2013-07-14 15:36:49 +00:00
|
|
|
pandora.UI.set({showMapLabels: data.visible});
|
2011-10-04 02:26:54 +00:00
|
|
|
}
|
2011-10-03 13:23:11 +00:00
|
|
|
})
|
|
|
|
);
|
2011-10-08 19:09:25 +00:00
|
|
|
// needed for resize handlers further up
|
|
|
|
pandora.$ui.map = $element;
|
2011-10-29 17:46:46 +00:00
|
|
|
|
2011-10-03 13:23:11 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
pandora.api.findEvents({
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery: !ui.item ? ui.find : {
|
2011-10-13 12:04:27 +00:00
|
|
|
conditions: [{key: 'id', value: ui.item, operator: '=='}],
|
|
|
|
operator: '&'
|
|
|
|
},
|
2011-10-03 13:23:11 +00:00
|
|
|
keys: ['id', 'name', 'start', 'end'],
|
2012-02-02 05:16:32 +00:00
|
|
|
query: {
|
|
|
|
conditions: [{key: 'start', value: '', operator: '!='}]
|
|
|
|
},
|
2011-10-10 12:52:53 +00:00
|
|
|
range: [0, 1000000]
|
2011-10-03 13:23:11 +00:00
|
|
|
}, function(result) {
|
|
|
|
that.replaceElement(0,
|
|
|
|
$element = Ox.Calendar({
|
2013-03-06 14:09:18 +00:00
|
|
|
date: new Date(ui.calendarFind || 0),
|
2011-10-03 13:23:11 +00:00
|
|
|
events: result.data.items,
|
2012-04-23 06:31:44 +00:00
|
|
|
// 20 px menu + 24 px toolbar + 1px resizbar + 16px statusbar (if !item)
|
|
|
|
height: !ui.item
|
|
|
|
? window.innerHeight - ui.showFilters * ui.filtersSize - 61
|
|
|
|
: window.innerHeight - ui.showBrowser * (112 + Ox.UI.SCROLLBAR_SIZE) - 45,
|
2011-10-03 13:23:11 +00:00
|
|
|
range: [-5000, 5000],
|
2013-03-06 14:09:18 +00:00
|
|
|
selected: ui.calendarSelection,
|
2011-10-31 12:46:17 +00:00
|
|
|
showControls: ui.showCalendarControls,
|
2012-01-13 16:26:07 +00:00
|
|
|
showToolbar: true,
|
|
|
|
showZoombar: true,
|
2011-10-03 13:23:11 +00:00
|
|
|
width: window.innerWidth - ui.showSidebar * ui.sidebarSize - listSize - 2,
|
|
|
|
zoom: 4
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
resize: function(data) {
|
2011-10-09 21:12:50 +00:00
|
|
|
// triggered by SplitPanel
|
2011-10-03 13:23:11 +00:00
|
|
|
$element.resizeCalendar();
|
|
|
|
},
|
|
|
|
select: selectItem
|
|
|
|
})
|
|
|
|
);
|
2011-10-08 19:09:25 +00:00
|
|
|
// needed for resize handlers further up
|
|
|
|
pandora.$ui.calendar = $element;
|
2011-10-29 17:46:46 +00:00
|
|
|
});
|
2011-10-03 13:23:11 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-08-05 22:45:49 +00:00
|
|
|
updateStatusbar(0);
|
2011-10-03 13:23:11 +00:00
|
|
|
|
|
|
|
function selectItem(data) {
|
|
|
|
var id = data.id || '';
|
|
|
|
if (id && id[0] != '_') {
|
2013-05-09 10:13:58 +00:00
|
|
|
$status.html(Ox._('Loading...'));
|
2011-10-03 13:23:11 +00:00
|
|
|
$list.options({
|
|
|
|
items: function(data, callback) {
|
2011-10-19 16:20:12 +00:00
|
|
|
var itemsQuery;
|
2011-10-03 13:23:11 +00:00
|
|
|
if (!ui.item) {
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery = ui.find;
|
2011-10-03 13:23:11 +00:00
|
|
|
} else {
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery = {
|
2011-10-03 13:23:11 +00:00
|
|
|
conditions: [{key: 'id', value: ui.item, operator: '=='}],
|
|
|
|
operator: '&'
|
|
|
|
};
|
|
|
|
}
|
2012-06-20 17:45:14 +00:00
|
|
|
return pandora.api.findClips(Ox.extend(data, {
|
2011-10-19 16:20:12 +00:00
|
|
|
itemsQuery: itemsQuery,
|
2011-10-03 13:23:11 +00:00
|
|
|
query: {
|
|
|
|
conditions: [{key: itemName, value: id, operator:'=='}],
|
|
|
|
operator: '&'
|
2012-05-26 15:46:24 +00:00
|
|
|
}
|
2012-06-20 17:45:14 +00:00
|
|
|
}), callback);
|
2011-10-03 13:23:11 +00:00
|
|
|
}
|
|
|
|
});
|
2011-10-08 18:36:26 +00:00
|
|
|
type == 'map' && pandora.UI.set({mapSelection: data.name});
|
2011-10-03 13:23:11 +00:00
|
|
|
} else {
|
|
|
|
$list.options({
|
2013-08-10 09:35:42 +00:00
|
|
|
selected: []
|
|
|
|
}).options({
|
2011-10-03 13:23:11 +00:00
|
|
|
items: function(data, callback) {
|
|
|
|
callback({data: {items: data.keys ? [] : 0}});
|
|
|
|
}
|
|
|
|
});
|
2011-10-08 18:36:26 +00:00
|
|
|
type == 'map' && pandora.UI.set({mapSelection: id ? $element.options('find') : ''});
|
2011-10-03 13:23:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateStatusbar(items) {
|
2013-07-18 08:14:14 +00:00
|
|
|
$status.html(Ox.toTitleCase(Ox.formatCount(items, 'clip')));
|
2011-10-03 13:23:11 +00:00
|
|
|
}
|
|
|
|
|
2011-10-13 12:04:27 +00:00
|
|
|
// needed to it can recieve events from UI module
|
|
|
|
pandora.$ui.clipList = $list;
|
|
|
|
|
2011-10-03 13:23:11 +00:00
|
|
|
return that;
|
|
|
|
|
2012-02-02 05:16:32 +00:00
|
|
|
};
|