From fdffa468cbbd2555e05fb755d2c9aa345dd0bffc Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 28 Feb 2013 13:44:54 +0000 Subject: [PATCH] indiancinema info view: handle studio descriptions --- static/js/pandora/infoView.indiancinema.js | 94 ++++++++++++++-------- 1 file changed, 61 insertions(+), 33 deletions(-) diff --git a/static/js/pandora/infoView.indiancinema.js b/static/js/pandora/infoView.indiancinema.js index 180ed5fd..b174e746 100644 --- a/static/js/pandora/infoView.indiancinema.js +++ b/static/js/pandora/infoView.indiancinema.js @@ -28,7 +28,10 @@ pandora.ui.infoView = function(data) { listKeys = nameKeys.concat([ 'country', 'language', 'productionCompany', 'genre', 'keyword' ]), - names = getNames(), + descriptions = { + names: getNames(), + studios: getStudios() + }, statisticsWidth = 128, uid = Ox.uid(), @@ -457,7 +460,10 @@ pandora.ui.infoView = function(data) { } } if (Ox.contains(nameKeys, key)) { - names = getNames(); + descriptions.names = getNames(); + renderDescriptions(); + } else if (key == 'productionCompany') { + descriptions.studios = getStudios(); renderDescriptions(); } else if (key == 'imdbId') { 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) { var $target = $(e.target); return $target.is('a') || $target.parents('a').length @@ -653,37 +675,43 @@ pandora.ui.infoView = function(data) { function renderDescriptions() { $descriptions.empty(); - names.forEach(function(value) { - if (canEdit || value.description) { - $('
') - .css(css) - .css({marginTop: '12px', fontWeight: 'bold'}) - .html( - formatLink(value.name, 'name') - + ' (' + value.keys.map(function(key) { - return formatKey(key, 'description'); - }).join(', ') + ')' - ) - .appendTo($descriptions); - Ox.EditableContent({ - clickLink: pandora.clickLink, - editable: canEdit, - placeholder: formatLight('No Description'), - tooltip: canEdit ? getTooltip : '', - type: 'textarea', - value: value.description || '' - }) - .css(css) - .bindEvent({ - submit: function(data) { - editMetadata( - 'namedescription', - Ox.extend({}, value.name, data.value) - ); - } - }) - .appendTo($descriptions); - } + ['studios', 'names'].forEach(function(key) { + descriptions[key].forEach(function(value) { + if (canEdit || value.description) { + $('
') + .css(css) + .css({marginTop: '12px', fontWeight: 'bold'}) + .html( + formatLink( + value.name, + key == 'studios' ? 'productionCompany' : 'name' + ) + ' (' + value.keys.map(function(key) { + return formatKey(key, 'description'); + }).join(', ') + ')' + ) + .appendTo($descriptions); + Ox.EditableContent({ + clickLink: pandora.clickLink, + editable: canEdit, + placeholder: formatLight('No Description'), + tooltip: canEdit ? getTooltip : '', + type: 'textarea', + value: value.description || '' + }) + .css(css) + .bindEvent({ + submit: function(data) { + editMetadata( + key == 'studios' + ? 'productionCompanydescription' + : 'namedescription', + Ox.extend({}, value.name, data.value) + ); + } + }) + .appendTo($descriptions); + } + }); }); }