From ce8656ef53c5bcae2f6bea68c9f54c46042989d6 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 28 Sep 2011 00:10:26 +0000 Subject: [PATCH] refactoring (intermediate state) --- static/js/pandora.js | 4 +++- static/js/pandora/UI.js | 22 +++++++++++++--------- static/js/pandora/URL.js | 6 +++--- static/js/pandora/pandora.js | 4 +--- static/js/pandora/ui/browser.js | 2 +- static/js/pandora/ui/findElement.js | 12 ++++++------ static/js/pandora/ui/folderBrowserList.js | 18 +++++++++++------- static/js/pandora/ui/info.js | 6 +++--- static/js/pandora/ui/infoView.js | 2 +- static/js/pandora/ui/list.js | 6 +++--- static/js/pandora/ui/menu.js | 2 +- 11 files changed, 46 insertions(+), 38 deletions(-) diff --git a/static/js/pandora.js b/static/js/pandora.js index 53a3ab19..f4ce733d 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -109,6 +109,7 @@ Ox.load({ pandora.site.listSettings[key] = key[4].toLowerCase() + key.substr(5); } }); + /* if (Ox.isEmpty(pandora.user.ui.lists)) { var listSettings = {}; Ox.forEach(pandora.site.listSettings, function(listSetting, setting) { @@ -116,6 +117,7 @@ Ox.load({ }); pandora.UI.set('lists.', listSettings); } + */ Ox.extend(pandora.user, { sectionElement: 'buttons', @@ -192,7 +194,7 @@ Ox.load({ //Ox.print('pandora.$ui.window.resize'); pandora.$ui.browser.scrollToSelection(); pandora.user.ui.itemView == 'info' && pandora.$ui.item.resize(); - pandora.user.ui.itemView == 'player' && pandora.$ui.player.options({ + pandora.user.ui.itemView == 'video' && pandora.$ui.player.options({ // fixme: duplicated height: pandora.$ui.contentPanel.size(1), width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index da88b056..25f86e7c 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -57,16 +57,23 @@ pandora.UI = (function() { // when switching to an item, update list selection add['listSelection'] = [val]; add['lists.' + that.encode(pandora.user.ui._list || '') + '.selection'] = [val]; - } else if ( + } + if (( + key == 'item' + && ['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1 + && !pandora.user.ui.videoPoints[val] + ) || ( key == 'itemView' && ['video', 'timeline'].indexOf(val) > -1 && !pandora.user.ui.videoPoints[pandora.user.ui.item] - ) { + )) { // add default videoPoints - add['videoPoints.' + pandora.user.ui.item] = {'in': 0, out: 0, position: 0}; + add['videoPoints.' + ( + key == 'item' ? val : pandora.user.ui.item + )] = {'in': 0, out: 0, position: 0}; } }); - [args, add].forEach(function(obj, isAdd) { + [add, args].forEach(function(obj, isArg) { Ox.forEach(obj, function(val, key) { var keys = key.replace(/([^\\])\./g, '$1\n').split('\n'), ui = pandora.user.ui; @@ -79,11 +86,8 @@ pandora.UI = (function() { } else { ui[keys[0]] = val; } - // don't save or trigger events for private keys - //if (key[0] != '_') { - //} set[key] = val; - if (!isAdd) { + if (isArg) { trigger[key] = val; } } @@ -99,7 +103,7 @@ pandora.UI = (function() { }); }); }); - Ox.len(trigger) && Ox.URL.push(); + Ox.len(trigger) && pandora.URL.push(); }; return that; diff --git a/static/js/pandora/URL.js b/static/js/pandora/URL.js index 06c3174b..9182e594 100644 --- a/static/js/pandora/URL.js +++ b/static/js/pandora/URL.js @@ -121,9 +121,9 @@ pandora.URL = (function() { if (pandora.user.ui.showHome) { pandora.$ui.home = pandora.ui.home().showScreen(); /* - Ox.print('LIST', pandora.user.ui.list) - pandora.user.ui.list && pandora.Query.fromString( - 'find=list:' + pandora.user.ui.list + Ox.print('LIST', pandora.user.ui._list) + pandora.user.ui._list && pandora.Query.fromString( + 'find=list:' + pandora.user.ui._list ); */ } else { diff --git a/static/js/pandora/pandora.js b/static/js/pandora/pandora.js index 37d2acd3..dc85baa1 100644 --- a/static/js/pandora/pandora.js +++ b/static/js/pandora/pandora.js @@ -116,7 +116,7 @@ pandora.enableDragAndDrop = function($list, canMove) { )) { if (drag.action == 'move') { pandora.api.removeListItems({ - list: pandora.user.ui.list, + list: pandora.user.ui._list, items: data.ids }, pandora.reloadList); } @@ -572,8 +572,6 @@ pandora.selectList = function() { pandora.$ui.folderList[folder] .options('selected', [pandora.user.ui._list]) .gainFocus(); - } else { - pandora.user.ui.list = ''; } }); } diff --git a/static/js/pandora/ui/browser.js b/static/js/pandora/ui/browser.js index a35f756f..d67fcd97 100644 --- a/static/js/pandora/ui/browser.js +++ b/static/js/pandora/ui/browser.js @@ -98,7 +98,7 @@ pandora.ui.browser = function() { }).reloadList(true); }, pandora_showsiteposter: function() { - pandora.user.ui.icons == 'poster' && that.reloadList(true); + pandora.user.ui.icons == 'posters' && that.reloadList(true); } }); pandora.enableDragAndDrop(that, false); diff --git a/static/js/pandora/ui/findElement.js b/static/js/pandora/ui/findElement.js index 209538a0..b995aa9e 100644 --- a/static/js/pandora/ui/findElement.js +++ b/static/js/pandora/ui/findElement.js @@ -4,7 +4,7 @@ pandora.ui.findElement = function() { findKey = pandora.user.ui._findState.key, findValue = pandora.user.ui._findState.value; var that = Ox.FormElementGroup({ - elements: Ox.merge(pandora.user.ui.list ? [ + elements: Ox.merge(pandora.user.ui._list ? [ pandora.$ui.findListSelect = Ox.Select({ items: [ {id: 'all', title: 'Find: All ' + pandora.site.itemName.plural}, @@ -74,7 +74,7 @@ pandora.ui.findElement = function() { } }, submit: function(data) { - var findInList = pandora.user.ui.list + var findInList = pandora.user.ui._list && pandora.$ui.findListSelect.value() == 'list', key = pandora.$ui.findSelect.value(), conditions = data.value ? [{ @@ -86,7 +86,7 @@ pandora.ui.findElement = function() { pandora.UI.set('find', { conditions: Ox.merge([{ key: 'list', - value: pandora.user.ui.list, + value: pandora.user.ui._list, operator: '==' }], conditions), operator: '&' @@ -94,7 +94,7 @@ pandora.ui.findElement = function() { // fixme: what was this? // data.value && findIndex == 0 && pandora.user.ui.find.conditions.reverse(); } else { - if (pandora.user.ui.list) { + if (pandora.user.ui._list) { Ox.forEach(pandora.$ui.folderList, function($list) { $list.options({selected: []}); }); @@ -117,7 +117,7 @@ pandora.ui.findElement = function() { function autocompleteFunction() { return pandora.user.ui.find.conditions.length ? function(value, callback) { var elementValue = that.value(), - key = elementValue[pandora.user.ui.list ? 1 : 0], + key = elementValue[pandora.user.ui._list ? 1 : 0], findKey = Ox.getObjectById(pandora.site.findKeys, key); value === '' && Ox.print('Warning: autocomplete function should never be called with empty value'); if (findKey.autocomplete) { @@ -125,7 +125,7 @@ pandora.ui.findElement = function() { key: key, query: { conditions: pandora.$ui.findListSelect.value() == 'list' - ? [{key: 'list', value: pandora.user.ui.list, operator: '=='}] : [], + ? [{key: 'list', value: pandora.user.ui._list, operator: '=='}] : [], operator: '&' }, range: [0, 20], diff --git a/static/js/pandora/ui/folderBrowserList.js b/static/js/pandora/ui/folderBrowserList.js index fe33f415..334fc2d9 100644 --- a/static/js/pandora/ui/folderBrowserList.js +++ b/static/js/pandora/ui/folderBrowserList.js @@ -130,7 +130,7 @@ pandora.ui.folderBrowserList = function(id) { // not-featured list may be in the user's favorites folder keys: id == 'featured' ? ['subscribed'] : [], pageLength: 1000, - selected: pandora.getListData().folder == id ? [pandora.user.ui.list] : [], + selected: pandora.getListData().folder == id ? [pandora.user.ui._list] : [], sort: [ {key: 'name', operator: '+'} ] @@ -181,16 +181,20 @@ pandora.ui.folderBrowserList = function(id) { }, select: function(data) { // fixme: duplicated - if (data.ids.length) { + var list = data.ids.length ? data.ids[0] : ''; + if (list) { Ox.forEach(pandora.$ui.folderList, function($list, id_) { id != id_ && $list.options('selected', []); }); - //pandora.UI.set({list: data.ids[0]}); - pandora.URL.set('?find=list:' + data.ids[0]); - } else { - //pandora.UI.set({list: ''}); - pandora.URL.set(''); } + pandora.UI.set({ + find: { + conditions: list ? [ + {key: 'list', value: data.ids[0], operator: '=='} + ] : [], + operator: '&' + } + }); } }); return that; diff --git a/static/js/pandora/ui/info.js b/static/js/pandora/ui/info.js index d341b4b8..8289dafb 100644 --- a/static/js/pandora/ui/info.js +++ b/static/js/pandora/ui/info.js @@ -16,7 +16,7 @@ pandora.ui.info = function() { }); Ox.print('INFO', view) if (view == 'list') { - that.empty().append(pandora.$ui.listInfo = pandora.ui.listInfo(pandora.user.ui.list)); + that.empty().append(pandora.$ui.listInfo = pandora.ui.listInfo(pandora.user.ui._list)); } else if (view == 'poster') { pandora.api.get({id: id, keys: ['director', 'posterRatio', 'title']}, function(result) { var ratio = result.data.posterRatio, @@ -75,10 +75,10 @@ pandora.ui.info = function() { pandora.ui.listInfo = function(data) { var that = $('
').css({padding: '16px', textAlign: 'center'}); var $icon = $('') - .attr({src: !pandora.user.ui.list ? '/static/png/icon256.png' : Ox.UI.getImageURL('symbolIcon')}) + .attr({src: !pandora.user.ui._list ? '/static/png/icon256.png' : Ox.UI.getImageURL('symbolIcon')}) .css(getIconCSS()) .appendTo(that); - $('
').css({padding: '16px 0 16px 0', fontWeight: 'bold'}).html(!pandora.user.ui.list ? 'All Movies' : pandora.user.ui.list.replace(':', ': ')).appendTo(that); + $('
').css({padding: '16px 0 16px 0', fontWeight: 'bold'}).html(!pandora.user.ui._list ? 'All Movies' : pandora.user.ui._list.replace(':', ': ')).appendTo(that); $('
').css({textAlign: 'left'}).html(Ox.repeat('This is the list info text. ', 10)).appendTo(that); function getIconCSS() { var size = Math.round(pandora.user.ui.sidebarSize / 2); diff --git a/static/js/pandora/ui/infoView.js b/static/js/pandora/ui/infoView.js index 80f9b8b5..4b935d5c 100644 --- a/static/js/pandora/ui/infoView.js +++ b/static/js/pandora/ui/infoView.js @@ -518,7 +518,7 @@ pandora.ui.infoView = function(data) { that.bindEvent({ pandora_icons: that.reload, pandora_showsiteposter: function() { - pandora.user.ui.icons == 'poster' && that.reload(); + pandora.user.ui.icons == 'posters' && that.reload(); } }); diff --git a/static/js/pandora/ui/list.js b/static/js/pandora/ui/list.js index 0865027d..85d7bcad 100644 --- a/static/js/pandora/ui/list.js +++ b/static/js/pandora/ui/list.js @@ -550,7 +550,7 @@ pandora.ui.list = function() { }, 'delete': function(data) { pandora.getListData().editable && pandora.api.removeListItems({ - list: pandora.user.ui.list, + list: pandora.user.ui._list, items: data.ids }, pandora.reloadList); }, @@ -641,7 +641,7 @@ pandora.ui.list = function() { }, paste: function(data) { data.items && pandora.getListData().editable && pandora.api.addListItems({ - list: pandora.user.ui.list, + list: pandora.user.ui._list, items: data.items }, pandora.reloadList); }, @@ -689,7 +689,7 @@ pandora.ui.list = function() { }).reloadList(true); }, pandora_showsiteposter: function() { - pandora.user.ui.icons == 'poster' && that.reloadList(true); + pandora.user.ui.icons == 'posters' && that.reloadList(true); } }); } diff --git a/static/js/pandora/ui/menu.js b/static/js/pandora/ui/menu.js index 33ce2a89..5b93c924 100644 --- a/static/js/pandora/ui/menu.js +++ b/static/js/pandora/ui/menu.js @@ -251,7 +251,7 @@ pandora.ui.mainMenu = function() { return { id: 'viewlist' + list.id, title: (folder == 'favorite' ? list.user + ': ' : '') + list.name, - checked: list.id == pandora.user.ui.list + checked: list.id == pandora.user.ui._list }; }) : [{id: 'loading', title: 'Loading...', disabled: true}] }]