make list info icon doubleclickable

This commit is contained in:
rolux 2011-11-06 12:33:34 +00:00
parent 134f920aba
commit d3f5acbb13

View file

@ -141,11 +141,11 @@ pandora.ui.info = function() {
pandora.ui.listInfo = function() { pandora.ui.listInfo = function() {
var list = pandora.user.ui._list, var list = pandora.user.ui._list,
editable = list.split(':')[0] == pandora.user.username,
that = $('<div>').css({padding: '16px', textAlign: 'center'}), that = $('<div>').css({padding: '16px', textAlign: 'center'}),
$icon = Ox.Element({ $icon = Ox.Element({
element: '<img>', element: '<img>',
tooltip: list.split(':')[0] == pandora.user.username tooltip: editable ? 'Doubleclick to edit icon' : '',
? 'Doubleclick to edit icon' : '',
}) })
.attr({ .attr({
src: list src: list
@ -156,6 +156,12 @@ pandora.ui.listInfo = function() {
.appendTo(that), .appendTo(that),
$title, $description; $title, $description;
editable && $icon.bindEvent({
doubleclick: function() {
pandora.$ui.listDialog = pandora.ui.listDialog('icon').open();
}
});
that.append($('<div>').css({height: '16px'})); that.append($('<div>').css({height: '16px'}));
//fixme: allow editing //fixme: allow editing
@ -167,15 +173,15 @@ pandora.ui.listInfo = function() {
keys: ['description', 'name', 'user'] keys: ['description', 'name', 'user']
}, function(result) { }, function(result) {
if (result.data.items.length) { if (result.data.items.length) {
var item = result.data.items[0]; var item = result.data.items[0],
editable = item.user == pandora.user.username;
that.append( that.append(
$title = Ox.Editable({ $title = Ox.Editable({
editable: item.user == pandora.user.username, editable: editable,
format: function(value) { format: function(value) {
return Ox.encodeHTML(item.user + ': ' + value) return Ox.encodeHTML(item.user + ': ' + value)
}, },
tooltip: item.user == pandora.user.username tooltip: editable ? 'Doubleclick to edit title' : '',
? 'Doubleclick to edit title' : '',
value: item.name, value: item.name,
width: pandora.user.ui.sidebarSize - 32 width: pandora.user.ui.sidebarSize - 32
}) })
@ -209,13 +215,12 @@ pandora.ui.listInfo = function() {
return '<div style="color: rgb(128, 128, 128); text-align: center">' return '<div style="color: rgb(128, 128, 128); text-align: center">'
+ value + '</div>'; + value + '</div>';
}, },
editable: item.user == pandora.user.username, editable: editable,
height: pandora.user.ui.sidebarSize - 32, height: pandora.user.ui.sidebarSize - 32,
placeholder: item.user == pandora.user.username placeholder: editable
? '<div style="color: rgb(128, 128, 128); text-align: center">No description</span>' ? '<div style="color: rgb(128, 128, 128); text-align: center">No description</span>'
: '', : '',
tooltip: item.user == pandora.user.username tooltip: editable ? 'Doubleclick to edit description' : '',
? 'Doubleclick to edit description' : '',
type: 'textarea', type: 'textarea',
value: item.description, value: item.description,
width: pandora.user.ui.sidebarSize - 32 width: pandora.user.ui.sidebarSize - 32