From 29435355cb821131bfafc6057804b5243d0f5892 Mon Sep 17 00:00:00 2001 From: Rolux Date: Fri, 8 Jan 2016 15:41:24 +0530 Subject: [PATCH] more info/edit view formatting fixes --- static/js/editDialog.js | 15 ++++++++++++--- static/js/infoView.js | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/static/js/editDialog.js b/static/js/editDialog.js index 3796bea..e9310a5 100644 --- a/static/js/editDialog.js +++ b/static/js/editDialog.js @@ -160,7 +160,7 @@ oml.ui.editDialog = function() { Ox.EditableContent({ editable: true, format: function(value) { - return formatValue(value.split(separator), 'author'); + return formatValue(splitValue(value), 'author'); }, placeholder: formatLight(Ox._('Unknown Author')), tooltip: tooltip, @@ -197,7 +197,7 @@ oml.ui.editDialog = function() { editable: true, format: function(value) { return formatValue( - key == 'place' ? value.split(separator) : value, + key == 'place' ? splitValue(value) : value, key ); }, @@ -234,7 +234,7 @@ oml.ui.editDialog = function() { editable: true, format: function(value) { return formatValue( - key == 'language' ? value.split(separator) : value, + key == 'language' ? splitValue(value) : value, key ); }, @@ -262,6 +262,9 @@ oml.ui.editDialog = function() { }).append( Ox.EditableContent({ editable: true, + format: function(value) { + return value.replace(/\n/g, '
'); + }, placeholder: formatLight('No Description'), tooltip: tooltip, type: 'textarea', @@ -283,6 +286,12 @@ oml.ui.editDialog = function() { } + function splitValue(value) { + return Ox.encodeHTMLEntities( + Ox.decodeHTMLEntities(value).split(separator) + ); + } + return that; }; diff --git a/static/js/infoView.js b/static/js/infoView.js index a2c2498..8e8d1d6 100644 --- a/static/js/infoView.js +++ b/static/js/infoView.js @@ -318,6 +318,10 @@ oml.ui.infoView = function(identifyData) { return $element; } + function splitValue(value) { + return Ox.encodeHTMLEntities(Ox.decodeHTMLEntities(value).split('; ')); + } + function toggleCoverSize(ratio) { var css; iconSize = iconSize == 256 ? 512 : 256, @@ -485,7 +489,7 @@ oml.ui.infoView = function(identifyData) { clickLink: oml.clickLink, editable: isEditable, format: function(value) { - return formatValue(value.split('; '), 'author'); + return formatValue(splitValue(value), 'author'); }, placeholder: formatLight(Ox._('Unknown Author')), tooltip: isEditable ? oml.getEditTooltip() : '', @@ -524,7 +528,7 @@ oml.ui.infoView = function(identifyData) { format: function(value) { return formatValue( Ox.contains(arrayKeys, key) - ? value.split('; ') : value, + ? splitValue(value) : value, key ); }, @@ -561,11 +565,9 @@ oml.ui.infoView = function(identifyData) { clickLink: oml.clickLink, editable: isEditable, format: function(value) { - return formatValue( - Ox.contains(arrayKeys, key) - ? value.split('; ') : value, - key - ); + return key == 'language' + ? formatValue(splitValue(value), key) + : value; }, placeholder: formatLight('unknown'), tooltip: isEditable ? oml.getEditTooltip() : '', @@ -631,6 +633,9 @@ oml.ui.infoView = function(identifyData) { Ox.EditableContent({ clickLink: oml.clickLink, editable: isEditable, + format: function(value) { + return value.replace(/\n/g, '
'); + }, placeholder: formatLight('No Description'), tooltip: isEditable ? oml.getEditTooltip() : '', type: 'textarea',