fix mapView bugs

This commit is contained in:
rolux 2011-10-01 13:51:18 +00:00
parent bc118c67ee
commit 6b225333cd
13 changed files with 129 additions and 47 deletions

View file

@ -572,6 +572,8 @@
"listSort": [{"key": "director", "operator": ""}], "listSort": [{"key": "director", "operator": ""}],
"listView": "grid", "listView": "grid",
"lists": {}, "lists": {},
"mapFind": "",
"mapSelection": "",
"section": "items", "section": "items",
"showAnnotations": true, "showAnnotations": true,
"showControls": true, "showControls": true,

View file

@ -182,8 +182,18 @@ Ox.load({
if (!pandora.user.ui.item) { if (!pandora.user.ui.item) {
pandora.$ui.list.size(); pandora.$ui.list.size();
pandora.resizeGroups(pandora.$ui.rightPanel.width()); pandora.resizeGroups(pandora.$ui.rightPanel.width());
if (pandora.user.ui.listView == 'map') { if (!pandora.user.ui.item) {
pandora.$ui.map.resize(); if (pandora.user.ui.listView == 'map') {
pandora.$ui.map.resize();
} else {
pandora.$ui.list.size();
}
// ...
} else {
if (pandora.user.ui.itemView == 'map') {
pandora.$ui.map.resize();
}
// ...
} }
} else { } else {
//Ox.print('pandora.$ui.window.resize'); //Ox.print('pandora.$ui.window.resize');

View file

@ -117,7 +117,11 @@ pandora.UI = (function() {
pandora.URL.push(); pandora.URL.push();
} }
*/ */
pandora.URL.update(Object.keys(trigger)); // pandora.URL.update(Object.keys(trigger));
pandora.URL.update(Object.keys(
!pandora.$ui.appPanel ? args : trigger
));
}; };
return that; return that;

View file

@ -116,7 +116,7 @@ pandora.URL = (function() {
pandora.$ui.helpDialog = pandora.ui.helpDialog().open(); pandora.$ui.helpDialog = pandora.ui.helpDialog().open();
} else if (['signup', 'signin'].indexOf(state.page) > -1) { } else if (['signup', 'signin'].indexOf(state.page) > -1) {
if (pandora.user.level == 'guest') { if (pandora.user.level == 'guest') {
pandora.$ui.accountDialog = pandora.ui.accountDialog(state.page).open(); pandora.ui.accountDialog(state.page).open();
} else { } else {
pandora.URL.replace('/'); pandora.URL.replace('/');
} }
@ -147,11 +147,23 @@ pandora.URL = (function() {
if (state.span) { if (state.span) {
if (['video', 'timeline'].indexOf(state.view) > -1) { if (['video', 'timeline'].indexOf(state.view) > -1) {
// fixme: this doesn't handle annotation ids
set['videoPoints.' + state.item] = { set['videoPoints.' + state.item] = {
position: state.span[0], position: state.span[0],
'in': state.span[1] || 0, 'in': state.span[1] || 0,
out: state.span[2] || 0 out: state.span[2] || 0
} }
} else if (state.view == 'map') {
// fixme: this doesn't handle map coordinates
if (state.span[0] != '@') {
pandora.user.ui.mapSelection = state.span;
//set['mapSelection'] = state.span;
//set['mapFind'] = '';
} else {
pandora.user.ui.mapFind = state.span.substr(1);
//set['mapFind'] = state.span.substr(1);
//set['mapSelection'] = '';
}
} }
} }
@ -304,7 +316,7 @@ pandora.URL = (function() {
document.location.href = decodeURI(document.location.pathname.substr(4)); document.location.href = decodeURI(document.location.pathname.substr(4));
} else { } else {
self.URL.parse(function(state) { self.URL.parse(function(state) {
setState(state, callback); setState(state, callback); // setState -> UI.set -> URL.update
}); });
} }
return that; return that;
@ -337,6 +349,7 @@ pandora.URL = (function() {
}; };
that.update = function(keys) { that.update = function(keys) {
// this gets called from pandora.UI
var action; var action;
if (self.isPopState) { if (self.isPopState) {
self.isPopState = false; self.isPopState = false;

View file

@ -23,17 +23,27 @@ pandora.ui.browser = function() {
}) })
.bindEvent({ .bindEvent({
resize: function(data) { resize: function(data) {
pandora.user.ui.groupsSize = data.size;
pandora.$ui.groups.forEach(function(list) { pandora.$ui.groups.forEach(function(list) {
list.size(); list.size();
}); });
if (!pandora.user.ui.item) {
if (pandora.user.ui.listView == 'map') {
pandora.$ui.map.resize();
}
// ...
} else {
if (pandora.user.ui.itemView == 'map') {
pandora.$ui.map.resize();
}
// ...
}
}, },
resizeend: function(data) { resizeend: function(data) {
pandora.UI.set({groupsSize: data.size}); pandora.UI.set({groupsSize: data.size});
}, },
toggle: function(data) { toggle: function(data) {
pandora.UI.set({showGroups: !data.collapsed});
data.collapsed && pandora.$ui.list.gainFocus(); data.collapsed && pandora.$ui.list.gainFocus();
pandora.UI.set({showGroups: !data.collapsed});
} }
}); });
} else { } else {

View file

@ -34,7 +34,12 @@ pandora.ui.clipList = function(videoRatio) {
width: width width: width
}; };
}, },
items: isClipView ? function(data, callback) { items: function(data, callback) {
if (!isClipView) {
// fixme: this will have to be updated
callback({data: {items: []}});
return;
}
var itemQuery, query; var itemQuery, query;
if (!ui.item) { if (!ui.item) {
itemQuery = ui.find; itemQuery = ui.find;
@ -64,7 +69,7 @@ pandora.ui.clipList = function(videoRatio) {
itemQuery: itemQuery, itemQuery: itemQuery,
query: query query: query
}, data), callback); }, data), callback);
} : [], },
keys: Ox.merge( keys: Ox.merge(
['id', 'in', 'out', 'value'], ['id', 'in', 'out', 'value'],
!ui.item ? ['videoRatio'] : [] !ui.item ? ['videoRatio'] : []

View file

@ -252,7 +252,9 @@ pandora.ui.infoView = function(data) {
data.filming_locations && $('<div>') data.filming_locations && $('<div>')
.css(css) .css(css)
.html( .html(
formatKey('Filming Locations') + data.filming_locations.join('; ') formatKey('Filming Locations') + data.filming_locations.map(function(location) {
return '<a href="/map/@' + location + '">' + location + '</a>'
}).join(', ')
) )
.appendTo($text); .appendTo($text);
@ -304,7 +306,11 @@ pandora.ui.infoView = function(data) {
'Spoofs', 'Spoofed in' 'Spoofs', 'Spoofed in'
].forEach(function(key) { ].forEach(function(key) {
data.connections[key] && html.push( data.connections[key] && html.push(
formatKey(key) + formatConnections(data.connections[key]) formatKey(key) + data.connections[key].map(function(connection) {
return connection.item
? '<a href="/' + connection.item + '">' + connection.title + '</a>'
: connection.title;
}).join(', ')
); );
}); });
$div.html(html.join('; ')); $div.html(html.join('; '));
@ -352,12 +358,6 @@ pandora.ui.infoView = function(data) {
return '<span style="color: rgb(128, 128, 128)">' + str + '</span>'; return '<span style="color: rgb(128, 128, 128)">' + str + '</span>';
} }
function formatConnections(connections) {
return connections.map(function(c) {
return c.item ? '<a href="/' + c.item + '">' + c.title + '</a>' : c.title;
}).join(', ');
}
function formatValue(value, key) { function formatValue(value, key) {
return (Ox.isArray(value) ? value : [value]).map(function(value) { return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ? return key ?

View file

@ -388,7 +388,6 @@ pandora.ui.item = function() {
data: result.data, data: result.data,
width: pandora.$ui.mainPanel.size(1) - Ox.UI.SCROLLBAR_SIZE width: pandora.$ui.mainPanel.size(1) - Ox.UI.SCROLLBAR_SIZE
}).appendTo(stats); }).appendTo(stats);
pandora.$ui.contentPanel.replaceElement(1, stats); pandora.$ui.contentPanel.replaceElement(1, stats);
} else if (pandora.user.ui.itemView == 'files') { } else if (pandora.user.ui.itemView == 'files') {

View file

@ -525,6 +525,7 @@ pandora.ui.list = function() {
} }
that.bindEvent({ that.bindEvent({
// fixme: this is nonsense for map and calendar
pandora_listsort: function(data) { pandora_listsort: function(data) {
that.options({sort: data.value}); that.options({sort: data.value});
} }

View file

@ -12,6 +12,7 @@ pandora.ui.mapView = function(videoRatio) {
listSize = listSizes[ui.clipsColumns - 1], listSize = listSizes[ui.clipsColumns - 1],
$map = Ox.Map({ $map = Ox.Map({
find: ui.mapFind,
// 20 menu + 24 toolbar + 1 resizebar + 16 statusbar // 20 menu + 24 toolbar + 1 resizebar + 16 statusbar
height: window.innerHeight - ui.showGroups * ui.groupsSize - 61, height: window.innerHeight - ui.showGroups * ui.groupsSize - 61,
places: function(data, callback) { places: function(data, callback) {
@ -24,11 +25,11 @@ pandora.ui.mapView = function(videoRatio) {
operator: '&' operator: '&'
}; };
} }
return pandora.api.findPlaces(Ox.extend(data, { return pandora.api.findPlaces(Ox.extend({
itemQuery: itemQuery, itemQuery: itemQuery
query: {conditions: [], operator: '&'} }, data), callback);
}), callback);
}, },
selected: ui.mapSelection,
showTypes: true, showTypes: true,
toolbar: true, toolbar: true,
width: window.innerWidth - ui.showSidebar * ui.sidebarSize - listSize - 2, width: window.innerWidth - ui.showSidebar * ui.sidebarSize - listSize - 2,
@ -40,6 +41,7 @@ pandora.ui.mapView = function(videoRatio) {
}, },
selectplace: function(data) { selectplace: function(data) {
var id = data.id || ''; var id = data.id || '';
updateToolbar(id ? data : null);
if (id && id[0] != '_') { if (id && id[0] != '_') {
$list.options({ $list.options({
items: function(data, callback) { items: function(data, callback) {
@ -61,10 +63,12 @@ pandora.ui.mapView = function(videoRatio) {
}, data), callback); }, data), callback);
} }
}); });
updateToolbar(data);
} else { } else {
$list.options({items: []}); $list.options({
updateToolbar(); items: function(data, callback) {
callback({data: {items: data.keys ? [] : 0}});
}
});
} }
} }
}), }),
@ -91,6 +95,7 @@ pandora.ui.mapView = function(videoRatio) {
.bindEvent({ .bindEvent({
click: function() { click: function() {
$map.options({selected: null}); $map.options({selected: null});
updateStatusbar(0);
} }
}), }),
@ -199,7 +204,19 @@ pandora.ui.mapView = function(videoRatio) {
$placeButton.options({disabled: !place}); $placeButton.options({disabled: !place});
} }
// fixme: this is needed for the main window resize handler that.bindEvent({
pandora_itemsort: function(data) {
ui.item && $list.options({sort: data.value});
},
pandora_listsort: function(data) {
!ui.item && $list.options({sort: data.value});
}
});
pandora.user.ui.mapFind = '';
pandora.user.ui.mapSelection = '';
// fixme: this is needed for some resize handlers further up
pandora.$ui.map = $map; pandora.$ui.map = $map;
return that; return that;

View file

@ -136,14 +136,8 @@ pandora.ui.mainMenu = function() {
{ id: 'help', title: pandora.site.site.name + ' Help', keyboard: 'shift ?' } { id: 'help', title: pandora.site.site.name + ' Help', keyboard: 'shift ?' }
] }, ] },
{ id: 'debugMenu', title: 'Debug', items: [ { id: 'debugMenu', title: 'Debug', items: [
{ id: 'query', title: 'Show pandora.Query' },
{ id: 'resetui', title: 'Reset UI Settings'},
{ id: 'clearcache', title: 'Clear cache'}, { id: 'clearcache', title: 'Clear cache'},
{ id: 'nestedone', title: 'Some Nesting', items: [ { id: 'resetui', title: 'Reset UI Settings'}
{ id: 'nestedtwo', title: 'Some More Nesting', items: [
{ id: 'nestedthree', title: 'Even More Nesting' }
] }
] }
] } ] }
] ]
}) })

View file

@ -1,27 +1,52 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript // vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.toolbar = function() { pandora.ui.toolbar = function() {
var that = Ox.Bar({ var ui = pandora.user.ui,
that = Ox.Bar({
size: 24 size: 24
}).css({ }).css({
zIndex: 2 // fixme: remove later zIndex: 2 // fixme: remove later
}); });
pandora.user.ui.item && that.append( ui.item && that.append(
pandora.$ui.backButton = pandora.ui.backButton() pandora.$ui.backButton = pandora.ui.backButton()
); );
that.append( that.append(
pandora.$ui.viewSelect = pandora.ui.viewSelect() pandora.$ui.viewSelect = pandora.ui.viewSelect()
); );
if (!pandora.user.ui.item || pandora.isClipView()) { if (!ui.item || pandora.isClipView()) {
that.append( that.append(
pandora.$ui.sortSelect = pandora.ui.sortSelect() pandora.$ui.sortSelect = pandora.ui.sortSelect()
); );
} }
if (!pandora.user.ui.item) { if (!ui.item) {
that.append( that.append(
pandora.$ui.orderButton = pandora.ui.orderButton() pandora.$ui.orderButton = pandora.ui.orderButton()
); );
} }
if (ui.item && ui.itemView == 'info' && pandora.user.level == 'admin') {
that.append(
Ox.Button({
title: 'Reload Metadata'
})
.css({float: 'left', margin: '4px'})
.bindEvent({
click: function() {
var item = ui.item;
// fixme: maybe there's a better method name for this?
pandora.api.updateExternalData({
id: ui.item
}, function(result) {
Ox.Request.clearCache(item);
if (ui.item == item && ui.itemView == 'info') {
pandora.$ui.contentPanel.replaceElement(
1, pandora.$ui.item = pandora.ui.item()
);
}
});
}
})
);
}
that.append( that.append(
pandora.$ui.findElement = pandora.ui.findElement() pandora.$ui.findElement = pandora.ui.findElement()
); );

View file

@ -419,8 +419,8 @@ pandora.getFoldersWidth = function() {
var width = pandora.user.ui.sidebarSize; var width = pandora.user.ui.sidebarSize;
// fixme: don't use height(), look up in splitpanels // fixme: don't use height(), look up in splitpanels
if ( if (
/*pandora.$ui.appPanel pandora.$ui.appPanel
&&*/ pandora.getFoldersHeight() > pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height() && pandora.getFoldersHeight() > pandora.$ui.leftPanel.height() - 24 - 1 - pandora.$ui.info.height()
) { ) {
width -= Ox.UI.SCROLLBAR_SIZE; width -= Ox.UI.SCROLLBAR_SIZE;
} }
@ -525,8 +525,6 @@ pandora.getMetadataByIdOrName = function(item, view, str, callback) {
if (id) { if (id) {
callback(id, 'calendar'); callback(id, 'calendar');
} else if (canBePlace && isName) { } else if (canBePlace && isName) {
// set map query ...
pandora.user.ui.mapFind = str;
callback('@' + str, 'map'); callback('@' + str, 'map');
} else { } else {
callback(); callback();
@ -540,17 +538,21 @@ pandora.getMetadataByIdOrName = function(item, view, str, callback) {
if (type) { if (type) {
pandora.api['find' + Ox.toTitleCase(type + 's')](Ox.extend({ pandora.api['find' + Ox.toTitleCase(type + 's')](Ox.extend({
query: { query: {
key: isName ? 'name' : 'id', conditions: [{
value: type == 'annotation' ? item + '/' + str : str, key: isName ? 'name' : 'id',
operator: '=' value: type == 'annotation' ? item + '/' + str : str,
operator: '=='
}],
operator: '&'
}, },
keys: ['id'], keys: ['id'],
range: [0, 1] range: [0, 1]
}, item ? { }, item ? {
itemQuery: {key: 'id', value: item, operator: '='} itemQuery: {
conditions: [{key: 'id', value: item, operator: '=='}],
operator: '&'
}
} : {}), function(result) { } : {}), function(result) {
// fixme: this has to be fixed on the backend!
if (result.data.events) { result.data.items = result.data.events; };
callback(result.data.items.length ? result.data.items[0].id : ''); callback(result.data.items.length ? result.data.items[0].id : '');
}); });
} else { } else {