indiancinema info view: handle studio descriptions

This commit is contained in:
rolux 2013-02-28 13:44:54 +00:00
parent 27f5745d16
commit fdffa468cb

View file

@ -28,7 +28,10 @@ pandora.ui.infoView = function(data) {
listKeys = nameKeys.concat([ listKeys = nameKeys.concat([
'country', 'language', 'productionCompany', 'genre', 'keyword' 'country', 'language', 'productionCompany', 'genre', 'keyword'
]), ]),
names = getNames(), descriptions = {
names: getNames(),
studios: getStudios()
},
statisticsWidth = 128, statisticsWidth = 128,
uid = Ox.uid(), uid = Ox.uid(),
@ -457,7 +460,10 @@ pandora.ui.infoView = function(data) {
} }
} }
if (Ox.contains(nameKeys, key)) { if (Ox.contains(nameKeys, key)) {
names = getNames(); descriptions.names = getNames();
renderDescriptions();
} else if (key == 'productionCompany') {
descriptions.studios = getStudios();
renderDescriptions(); renderDescriptions();
} else if (key == 'imdbId') { } else if (key == 'imdbId') {
updateIMDb(); updateIMDb();
@ -557,6 +563,22 @@ pandora.ui.infoView = function(data) {
); );
} }
function getStudios() {
var studios = [];
if (data.productionCompany) {
data.productionCompany.forEach(function(studio) {
studios.push({
name: studio,
keys: ['productionCompany'],
description: data.productionCompanydescription
? data.productionCompanydescription[studio]
: void 0
});
});
}
return studios;
}
function getTooltip(e) { function getTooltip(e) {
var $target = $(e.target); var $target = $(e.target);
return $target.is('a') || $target.parents('a').length return $target.is('a') || $target.parents('a').length
@ -653,37 +675,43 @@ pandora.ui.infoView = function(data) {
function renderDescriptions() { function renderDescriptions() {
$descriptions.empty(); $descriptions.empty();
names.forEach(function(value) { ['studios', 'names'].forEach(function(key) {
if (canEdit || value.description) { descriptions[key].forEach(function(value) {
$('<div>') if (canEdit || value.description) {
.css(css) $('<div>')
.css({marginTop: '12px', fontWeight: 'bold'}) .css(css)
.html( .css({marginTop: '12px', fontWeight: 'bold'})
formatLink(value.name, 'name') .html(
+ ' (' + value.keys.map(function(key) { formatLink(
return formatKey(key, 'description'); value.name,
}).join(', ') + ')' key == 'studios' ? 'productionCompany' : 'name'
) ) + ' (' + value.keys.map(function(key) {
.appendTo($descriptions); return formatKey(key, 'description');
Ox.EditableContent({ }).join(', ') + ')'
clickLink: pandora.clickLink, )
editable: canEdit, .appendTo($descriptions);
placeholder: formatLight('No Description'), Ox.EditableContent({
tooltip: canEdit ? getTooltip : '', clickLink: pandora.clickLink,
type: 'textarea', editable: canEdit,
value: value.description || '' placeholder: formatLight('No Description'),
}) tooltip: canEdit ? getTooltip : '',
.css(css) type: 'textarea',
.bindEvent({ value: value.description || ''
submit: function(data) { })
editMetadata( .css(css)
'namedescription', .bindEvent({
Ox.extend({}, value.name, data.value) submit: function(data) {
); editMetadata(
} key == 'studios'
}) ? 'productionCompanydescription'
.appendTo($descriptions); : 'namedescription',
} Ox.extend({}, value.name, data.value)
);
}
})
.appendTo($descriptions);
}
});
}); });
} }