Commit 6db70161 authored by Andreas Valder's avatar Andreas Valder
Browse files

replace <br> with \n in the editor and reverse it for display, closes #258

parent 18fade0e
......@@ -62,6 +62,12 @@ var moderator = {
},
editor: {
fromhtml: function (str) {
return str.replace('<br>', '\n')
},
tohtml: function (str) {
return str.replace('\n', '<br>')
},
init: function() {
var editable = $('.moderator_editor');
for (var i=0; i<editable.length; i++) {
......@@ -75,7 +81,7 @@ var moderator = {
content: function() {
return '<div class="row form-group">'+
'<span class="col-xs-12">'+
'<textarea class="form-control editor_value ctrl_enter_submit" rows="3" data-path="'+$(this.parentElement).data('path')+'">'+this.parentElement.getElementsByClassName('moderator_editor_value')[0].innerHTML+'</textarea>'+
'<textarea class="form-control editor_value ctrl_enter_submit" rows="3" data-path="'+$(this.parentElement).data('path')+'">'+moderator.editor.fromhtml(this.parentElement.getElementsByClassName('moderator_editor_value')[0].innerHTML)+'</textarea>'+
'</span>'+
'<span class="col-xs-12">'+
'<input class="btn btn-default pull-right" type="submit" data-path="'+$(this.parentElement).data('path')+'" data-reload="'+$(this.parentElement).data('reload')+'" value="save" onClick="moderator.editor.editbtnclick(this)">'+
......@@ -100,13 +106,14 @@ var moderator = {
var reload = $($(src)[0]).data('reload');
var value = $('.editor_value',src.parentElement.parentElement).val();
var editable = $('.moderator_editor');
for (var i=0; i<editable.length; i++) {
var e = $(editable[i]);
if (e.data('path') == path) {
$('.moderator_editor_sign',e).click();
$(".moderator_editor_value",e).html(value);
$(".moderator_editor_value",e).html(moderator.editor.tohtml(value));
}
}
moderator.api.set(path,value,reload);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment