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": ""}],
"listView": "grid",
"lists": {},
"mapFind": "",
"mapSelection": "",
"section": "items",
"showAnnotations": true,
"showControls": true,

View file

@ -182,8 +182,18 @@ Ox.load({
if (!pandora.user.ui.item) {
pandora.$ui.list.size();
pandora.resizeGroups(pandora.$ui.rightPanel.width());
if (!pandora.user.ui.item) {
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 {
//Ox.print('pandora.$ui.window.resize');

View file

@ -117,7 +117,11 @@ pandora.UI = (function() {
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;

View file

@ -116,7 +116,7 @@ pandora.URL = (function() {
pandora.$ui.helpDialog = pandora.ui.helpDialog().open();
} else if (['signup', 'signin'].indexOf(state.page) > -1) {
if (pandora.user.level == 'guest') {
pandora.$ui.accountDialog = pandora.ui.accountDialog(state.page).open();
pandora.ui.accountDialog(state.page).open();
} else {
pandora.URL.replace('/');
}
@ -147,11 +147,23 @@ pandora.URL = (function() {
if (state.span) {
if (['video', 'timeline'].indexOf(state.view) > -1) {
// fixme: this doesn't handle annotation ids
set['videoPoints.' + state.item] = {
position: state.span[0],
'in': state.span[1] || 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));
} else {
self.URL.parse(function(state) {
setState(state, callback);
setState(state, callback); // setState -> UI.set -> URL.update
});
}
return that;
@ -337,6 +349,7 @@ pandora.URL = (function() {
};
that.update = function(keys) {
// this gets called from pandora.UI
var action;
if (self.isPopState) {
self.isPopState = false;

View file

@ -23,17 +23,27 @@ pandora.ui.browser = function() {
})
.bindEvent({
resize: function(data) {
pandora.user.ui.groupsSize = data.size;
pandora.$ui.groups.forEach(function(list) {
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) {
pandora.UI.set({groupsSize: data.size});
},
toggle: function(data) {
pandora.UI.set({showGroups: !data.collapsed});
data.collapsed && pandora.$ui.list.gainFocus();
pandora.UI.set({showGroups: !data.collapsed});
}
});
} else {

View file

@ -34,7 +34,12 @@ pandora.ui.clipList = function(videoRatio) {
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;
if (!ui.item) {
itemQuery = ui.find;
@ -64,7 +69,7 @@ pandora.ui.clipList = function(videoRatio) {
itemQuery: itemQuery,
query: query
}, data), callback);
} : [],
},
keys: Ox.merge(
['id', 'in', 'out', 'value'],
!ui.item ? ['videoRatio'] : []

View file

@ -252,7 +252,9 @@ pandora.ui.infoView = function(data) {
data.filming_locations && $('<div>')
.css(css)
.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);
@ -304,7 +306,11 @@ pandora.ui.infoView = function(data) {
'Spoofs', 'Spoofed in'
].forEach(function(key) {
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('; '));
@ -352,12 +358,6 @@ pandora.ui.infoView = function(data) {
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) {
return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ?

View file

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

View file

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

View file

@ -12,6 +12,7 @@ pandora.ui.mapView = function(videoRatio) {
listSize = listSizes[ui.clipsColumns - 1],
$map = Ox.Map({
find: ui.mapFind,
// 20 menu + 24 toolbar + 1 resizebar + 16 statusbar
height: window.innerHeight - ui.showGroups * ui.groupsSize - 61,
places: function(data, callback) {
@ -24,11 +25,11 @@ pandora.ui.mapView = function(videoRatio) {
operator: '&'
};
}
return pandora.api.findPlaces(Ox.extend(data, {
itemQuery: itemQuery,
query: {conditions: [], operator: '&'}
}), callback);
return pandora.api.findPlaces(Ox.extend({
itemQuery: itemQuery
}, data), callback);
},
selected: ui.mapSelection,
showTypes: true,
toolbar: true,
width: window.innerWidth - ui.showSidebar * ui.sidebarSize - listSize - 2,
@ -40,6 +41,7 @@ pandora.ui.mapView = function(videoRatio) {
},
selectplace: function(data) {
var id = data.id || '';
updateToolbar(id ? data : null);
if (id && id[0] != '_') {
$list.options({
items: function(data, callback) {
@ -61,10 +63,12 @@ pandora.ui.mapView = function(videoRatio) {
}, data), callback);
}
});
updateToolbar(data);
} else {
$list.options({items: []});
updateToolbar();
$list.options({
items: function(data, callback) {
callback({data: {items: data.keys ? [] : 0}});
}
});
}
}
}),
@ -91,6 +95,7 @@ pandora.ui.mapView = function(videoRatio) {
.bindEvent({
click: function() {
$map.options({selected: null});
updateStatusbar(0);
}
}),
@ -199,7 +204,19 @@ pandora.ui.mapView = function(videoRatio) {
$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;
return that;

View file

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

View file

@ -1,27 +1,52 @@
// vim: et:ts=4:sw=4:sts=4:ft=javascript
pandora.ui.toolbar = function() {
var that = Ox.Bar({
var ui = pandora.user.ui,
that = Ox.Bar({
size: 24
}).css({
zIndex: 2 // fixme: remove later
});
pandora.user.ui.item && that.append(
ui.item && that.append(
pandora.$ui.backButton = pandora.ui.backButton()
);
that.append(
pandora.$ui.viewSelect = pandora.ui.viewSelect()
);
if (!pandora.user.ui.item || pandora.isClipView()) {
if (!ui.item || pandora.isClipView()) {
that.append(
pandora.$ui.sortSelect = pandora.ui.sortSelect()
);
}
if (!pandora.user.ui.item) {
if (!ui.item) {
that.append(
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(
pandora.$ui.findElement = pandora.ui.findElement()
);

View file

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