From 7da2b8d94336b65d456798d9314a7c3080bf5365 Mon Sep 17 00:00:00 2001 From: j Date: Wed, 20 Nov 2019 15:24:14 +0100 Subject: [PATCH] alternative titles --- static/js/infoView.erg.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/static/js/infoView.erg.js b/static/js/infoView.erg.js index cdb6391..159e993 100644 --- a/static/js/infoView.erg.js +++ b/static/js/infoView.erg.js @@ -30,7 +30,7 @@ pandora.ui.infoView = function(data, isMixed) { }).map(function(key){ return key.id; }), - specialListKeys = [].concat( + specialListKeys = ['alternativeTitles'].concat( pandora.site.itemKeys.filter(function(key) { return key.type[0] == 'date' }).map(function(key) { @@ -217,6 +217,8 @@ pandora.ui.infoView = function(data, isMixed) { }) .appendTo($info), + $alternativeTitles, + $statistics = $('
') .css({ position: 'absolute', @@ -271,8 +273,11 @@ pandora.ui.infoView = function(data, isMixed) { ) .appendTo($text); + renderGroup(['alternativeTitles']); + // Director, Year and Country, Language -------------------------------- + renderGroup(['director', 'year', 'country', 'language']); // Featuring ---------------------------------------------- @@ -417,6 +422,12 @@ pandora.ui.infoView = function(data, isMixed) { var edit = {id: isMultiple ? ui.listSelection : data.id}; if (key == 'title') { edit[key] = value; + if (key == 'alternativeTitles') { + edit[key] = value ? Ox.decodeHTMLEntities(value).split('; ').map(function(value) { + return [Ox.encodeHTMLEntities(value), []]; + }) : []; + data[key] = edit[key]; + $alternativeTitles.html(formatKey(key)); } else if (listKeys.indexOf(key) >= 0) { edit[key] = value ? value.split(', ') : []; } else if (specialListKeys.indexOf(key) > -1) { @@ -466,6 +477,11 @@ pandora.ui.infoView = function(data, isMixed) { var item = Ox.getObjectById(pandora.site.itemKeys, key); key = Ox._(item ? item.title : key); mode = mode || 'text'; + if (key == 'alternativeTitles') { + key = Ox._('Alternative Title' + ( + data.alternativeTitles && data.alternativeTitles.length == 1 ? '' : 's' + )); + } return mode == 'text' ? '' + Ox.toTitleCase(key) + ': ' : mode == 'description' @@ -625,7 +641,13 @@ pandora.ui.infoView = function(data, isMixed) { if ($element.children().length) { $('').html('; ').appendTo($element); } - $('').html(formatKey(key)).appendTo($element); + if (key == 'alternativeTitles') { + $alternativeTitles = $('') + .html(formatKey(key)) + .appendTo($element); + } else { + $('').html(formatKey(key)).appendTo($element); + } Ox.EditableContent({ clickLink: pandora.clickLink, format: function(value) {