dont display empty metadata fields if not editable

This commit is contained in:
j 2012-01-18 21:42:26 +05:30
parent 2c573eca84
commit 289e47fa5b

View file

@ -162,111 +162,32 @@ pandora.ui.infoView = function(data) {
) )
.appendTo($text); .appendTo($text);
// Director ---------------------------------------------------------------- if(data.description || isEditable) {
/*
if (data.director || isEditable) {
$('<div>') $('<div>')
.css({
marginTop: '2px'
})
.append( .append(
Ox.Editable({ Ox.Editable({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
editable: isEditable, placeholder: formatLight('unknown'),
format: function(value) { editable: isEditable,
return formatValue(value.split(', '), 'name'); tooltip: isEditable ? 'Doubleclick to edit' : '',
}, type: 'textarea',
placeholder: formatLight('Unknown Director'), value: data.description || ''
tooltip: isEditable ? 'Doubleclick to edit' : '', })
value: data.director ? data.director.join(', ') : 'Unknown Director' .bindEvent({
}) submit: function(event) {
.css({ editMetadata('description', event.value);
display: 'inline-block', }
marginBottom: '-3px', })
fontWeight: 'bold',
fontSize: '13px',
MozUserSelect: 'text',
WebkitUserSelect: 'text'
})
.bindEvent({
submit: function(event) {
editMetadata('director', event.value);
}
})
) )
.appendTo($text); .appendTo($text);
} }
*/
// Country, Year, Language, Runtime ----------------------------------------
/*
if (isEditable) {
var $div = $('<div>')
.css(css)
.appendTo($text);
['country', 'year'].forEach(function(key) {
$('<div>')
.css({float: 'left'})
.html(formatKey(key).replace('</span>', '&nbsp;</span>'))
.appendTo($div);
Ox.Editable({
clickLink: pandora.clickLink,
format: function(value) {
return formatValue(value.split(', '), key)
},
placeholder: formatLight('unknown'),
tooltip: 'Doubleclick to edit',
value: key == 'country'
? (data[key] ? data[key].join(', ') : '')
: data[key] || ''
})
.css({float: 'left'})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
}
})
.appendTo($div);
key == 'country' && $('<div>').css({float: 'left'}).html(';&nbsp;').appendTo($div);
});
} else if (data.country || data.year || data.language || data.runtime) {
var html = [];
['country', 'year', 'language', 'runtime'].forEach(function(key) {
if (data[key]) {
html.push(
formatKey(key)
+ (key == 'runtime'
? Math.round(data[key] / 60) + ' min'
: formatValue(data[key], key))
)
}
});
$('<div>').css(css).html(html.join('; ')).appendTo($text);
}
*/
$('<div>')
.append(
Ox.Editable({
clickLink: pandora.clickLink,
placeholder: formatLight('unknown'),
editable: isEditable,
tooltip: isEditable ? 'Doubleclick to edit' : '',
type: 'textarea',
value: data.description || ''
})
.bindEvent({
submit: function(event) {
editMetadata('description', event.value);
}
})
)
.appendTo($text);
var list_keys = ['language', 'topic', 'director', 'cinematographer', 'features', 'groups']; var list_keys = ['language', 'topic', 'director', 'cinematographer', 'features', 'groups'];
$('<div>').html('<br>').appendTo($text); $('<div>').html('<br>').appendTo($text);
[ [
'source', 'source',
'project', 'project',
'year',
'date', 'date',
'location', 'location',
'director', 'director',
@ -276,63 +197,70 @@ pandora.ui.infoView = function(data) {
'topic', 'topic',
'user', 'user',
].forEach(function(key) { ].forEach(function(key) {
var $div = $('<div>') var $div = $('<div>')
.appendTo($text); .appendTo($text),
$('<div>') value = list_keys.indexOf(key) >= 0
.html( ? (data[key] || []).join(', ')
formatKey({ : data[key] || '';
categorty: 'categories', if(isEditable || value) {
}[key] || key).replace('</span>', '&nbsp;</span>')
)
.appendTo($div);
Ox.Editable({
clickLink: pandora.clickLink,
format: function(value) {
return list_keys.indexOf(key) >= 0
? formatValue(value.split(', '), {
'director': 'name',
'cinematographer': 'name',
'features': 'name',
}[key] || key)
: value;
},
placeholder: formatLight('unknown'),
editable: isEditable,
tooltip: isEditable ? 'Doubleclick to edit' : '',
value: list_keys.indexOf(key) >= 0
? (data[key] || []).join(', ')
: data[key] || ''
})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
}
})
.appendTo($div);
if(pandora.site.itemKeys.filter(function(item) {
if (item.id == key)
return item.description
}).length > 0) {
$('<div>') $('<div>')
.append( .html(
descriptions[key] = Ox.Editable({ formatKey({
clickLink: pandora.clickLink, categorty: 'categories',
placeholder: formatLight(Ox.toTitleCase(key) + ' Description'), }[key] || key).replace('</span>', '&nbsp;</span>')
editable: isEditable, )
tooltip: isEditable ? 'Doubleclick to edit' : '',
type: 'textarea',
value: data[key + 'description']|| ''
})
.bindEvent({
submit: function(event) {
editMetadata(key + 'description', event.value);
}
})
).css({
'padding-top': '4px',
'padding-bottom': '4px'
})
.appendTo($div); .appendTo($div);
Ox.Editable({
clickLink: pandora.clickLink,
format: function(value) {
return list_keys.indexOf(key) >= 0
? formatValue(value.split(', '), {
'director': 'name',
'cinematographer': 'name',
'features': 'name',
}[key] || key)
: value;
},
placeholder: formatLight('unknown'),
editable: isEditable,
tooltip: isEditable ? 'Doubleclick to edit' : '',
value: list_keys.indexOf(key) >= 0
? (data[key] || []).join(', ')
: data[key] || ''
})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
}
})
.appendTo($div);
if(pandora.site.itemKeys.filter(function(item) {
if (item.id == key)
return item.description
}).length > 0
&& (isEditable || data[key + 'description'])) {
$('<div>')
.append(
descriptions[key] = Ox.Editable({
clickLink: pandora.clickLink,
placeholder: formatLight(Ox.toTitleCase(key) + ' Description'),
editable: isEditable,
tooltip: isEditable ? 'Doubleclick to edit' : '',
type: 'textarea',
value: data[key + 'description']|| ''
})
.bindEvent({
submit: function(event) {
editMetadata(key + 'description', event.value);
}
})
).css({
'padding-top': '4px',
'padding-bottom': '4px'
})
.appendTo($div);
}
} }
}); });
@ -447,6 +375,14 @@ pandora.ui.infoView = function(data) {
pandora.$ui.browser.value(result.data.id, 'director', result.data.director); pandora.$ui.browser.value(result.data.id, 'director', result.data.director);
pandora.$ui.browser.value(result.data.id, 'country', result.data.country); pandora.$ui.browser.value(result.data.id, 'country', result.data.country);
pandora.$ui.browser.value(result.data.id, 'year', result.data.year); pandora.$ui.browser.value(result.data.id, 'year', result.data.year);
pandora.$ui.itemTitle
.options({
title: '<b>' + result.data.title
+ (Ox.len(result.data.director)
? ' (' + result.data.director.join(', ') + ')'
: '')
+ (result.data.year ? ' ' + result.data.year : '') + '</b>'
});
//pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser()); //pandora.$ui.contentPanel.replaceElement(0, pandora.$ui.browser = pandora.ui.browser());
}); });
} }