From 4da5a6ca84c41259dbab40c694608730a03edafa Mon Sep 17 00:00:00 2001 From: rolux Date: Mon, 26 Sep 2011 19:17:39 +0000 Subject: [PATCH] hook up url controller to ui controller --- pandora/0xdb.json | 1 + static/js/pandora.js | 4 +-- static/js/pandora/UI.js | 26 ++++++++++---- static/js/pandora/URL.js | 8 ++++- static/js/pandora/ui/contentPanel.js | 3 ++ static/js/pandora/ui/home.js | 2 +- static/js/pandora/ui/infoView.js | 9 ++--- static/js/pandora/ui/item.js | 52 +--------------------------- static/js/pandora/ui/list.js | 6 +--- static/js/pandora/ui/menu.js | 11 ++---- static/js/pandora/ui/rightPanel.js | 3 ++ 11 files changed, 44 insertions(+), 81 deletions(-) diff --git a/pandora/0xdb.json b/pandora/0xdb.json index eb794af1..4d2e6d60 100644 --- a/pandora/0xdb.json +++ b/pandora/0xdb.json @@ -549,6 +549,7 @@ "columnWidth": {} } }, + "editIcon": false, "find": {"conditions": [], "operator": "&"}, "groups": [ {"id": "director", "sort": [{"key": "items", "operator": "-"}]}, diff --git a/static/js/pandora.js b/static/js/pandora.js index b0403c2b..acc12867 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -90,7 +90,7 @@ Ox.load({ pandora.site.listSettings = {}; Ox.map(pandora.site.user.ui, function(val, key) { if (/^list[A-Z]/.test(key)) { - pandora.site.listSettings[key] = key[0].toLowerCase() + key.substr(1); + pandora.site.listSettings[key] = key[4].toLowerCase() + key.substr(5); } }); if (Ox.isEmpty(pandora.user.ui.lists)) { @@ -98,7 +98,7 @@ Ox.load({ Ox.forEach(pandora.site.listSettings, function(listSetting, setting) { listSettings[listSetting] = pandora.site.user.ui[setting]; }); - pandora.UI.set('lists|', listSettings); + pandora.UI.set('lists.', listSettings); } Ox.extend(pandora.user, { diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index a43dab86..295428f7 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -20,12 +20,21 @@ pandora.UI = (function() { self.previousUI = Ox.clone(pandora.user.ui, true); Ox.forEach(obj, function(val, key) { var listSettings = pandora.site.listSettings - if (key == 'list' && !pandora.user.ui.lists[val]) { - // add default list settings - obj['lists.' + that.encode(val)] = {}; + if (key == 'list') { + if (!pandora.user.ui.lists[val]) { + obj['lists.' + that.encode(val)] = {}; + } Ox.forEach(listSettings, function(listSetting, setting) { - obj['lists.' + that.encode(val)][listSetting] = pandora.site.user.ui[setting]; + if (!pandora.user.ui.lists[val]) { + // add default list settings and copy to settings + obj['lists.' + that.encode(val)][listSetting] = pandora.site.user.ui[setting]; + obj[setting] = pandora.site.user.ui[setting]; + } else { + // copy list settings to setting + obj[setting] = pandora.user.ui.lists[val][listSetting]; + } }); + Ox.forEach() } else if (Object.keys(listSettings).indexOf(key) > -1) { // add list setting obj['lists.' + that.encode(pandora.user.ui.list) + '.' + listSettings[key]] = val; @@ -52,9 +61,12 @@ pandora.UI = (function() { } else { ui[keys[i]] = val; } - // set[key] = val; - // fixme: remove later - set[key.replace(/\./g, '|')] = val; + if (key[0] != '_') { + // don't send private keys + // set[key] = val; + // fixme: remove later + set[key.replace(/\./g, '|')] = val; + } } }); if (Ox.len(set)) { diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index fa4517de..6be90b30 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -555,6 +555,12 @@ pandora.URL = (function() { views: views }); + ['item', 'itemSort', 'itemView', 'list', 'listSort', 'listView'].forEach(function(event) { + pandora.UI.bind(event, function() { + that.push(); + }); + }); + return that; }; @@ -586,7 +592,7 @@ pandora.URL = (function() { var state = getState(); Ox.print('&&&&&&&', state) self.URL.push(state); - setState(state); + //setState(state); } return that; }; diff --git a/static/js/pandora/ui/contentPanel.js b/static/js/pandora/ui/contentPanel.js index 1ee38775..843ae65b 100644 --- a/static/js/pandora/ui/contentPanel.js +++ b/static/js/pandora/ui/contentPanel.js @@ -32,6 +32,9 @@ pandora.ui.contentPanel = function() { listView: function() { that.replaceElement(1, pandora.$ui.list = pandora.ui.list()); }, + item: function() { + that.replaceElement(1, pandora.$ui.item = pandora.ui.item()); + }, itemView: function() { that.replaceElement(1, pandora.$ui.item = pandora.ui.item()); } diff --git a/static/js/pandora/ui/home.js b/static/js/pandora/ui/home.js index 08b74714..1ea6c576 100644 --- a/static/js/pandora/ui/home.js +++ b/static/js/pandora/ui/home.js @@ -127,7 +127,7 @@ pandora.ui.home = function() { }) .bindEvent({ click: function() { - pandora.URL.push(); + //pandora.URL.push(); that.fadeOutScreen(); } }) diff --git a/static/js/pandora/ui/infoView.js b/static/js/pandora/ui/infoView.js index d539aa9b..8f4915cf 100644 --- a/static/js/pandora/ui/infoView.js +++ b/static/js/pandora/ui/infoView.js @@ -18,14 +18,13 @@ pandora.ui.infoView = function(data) { iconHeight = iconRatio < 1 ? iconSize : Math.round(iconSize / iconRatio), iconLeft = iconSize == 256 ? Math.floor((iconSize - iconWidth) / 2) : 0, borderRadius = pandora.user.ui.icons == 'posters' ? 0 : iconSize / 8, - edit = false, that = Ox.Element(), uid = Ox.uid(), $list, $info = $('
') .css({ position: 'absolute', - left: pandora.user.level == 'admin' ? -listWidth + 'px' : 0, + left: pandora.user.level == 'admin' && !pandora.user.ui.editPoster ? -listWidth + 'px' : 0, top: 0, right: 0, }) @@ -328,16 +327,15 @@ pandora.ui.infoView = function(data) { $icon.bindEvent({ doubleclick: function() { - if (!edit) { + pandora.UI.set('editPoster', !pandora.user.ui.editPoster); + if (pandora.user.ui.editPoster) { $info.animate({ left: 0 }, 250); - edit = true; } else { $info.animate({ left: -listWidth + 'px' }, 250); - edit = false; } } }); @@ -367,7 +365,6 @@ pandora.ui.infoView = function(data) { id: data.id, keys: [pandora.user.ui.icons == 'posters' ? 'posters' : 'frames'] }, 0, function(result) { - Ox.print('RESULT', result.data) var images = result.data[pandora.user.ui.icons == 'posters' ? 'posters' : 'frames'], selectedImage = images.filter(function(image) { return image.selected; diff --git a/static/js/pandora/ui/item.js b/static/js/pandora/ui/item.js index 648240b7..7ef321cc 100644 --- a/static/js/pandora/ui/item.js +++ b/static/js/pandora/ui/item.js @@ -80,54 +80,6 @@ pandora.ui.item = function() { } }); - } else if (pandora.user.ui.itemView == 'clips') { - var ratio = result.data.stream.aspectRatio; - pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = Ox.IconList({ - fixedRatio: ratio, - item: function(data, sort, size) { - size = size || 128; - var width = ratio > 1 ? size : Math.round(size * ratio), - height = ratio > 1 ? Math.round(size / ratio) : size, - url = '/' + pandora.user.ui.item + '/' + height + 'p' + data['in'] + '.jpg'; - return { - height: height, - id: data['id'], - info: Ox.formatDuration(data['in'], 'short') + ' - ' + Ox.formatDuration(data['out'], 'short'), - title: data.value, - url: url, - width: width - }; - }, - items: function(data, callback) { - pandora.api.findAnnotations(Ox.extend(data, { - itemQuery: { - conditions:[{ - key: 'id', - value: pandora.user.ui.item, - operator: '=' - }] - } - }), callback); - }, - keys: ['id', 'value', 'in', 'out'], - size: 128, - sort: pandora.user.ui.lists[pandora.user.ui.list].sort, - 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.URL.set(item + '/timeline'); - } - })); - } else if (pandora.user.ui.itemView == 'info') { //Ox.print('result.data', result.data) if (pandora.user.level == 'admin' && false) { @@ -196,7 +148,6 @@ pandora.ui.item = function() { } else if (pandora.user.ui.itemView == 'clips') { var ratio = result.data.videoRatio; - Ox.print('RATIO', ratio) pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.clips = Ox.IconList({ fixedRatio: ratio, item: function(data, sort, size) { @@ -214,7 +165,6 @@ pandora.ui.item = function() { }; }, items: function(data, callback) { - Ox.print('DATA', data) pandora.api.findAnnotations(Ox.extend(data, { itemQuery: { conditions:[{ @@ -241,7 +191,7 @@ pandora.ui.item = function() { })); pandora.UI.set({ itemView: pandora.user.ui.videoView - }) + }); }, // fixme: duplicated openpreview: function(data) { diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index bbc944be..9f71f64d 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -507,7 +507,7 @@ pandora.ui.list = function() { }); pandora.api.findEvents({ - itemQuery: pandora.user.ui.query, + itemQuery: pandora.user.ui.find, keys: ['id', 'name', 'start', 'end'], query: {} }, function(result) { @@ -675,10 +675,6 @@ pandora.ui.list = function() { } - that.display = function() { // fixme: used? - pandora.$ui.rightPanel.replaceElement(1, pandora.$ui.contentPanel = pandora.ui.contentPanel()); - }; - pandora.UI.bind({ listSort: function(value) { that.options({sort: value}); diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js index 32a9cb8f..e280187e 100644 --- a/static/js/pandora/ui/menu.js +++ b/static/js/pandora/ui/menu.js @@ -70,7 +70,7 @@ pandora.ui.mainMenu = function() { ]}, {}, { id: 'openmovie', title: ['Open ' + pandora.site.itemName.singular, 'Open ' + pandora.site.itemName.plural], items: [ - { group: 'movieview', min: 1, max: 1, items: pandora.site.itemViews.map(function(view) { + { group: 'itemview', min: 1, max: 1, items: pandora.site.itemViews.map(function(view) { return Ox.extend({ checked: ui.itemView == view.id, }, view); @@ -151,13 +151,8 @@ pandora.ui.mainMenu = function() { var value = data.checked[0] ? data.checked[0].id : null; if (data.id == 'find') { pandora.$ui.findSelect.options({value: value}); - } else if (data.id == 'movieview') { - var id = document.location.pathname.split('/')[1]; - // fixme: what's this? - if (value == 'info') - url(id + '/info'); - else - url(id); + } else if (data.id == 'itemview') { + pandora.UI.set({itemView: value}); } else if (Ox.startsWith(data.id, 'ordergroup')) { var groups = Ox.clone(pandora.user.ui.groups), id = data.id.replace('ordergroup', ''), diff --git a/static/js/pandora/ui/rightPanel.js b/static/js/pandora/ui/rightPanel.js index e0e67b92..6a940b51 100644 --- a/static/js/pandora/ui/rightPanel.js +++ b/static/js/pandora/ui/rightPanel.js @@ -58,6 +58,9 @@ pandora.ui.rightPanel = function() { }); } pandora.UI.bind({ + list: function() { + that.replaceElement(1, pandora.$ui.contentPanel = pandora.ui.contentPanel()); + }, itemView: function(value) { if (pandora.isClipView() != pandora.isClipView(pandora.UI.getPrevious('itemView'))) { that.replaceElement(0, pandora.$ui.toolbar = pandora.ui.toolbar());