From db42f6b2e3a45b332d3b0127870e23efd199e78a Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 13 Oct 2011 12:04:27 +0000 Subject: [PATCH] fix bugs with sorting clip lists of map and calendar views --- static/js/pandora/ui/Ox.FilesView.js | 4 +- static/js/pandora/ui/browser.js | 3 +- static/js/pandora/ui/clipList.js | 6 ++ static/js/pandora/ui/item.js | 109 +------------------------ static/js/pandora/ui/list.js | 9 +- static/js/pandora/ui/navigationView.js | 17 ++-- static/js/pandora/ui/orderButton.js | 18 ++-- static/js/pandora/ui/toolbar.js | 2 +- 8 files changed, 32 insertions(+), 136 deletions(-) diff --git a/static/js/pandora/ui/Ox.FilesView.js b/static/js/pandora/ui/Ox.FilesView.js index f5dbc01d..92d29480 100644 --- a/static/js/pandora/ui/Ox.FilesView.js +++ b/static/js/pandora/ui/Ox.FilesView.js @@ -352,11 +352,11 @@ Ox.FilesView = function(options, self) { }); function openFiles(data) { - Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances'))) + //Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances'))) } function selectFiles(data) { - Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances'))) + //Ox.print('........', JSON.stringify(self.$filesList.value(data.ids[0], 'instances'))) self.selected = data.ids; self.$instancesList.options({ items: data.ids.length == 1 diff --git a/static/js/pandora/ui/browser.js b/static/js/pandora/ui/browser.js index 5fcbaded..1a108fa0 100644 --- a/static/js/pandora/ui/browser.js +++ b/static/js/pandora/ui/browser.js @@ -80,7 +80,8 @@ pandora.ui.browser = function() { orientation: 'horizontal', selected: [pandora.user.ui.item], size: 64, - sort: pandora.user.ui.listSort, + sort: ['text', 'position'].indexOf(pandora.user.ui.listSort) > -1 + ? pandora.site.user.ui.listSort : pandora.user.ui.listSort, unique: 'id' }) .bindEvent({ diff --git a/static/js/pandora/ui/clipList.js b/static/js/pandora/ui/clipList.js index b2aeaec5..d63a8fcb 100644 --- a/static/js/pandora/ui/clipList.js +++ b/static/js/pandora/ui/clipList.js @@ -177,6 +177,12 @@ pandora.ui.clipList = function(videoRatio) { $('.OxSelectedVideo').removeClass('OxSelectedVideo'); !ui.item && pandora.UI.set('listSelection', []); } + }, + pandora_itemsort: function(data) { + that.options({sort: data.value}); + }, + pandora_listsort: function(data) { + that.options({sort: data.value}); } }); diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index 8cc57362..c3ae2412 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -39,108 +39,6 @@ pandora.ui.item = function() { ) ); - } else if (pandora.user.ui.itemView == 'calendar') { - var video = result.data.stream; - pandora.api.findEvents({ - itemQuery: {conditions: [{key: 'id', value: pandora.user.ui.item, operator:'='}]}, - keys: ['id', 'name', 'start', 'end'], - query: {} - }, function(r) { - if (r.data.items.length>0) { - pandora.$ui.contentPanel.replaceElement(1, Ox.SplitPanel({ - elements: [ - { - element: pandora.$ui.calendar = Ox.Calendar({ - date: new Date(0), - events: r.data.items, - height: window.innerHeight - pandora.user.ui.showGroups * pandora.user.ui.groupsSize - 61, - range: [-5000, 5000], - width: window.innerWidth - pandora.user.ui.showSidebar * pandora.user.ui.sidebarSize - 2 - 144 - Ox.UI.SCROLLBAR_SIZE, - zoom: 4 - }).bindEvent({ - select: function(event) { - pandora.$ui.clips.options({ - items: function(data, callback) { - pandora.api.findClips(Ox.extend(data, { - query: { - conditions:[{ - key: 'event', - value: event.id, - operator:'==' - }] - }, - itemQuery: {conditions: [{ - key: 'id', - value: pandora.user.ui.item, - operator: '==' - }]} - }), callback); - } - }); - - } - }) - }, - { - element: Ox.Element(), - element: pandora.$ui.clips = Ox.IconList({ - fixedRatio: video.aspectRatio, - item: function(data, sort, size) { - size = size || 128; - var width = size, - height = Math.round(size / video.aspectRatio), - itemId = data.id.split('/')[0], - url = '/' + itemId + '/' + height + 'p' + data['in'] + '.jpg'; - return { - height: height, - id: data['id'], - info: Ox.formatDuration(data['in']) + ' - ' - + Ox.formatDuration(data['out']), - title: data.value, - url: url, - width: width - }; - }, - items: [], - keys: ['id', 'value', 'in', 'out'], - size: 128, - sort: pandora.user.ui.itemSort, - unique: 'id' - }).bindEvent({ - open: function(data) { - var id = data.ids[0], - item = pandora.user.ui.item, - points = { - 'in': pandora.$ui.clips.value(id, 'in'), - out: pandora.$ui.clips.value(id, 'out') - }; - pandora.UI.set('videoPoints.' + item, Ox.extend(points, { - position: points['in'] - })); - pandora.UI.set('itemView', 'timeline'); - } - }), - id: 'place', - size: 144 + Ox.UI.SCROLLBAR_SIZE - } - ], - orientation: 'horizontal' - }) - .bindEvent('resize', function(data) { - - })); - } else { - pandora.$ui.contentPanel.replaceElement(1, - Ox.Element() - .css({marginTop: '32px', fontSize: '12px', textAlign: 'center'}) - .html( - 'Sorry, ' + result.data.title - + ' currently doesn\'t have a ' - + pandora.user.ui.itemView + ' view.' - )); - } - }); - } else if (pandora.user.ui.itemView == 'info') { //Ox.print('result.data', result.data) if (pandora.user.level == 'admin' && false) { @@ -201,11 +99,6 @@ pandora.ui.item = function() { } else if (pandora.user.ui.itemView == 'clips') { pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = pandora.ui.clipList(result.data.videoRatio) - .bindEvent({ - pandora_itemsort: function(data) { - pandora.$ui.clips.options({sort: data.value}); - } - }) ); } else if (pandora.user.ui.itemView == 'video') { @@ -388,7 +281,7 @@ pandora.ui.item = function() { pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('map', result.data.videoRatio)); } else if (pandora.user.ui.itemView == 'calendar') { - pandora.$ui.contentPanel.replaceElement(1, Ox.Element().html('Calendar')); + pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('calendar', result.data.videoRatio)); } else if (pandora.user.ui.itemView == 'data') { var stats = Ox.Container(); diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 2328c07f..720d270d 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -390,17 +390,14 @@ pandora.ui.list = function() { }, function(result) { pandora.$ui.selected.html(pandora.ui.status('selected', result.data)); }); + }, + pandora_listsort: function(data) { + that.options({sort: data.value}); } }); } - that.bindEvent({ - // fixme: this is nonsense for map and calendar - pandora_listsort: function(data) { - that.options({sort: data.value}); - } - }); if (pandora.user.ui.listView == 'grid') { that.bindEvent({ pandora_icons: function(data) { diff --git a/static/js/pandora/ui/navigationView.js b/static/js/pandora/ui/navigationView.js index e15dd2a4..86ea5e20 100644 --- a/static/js/pandora/ui/navigationView.js +++ b/static/js/pandora/ui/navigationView.js @@ -186,7 +186,10 @@ pandora.ui.navigationView = function(type, videoRatio) { } else { pandora.api.findEvents({ - itemQuery: ui.find, + itemQuery: !ui.item ? ui.find : { + conditions: [{key: 'id', value: ui.item, operator: '=='}], + operator: '&' + }, keys: ['id', 'name', 'start', 'end'], query: {}, range: [0, 1000000] @@ -277,20 +280,14 @@ pandora.ui.navigationView = function(type, videoRatio) { $itemButton.options({disabled: !item}); } - that.bindEvent({ - pandora_itemsort: function(data) { - ui.item && $list.options({sort: data.value}); - }, - pandora_listsort: function(data) { - !ui.item && $list.options({sort: data.value}); - } - }); - if (type == 'map') { pandora.user.ui.mapFind = ''; pandora.user.ui.mapSelection = ''; } + // needed to it can recieve events from UI module + pandora.$ui.clipList = $list; + return that; }; \ No newline at end of file diff --git a/static/js/pandora/ui/orderButton.js b/static/js/pandora/ui/orderButton.js index ad71b017..a963aab6 100644 --- a/static/js/pandora/ui/orderButton.js +++ b/static/js/pandora/ui/orderButton.js @@ -1,7 +1,8 @@ // vim: et:ts=4:sw=4:sts=4:ft=javascript pandora.ui.orderButton = function() { - var that = Ox.Button({ + var sortKey = !pandora.user.ui.item ? 'listSort' : 'itemSort', + that = Ox.Button({ id: 'orderButton', title: getTitle(), // tooltip: 'Change sort order', @@ -13,20 +14,21 @@ pandora.ui.orderButton = function() { }) .bindEvent({ click: function(data) { - pandora.UI.set({ - listSort: [{ - key: pandora.user.ui.listSort[0].key, - operator: pandora.user.ui.listSort[0].operator == '+' ? '-' : '+' - }] - }); + pandora.UI.set(sortKey, [{ + key: pandora.user.ui[sortKey][0].key, + operator: pandora.user.ui[sortKey][0].operator == '+' ? '-' : '+' + }]); that.options({title: getTitle()}); }, pandora_listsort: function() { that.options({title: getTitle()}); + }, + pandora_itemsort: function() { + that.options({title: getTitle()}); } }); function getTitle() { - return pandora.user.ui.listSort[0].operator == '+' ? 'up' : 'down'; + return pandora.user.ui[sortKey][0].operator == '+' ? 'up' : 'down'; } return that; } \ No newline at end of file diff --git a/static/js/pandora/ui/toolbar.js b/static/js/pandora/ui/toolbar.js index bcf5c435..dee1c657 100644 --- a/static/js/pandora/ui/toolbar.js +++ b/static/js/pandora/ui/toolbar.js @@ -18,7 +18,7 @@ pandora.ui.toolbar = function() { pandora.$ui.sortSelect = pandora.ui.sortSelect() ); } - if (!ui.item) { + if (!ui.item || pandora.isClipView()) { that.append( pandora.$ui.orderButton = pandora.ui.orderButton() );