From 42f1e4e50fa11618aa0fbef3814f6baa8ff30e11 Mon Sep 17 00:00:00 2001 From: Tom Price Date: Fri, 5 Dec 2014 00:24:06 +0000 Subject: [PATCH] Improvements to layout of event form notes section Added nl2br support in interactions --- RIGS/static/js/interaction.js | 7 ++++++- RIGS/templates/RIGS/event_form.html | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/RIGS/static/js/interaction.js b/RIGS/static/js/interaction.js index b87c0135..933179da 100644 --- a/RIGS/static/js/interaction.js +++ b/RIGS/static/js/interaction.js @@ -6,6 +6,11 @@ function setupItemTable(items_json) { newitem = -1; } +function nl2br (str, is_xhtml) { + var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
' : '
'; + return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2'); +} + function updatePrices() { // individual rows var sum = 0; @@ -92,7 +97,7 @@ $('body').on('submit', '#item-form', function (e) { // update the table $row = $('#item-' + pk); $row.find('.name').html(fields.name); - $row.find('.description').html(fields.description); + $row.find('.description').html(nl2br(fields.description)); $row.find('.cost').html(parseFloat(fields.cost).toFixed(2)); $row.find('.quantity').html(fields.quantity); diff --git a/RIGS/templates/RIGS/event_form.html b/RIGS/templates/RIGS/event_form.html index 7f532dbb..b2e8ccad 100644 --- a/RIGS/templates/RIGS/event_form.html +++ b/RIGS/templates/RIGS/event_form.html @@ -323,9 +323,11 @@
-
- - {% render_field form.notes class+="form-control" %} +
+
+ + {% render_field form.notes class+="form-control" %} +
{% include "RIGS/item_table.html" %}