From 56b1098c6005d03aa0bcf84d7283db68283d295b Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 3 Nov 2011 17:11:10 +0000 Subject: [PATCH] improving info and info page --- static/js/pandora/info.js | 50 +++++++++++++++++++++++++---------- static/js/pandora/infoView.js | 15 +++++------ static/js/pandora/menu.js | 11 ++++++-- 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/static/js/pandora/info.js b/static/js/pandora/info.js index 21923a3b..03bb58df 100644 --- a/static/js/pandora/info.js +++ b/static/js/pandora/info.js @@ -135,7 +135,11 @@ pandora.ui.listInfo = function() { var list = pandora.user.ui._list, that = $('
').css({padding: '16px', textAlign: 'center'}), - $icon = $('') + $icon = Ox.Element({ + element: '', + tooltip: list.split(':')[0] == pandora.user.username + ? 'Doubleclick to edit icon' : '', + }) .attr({ src: list ? '/list/' + list + '/icon256.jpg?' + Ox.uid() @@ -144,32 +148,50 @@ pandora.ui.listInfo = function() { .css(getIconCSS()) .appendTo(that); + that.append($('
').css({height: '16px'})); + //fixme: allow editing //pandora.api.editList({id: list, description: 'foobbar'}, callback) //pandora.api.editPage({name: 'allItems', body: 'foobar'}, callback) if (list) { pandora.api.findLists({ query: { conditions: [{key: 'id', value: list, operator: '=='}] }, - keys: ['description'] + keys: ['description', 'name', 'user'] }, function(result) { if (result.data.items.length) { + var item = result.data.items[0]; that.append( - $('
') - .css({paddingTop: '16px', fontWeight: 'bold'}) - .html(Ox.encodeHTML(list)) + Ox.Editable({ + editable: item.user == pandora.user.username, + format: function(value) { + return Ox.encodeHTML(item.user + ':' + value) + }, + tooltip: item.user == pandora.user.username + ? 'Doubleclick to edit title' : '', + value: item.name, + width: pandora.user.ui.sidebarSize - 32 + }) + .css({fontWeight: 'bold', textAlign: 'center'}) ).append( - $('
') - .css({paddingTop: '16px', textAlign: 'left'}) - .html( - result.data.items.length - ? result.data.items[0].description - : 'List not found' - ) + $('
').css({height: '8px'}) + ).append( + Ox.Editable({ + editable: item.user == pandora.user.username, + format: function(value) { + return Ox.encodeHTML(value) + }, + placeholder: '
No description', + tooltip: 'Doubleclick to edit description', + type: 'textarea', + value: item.description, + width: pandora.user.ui.sidebarSize - 32 + }) + .css({textAlign: 'left'}) ); } else { that.append( $('
') - .css({paddingTop: '16px',}) + .css({paddingTop: '16px'}) .html('List not found') ); } @@ -187,7 +209,7 @@ pandora.ui.listInfo = function() { return { width: size + 'px', height: size + 'px', - borderRadius: Math.round(size / 4) + 'px' + borderRadius: Math.round(size / 4) + 'px', }; } that.resizeIcon = function() { diff --git a/static/js/pandora/infoView.js b/static/js/pandora/infoView.js index ef6cabf8..d2977546 100644 --- a/static/js/pandora/infoView.js +++ b/static/js/pandora/infoView.js @@ -151,6 +151,7 @@ pandora.ui.infoView = function(data) { }) .css({ display: 'inline-block', + marginBottom: '-3px', fontWeight: 'bold', fontSize: '13px', MozUserSelect: 'text', @@ -177,15 +178,15 @@ pandora.ui.infoView = function(data) { clickLink: pandora.clickLink, editable: isEditable, format: function(value) { - return value - ? formatValue(value.split(', '), 'name') - : formatLight('Unknown Director'); + formatValue(value.split(', '), 'name') }, + placeholder: formatLight('Unknown Director'), tooltip: isEditable ? 'Doubleclick to edit' : '', value: data.director ? data.director.join(', ') : 'Unknown Director' }) .css({ display: 'inline-block', + marginBottom: '-3px', fontWeight: 'bold', fontSize: '13px', MozUserSelect: 'text', @@ -214,10 +215,9 @@ pandora.ui.infoView = function(data) { Ox.Editable({ clickLink: pandora.clickLink, format: function(value) { - return value - ? formatValue(value.split(', '), key) - : formatLight('unknown'); + return formatValue(value.split(', '), key) }, + placeholder: formatLight('unknown'), tooltip: 'Doubleclick to edit', value: key == 'country' ? (data[key] ? data[key].join(', ') : ['']) @@ -452,9 +452,6 @@ pandora.ui.infoView = function(data) { .append(formatKey('Notes', true)) .append( Ox.Editable({ - format: function(value) { - return value || formatLight('No notes'); - }, height: 128, placeholder: formatLight('No notes'), tooltip: 'Doubleclick to edit', diff --git a/static/js/pandora/menu.js b/static/js/pandora/menu.js index 820377a7..5c0d8466 100644 --- a/static/js/pandora/menu.js +++ b/static/js/pandora/menu.js @@ -205,8 +205,15 @@ pandora.ui.mainMenu = function() { set.listSort = pandora.site.user.ui.listSort; } pandora.UI.set(set); - } else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(value) > -1) { - pandora.UI.set({list: value.substr(8)}); + } else if (['personallists', 'favoritelists', 'featuredlists'].indexOf(data.id) > -1) { + pandora.UI.set({ + find: { + conditions: value ? [ + {key: 'list', value: value.substr(8), operator: '=='} + ] : [], + operator: '&' + } + }); } }, click: function(data) {