From 6b225333cd38d2014694c545ea783d028362c662 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 1 Oct 2011 13:51:18 +0000 Subject: [PATCH] fix mapView bugs --- pandora/0xdb.json | 2 ++ static/js/pandora.js | 14 ++++++++++++-- static/js/pandora/UI.js | 6 +++++- static/js/pandora/URL.js | 17 ++++++++++++++-- static/js/pandora/ui/browser.js | 14 ++++++++++++-- static/js/pandora/ui/clipList.js | 9 +++++++-- static/js/pandora/ui/infoView.js | 16 ++++++++-------- static/js/pandora/ui/item.js | 1 - static/js/pandora/ui/list.js | 1 + static/js/pandora/ui/mapView.js | 33 ++++++++++++++++++++++++-------- static/js/pandora/ui/menu.js | 8 +------- static/js/pandora/ui/toolbar.js | 33 ++++++++++++++++++++++++++++---- static/js/pandora/utils.js | 22 +++++++++++---------- 13 files changed, 129 insertions(+), 47 deletions(-) diff --git a/pandora/0xdb.json b/pandora/0xdb.json index f439cefc..bd5031d4 100644 --- a/pandora/0xdb.json +++ b/pandora/0xdb.json @@ -572,6 +572,8 @@ "listSort": [{"key": "director", "operator": ""}], "listView": "grid", "lists": {}, + "mapFind": "", + "mapSelection": "", "section": "items", "showAnnotations": true, "showControls": true, diff --git a/static/js/pandora.js b/static/js/pandora.js index f822e0a9..d698c680 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -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.listView == 'map') { - pandora.$ui.map.resize(); + 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'); diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index 5de2ca92..1727e576 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -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; diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 7cd784f6..2896ccef 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -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; diff --git a/static/js/pandora/ui/browser.js b/static/js/pandora/ui/browser.js index 936f3349..9a1c4249 100644 --- a/static/js/pandora/ui/browser.js +++ b/static/js/pandora/ui/browser.js @@ -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 { diff --git a/static/js/pandora/ui/clipList.js b/static/js/pandora/ui/clipList.js index ef25f232..759325b8 100644 --- a/static/js/pandora/ui/clipList.js +++ b/static/js/pandora/ui/clipList.js @@ -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'] : [] diff --git a/static/js/pandora/ui/infoView.js b/static/js/pandora/ui/infoView.js index 6d754077..4bf4e5a2 100644 --- a/static/js/pandora/ui/infoView.js +++ b/static/js/pandora/ui/infoView.js @@ -252,7 +252,9 @@ pandora.ui.infoView = function(data) { data.filming_locations && $('
') .css(css) .html( - formatKey('Filming Locations') + data.filming_locations.join('; ') + formatKey('Filming Locations') + data.filming_locations.map(function(location) { + return '' + location + '' + }).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 + ? '' + connection.title + '' + : connection.title; + }).join(', ') ); }); $div.html(html.join('; ')); @@ -352,12 +358,6 @@ pandora.ui.infoView = function(data) { return '' + str + ''; } - function formatConnections(connections) { - return connections.map(function(c) { - return c.item ? '' + c.title + '' : c.title; - }).join(', '); - } - function formatValue(value, key) { return (Ox.isArray(value) ? value : [value]).map(function(value) { return key ? diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index badf33cd..0283d5d9 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -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') { diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 9f3f4ef3..d8514e40 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -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}); } diff --git a/static/js/pandora/ui/mapView.js b/static/js/pandora/ui/mapView.js index 7ae4d81b..6459f96e 100644 --- a/static/js/pandora/ui/mapView.js +++ b/static/js/pandora/ui/mapView.js @@ -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; diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js index 7e801d0a..f181dbc7 100644 --- a/static/js/pandora/ui/menu.js +++ b/static/js/pandora/ui/menu.js @@ -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'} ] } ] }) diff --git a/static/js/pandora/ui/toolbar.js b/static/js/pandora/ui/toolbar.js index 11784250..6124d50d 100644 --- a/static/js/pandora/ui/toolbar.js +++ b/static/js/pandora/ui/toolbar.js @@ -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() ); diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index c8526a3f..fdfaeec3 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -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: { - key: isName ? 'name' : 'id', - value: type == 'annotation' ? item + '/' + str : str, - operator: '=' + conditions: [{ + key: isName ? 'name' : 'id', + value: type == 'annotation' ? item + '/' + str : str, + 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 {