refactoring (intermediate state)

This commit is contained in:
rolux 2011-09-28 00:10:26 +00:00
parent 000362c05c
commit ce8656ef53
11 changed files with 46 additions and 38 deletions

View file

@ -109,6 +109,7 @@ Ox.load({
pandora.site.listSettings[key] = key[4].toLowerCase() + key.substr(5); pandora.site.listSettings[key] = key[4].toLowerCase() + key.substr(5);
} }
}); });
/*
if (Ox.isEmpty(pandora.user.ui.lists)) { if (Ox.isEmpty(pandora.user.ui.lists)) {
var listSettings = {}; var listSettings = {};
Ox.forEach(pandora.site.listSettings, function(listSetting, setting) { Ox.forEach(pandora.site.listSettings, function(listSetting, setting) {
@ -116,6 +117,7 @@ Ox.load({
}); });
pandora.UI.set('lists.', listSettings); pandora.UI.set('lists.', listSettings);
} }
*/
Ox.extend(pandora.user, { Ox.extend(pandora.user, {
sectionElement: 'buttons', sectionElement: 'buttons',
@ -192,7 +194,7 @@ Ox.load({
//Ox.print('pandora.$ui.window.resize'); //Ox.print('pandora.$ui.window.resize');
pandora.$ui.browser.scrollToSelection(); pandora.$ui.browser.scrollToSelection();
pandora.user.ui.itemView == 'info' && pandora.$ui.item.resize(); 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 // fixme: duplicated
height: pandora.$ui.contentPanel.size(1), height: pandora.$ui.contentPanel.size(1),
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1 width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1

View file

@ -57,16 +57,23 @@ pandora.UI = (function() {
// when switching to an item, update list selection // when switching to an item, update list selection
add['listSelection'] = [val]; add['listSelection'] = [val];
add['lists.' + that.encode(pandora.user.ui._list || '') + '.selection'] = [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' key == 'itemView'
&& ['video', 'timeline'].indexOf(val) > -1 && ['video', 'timeline'].indexOf(val) > -1
&& !pandora.user.ui.videoPoints[pandora.user.ui.item] && !pandora.user.ui.videoPoints[pandora.user.ui.item]
) { )) {
// add default videoPoints // 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) { Ox.forEach(obj, function(val, key) {
var keys = key.replace(/([^\\])\./g, '$1\n').split('\n'), var keys = key.replace(/([^\\])\./g, '$1\n').split('\n'),
ui = pandora.user.ui; ui = pandora.user.ui;
@ -79,11 +86,8 @@ pandora.UI = (function() {
} else { } else {
ui[keys[0]] = val; ui[keys[0]] = val;
} }
// don't save or trigger events for private keys
//if (key[0] != '_') {
//}
set[key] = val; set[key] = val;
if (!isAdd) { if (isArg) {
trigger[key] = val; trigger[key] = val;
} }
} }
@ -99,7 +103,7 @@ pandora.UI = (function() {
}); });
}); });
}); });
Ox.len(trigger) && Ox.URL.push(); Ox.len(trigger) && pandora.URL.push();
}; };
return that; return that;

View file

@ -121,9 +121,9 @@ pandora.URL = (function() {
if (pandora.user.ui.showHome) { if (pandora.user.ui.showHome) {
pandora.$ui.home = pandora.ui.home().showScreen(); pandora.$ui.home = pandora.ui.home().showScreen();
/* /*
Ox.print('LIST', pandora.user.ui.list) Ox.print('LIST', pandora.user.ui._list)
pandora.user.ui.list && pandora.Query.fromString( pandora.user.ui._list && pandora.Query.fromString(
'find=list:' + pandora.user.ui.list 'find=list:' + pandora.user.ui._list
); );
*/ */
} else { } else {

View file

@ -116,7 +116,7 @@ pandora.enableDragAndDrop = function($list, canMove) {
)) { )) {
if (drag.action == 'move') { if (drag.action == 'move') {
pandora.api.removeListItems({ pandora.api.removeListItems({
list: pandora.user.ui.list, list: pandora.user.ui._list,
items: data.ids items: data.ids
}, pandora.reloadList); }, pandora.reloadList);
} }
@ -572,8 +572,6 @@ pandora.selectList = function() {
pandora.$ui.folderList[folder] pandora.$ui.folderList[folder]
.options('selected', [pandora.user.ui._list]) .options('selected', [pandora.user.ui._list])
.gainFocus(); .gainFocus();
} else {
pandora.user.ui.list = '';
} }
}); });
} }

View file

@ -98,7 +98,7 @@ pandora.ui.browser = function() {
}).reloadList(true); }).reloadList(true);
}, },
pandora_showsiteposter: function() { pandora_showsiteposter: function() {
pandora.user.ui.icons == 'poster' && that.reloadList(true); pandora.user.ui.icons == 'posters' && that.reloadList(true);
} }
}); });
pandora.enableDragAndDrop(that, false); pandora.enableDragAndDrop(that, false);

View file

@ -4,7 +4,7 @@ pandora.ui.findElement = function() {
findKey = pandora.user.ui._findState.key, findKey = pandora.user.ui._findState.key,
findValue = pandora.user.ui._findState.value; findValue = pandora.user.ui._findState.value;
var that = Ox.FormElementGroup({ var that = Ox.FormElementGroup({
elements: Ox.merge(pandora.user.ui.list ? [ elements: Ox.merge(pandora.user.ui._list ? [
pandora.$ui.findListSelect = Ox.Select({ pandora.$ui.findListSelect = Ox.Select({
items: [ items: [
{id: 'all', title: 'Find: All ' + pandora.site.itemName.plural}, {id: 'all', title: 'Find: All ' + pandora.site.itemName.plural},
@ -74,7 +74,7 @@ pandora.ui.findElement = function() {
} }
}, },
submit: function(data) { submit: function(data) {
var findInList = pandora.user.ui.list var findInList = pandora.user.ui._list
&& pandora.$ui.findListSelect.value() == 'list', && pandora.$ui.findListSelect.value() == 'list',
key = pandora.$ui.findSelect.value(), key = pandora.$ui.findSelect.value(),
conditions = data.value ? [{ conditions = data.value ? [{
@ -86,7 +86,7 @@ pandora.ui.findElement = function() {
pandora.UI.set('find', { pandora.UI.set('find', {
conditions: Ox.merge([{ conditions: Ox.merge([{
key: 'list', key: 'list',
value: pandora.user.ui.list, value: pandora.user.ui._list,
operator: '==' operator: '=='
}], conditions), }], conditions),
operator: '&' operator: '&'
@ -94,7 +94,7 @@ pandora.ui.findElement = function() {
// fixme: what was this? // fixme: what was this?
// data.value && findIndex == 0 && pandora.user.ui.find.conditions.reverse(); // data.value && findIndex == 0 && pandora.user.ui.find.conditions.reverse();
} else { } else {
if (pandora.user.ui.list) { if (pandora.user.ui._list) {
Ox.forEach(pandora.$ui.folderList, function($list) { Ox.forEach(pandora.$ui.folderList, function($list) {
$list.options({selected: []}); $list.options({selected: []});
}); });
@ -117,7 +117,7 @@ pandora.ui.findElement = function() {
function autocompleteFunction() { function autocompleteFunction() {
return pandora.user.ui.find.conditions.length ? function(value, callback) { return pandora.user.ui.find.conditions.length ? function(value, callback) {
var elementValue = that.value(), 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); findKey = Ox.getObjectById(pandora.site.findKeys, key);
value === '' && Ox.print('Warning: autocomplete function should never be called with empty value'); value === '' && Ox.print('Warning: autocomplete function should never be called with empty value');
if (findKey.autocomplete) { if (findKey.autocomplete) {
@ -125,7 +125,7 @@ pandora.ui.findElement = function() {
key: key, key: key,
query: { query: {
conditions: pandora.$ui.findListSelect.value() == 'list' conditions: pandora.$ui.findListSelect.value() == 'list'
? [{key: 'list', value: pandora.user.ui.list, operator: '=='}] : [], ? [{key: 'list', value: pandora.user.ui._list, operator: '=='}] : [],
operator: '&' operator: '&'
}, },
range: [0, 20], range: [0, 20],

View file

@ -130,7 +130,7 @@ pandora.ui.folderBrowserList = function(id) {
// not-featured list may be in the user's favorites folder // not-featured list may be in the user's favorites folder
keys: id == 'featured' ? ['subscribed'] : [], keys: id == 'featured' ? ['subscribed'] : [],
pageLength: 1000, pageLength: 1000,
selected: pandora.getListData().folder == id ? [pandora.user.ui.list] : [], selected: pandora.getListData().folder == id ? [pandora.user.ui._list] : [],
sort: [ sort: [
{key: 'name', operator: '+'} {key: 'name', operator: '+'}
] ]
@ -181,16 +181,20 @@ pandora.ui.folderBrowserList = function(id) {
}, },
select: function(data) { select: function(data) {
// fixme: duplicated // fixme: duplicated
if (data.ids.length) { var list = data.ids.length ? data.ids[0] : '';
if (list) {
Ox.forEach(pandora.$ui.folderList, function($list, id_) { Ox.forEach(pandora.$ui.folderList, function($list, id_) {
id != id_ && $list.options('selected', []); 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; return that;

View file

@ -16,7 +16,7 @@ pandora.ui.info = function() {
}); });
Ox.print('INFO', view) Ox.print('INFO', view)
if (view == 'list') { 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') { } else if (view == 'poster') {
pandora.api.get({id: id, keys: ['director', 'posterRatio', 'title']}, function(result) { pandora.api.get({id: id, keys: ['director', 'posterRatio', 'title']}, function(result) {
var ratio = result.data.posterRatio, var ratio = result.data.posterRatio,
@ -75,10 +75,10 @@ pandora.ui.info = function() {
pandora.ui.listInfo = function(data) { pandora.ui.listInfo = function(data) {
var that = $('<div>').css({padding: '16px', textAlign: 'center'}); var that = $('<div>').css({padding: '16px', textAlign: 'center'});
var $icon = $('<img>') var $icon = $('<img>')
.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()) .css(getIconCSS())
.appendTo(that); .appendTo(that);
$('<div>').css({padding: '16px 0 16px 0', fontWeight: 'bold'}).html(!pandora.user.ui.list ? 'All Movies' : pandora.user.ui.list.replace(':', ': ')).appendTo(that); $('<div>').css({padding: '16px 0 16px 0', fontWeight: 'bold'}).html(!pandora.user.ui._list ? 'All Movies' : pandora.user.ui._list.replace(':', ': ')).appendTo(that);
$('<div>').css({textAlign: 'left'}).html(Ox.repeat('This is the list info text. ', 10)).appendTo(that); $('<div>').css({textAlign: 'left'}).html(Ox.repeat('This is the list info text. ', 10)).appendTo(that);
function getIconCSS() { function getIconCSS() {
var size = Math.round(pandora.user.ui.sidebarSize / 2); var size = Math.round(pandora.user.ui.sidebarSize / 2);

View file

@ -518,7 +518,7 @@ pandora.ui.infoView = function(data) {
that.bindEvent({ that.bindEvent({
pandora_icons: that.reload, pandora_icons: that.reload,
pandora_showsiteposter: function() { pandora_showsiteposter: function() {
pandora.user.ui.icons == 'poster' && that.reload(); pandora.user.ui.icons == 'posters' && that.reload();
} }
}); });

View file

@ -550,7 +550,7 @@ pandora.ui.list = function() {
}, },
'delete': function(data) { 'delete': function(data) {
pandora.getListData().editable && pandora.api.removeListItems({ pandora.getListData().editable && pandora.api.removeListItems({
list: pandora.user.ui.list, list: pandora.user.ui._list,
items: data.ids items: data.ids
}, pandora.reloadList); }, pandora.reloadList);
}, },
@ -641,7 +641,7 @@ pandora.ui.list = function() {
}, },
paste: function(data) { paste: function(data) {
data.items && pandora.getListData().editable && pandora.api.addListItems({ data.items && pandora.getListData().editable && pandora.api.addListItems({
list: pandora.user.ui.list, list: pandora.user.ui._list,
items: data.items items: data.items
}, pandora.reloadList); }, pandora.reloadList);
}, },
@ -689,7 +689,7 @@ pandora.ui.list = function() {
}).reloadList(true); }).reloadList(true);
}, },
pandora_showsiteposter: function() { pandora_showsiteposter: function() {
pandora.user.ui.icons == 'poster' && that.reloadList(true); pandora.user.ui.icons == 'posters' && that.reloadList(true);
} }
}); });
} }

View file

@ -251,7 +251,7 @@ pandora.ui.mainMenu = function() {
return { return {
id: 'viewlist' + list.id, id: 'viewlist' + list.id,
title: (folder == 'favorite' ? list.user + ': ' : '') + list.name, 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}] }) : [{id: 'loading', title: 'Loading...', disabled: true}]
}] }]