textarea: use white-space: pre-wrap instead of converting nl2br and back, see #48
This commit is contained in:
@ -128,4 +128,8 @@
|
||||
|
||||
.editable-clear-x:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.editable-pre-wrapped {
|
||||
white-space: pre-wrap;
|
||||
}
|
@ -61,6 +61,11 @@ Makes editable any HTML element on the page. Applied as jQuery method.
|
||||
//add 'editable' class to every editable element
|
||||
this.$element.addClass('editable');
|
||||
|
||||
//specifically for "textarea" add class .editable-pre-wrapped to keep linebreaks
|
||||
if(this.input.type === 'textarea') {
|
||||
this.$element.addClass('editable-pre-wrapped');
|
||||
}
|
||||
|
||||
//attach handler activating editable. In disabled mode it just prevent default action (useful for links)
|
||||
if(this.options.toggle !== 'manual') {
|
||||
this.$element.addClass('editable-click');
|
||||
|
@ -38,8 +38,10 @@ $(function(){
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
value2html: function(value, element) {
|
||||
|
||||
//using `white-space: pre-wrap` solves \n <--> BR conversion very elegant!
|
||||
/*
|
||||
value2html: function(value, element) {
|
||||
var html = '', lines;
|
||||
if(value) {
|
||||
lines = value.split("\n");
|
||||
@ -50,7 +52,7 @@ $(function(){
|
||||
}
|
||||
$(element).html(html);
|
||||
},
|
||||
|
||||
|
||||
html2value: function(html) {
|
||||
if(!html) {
|
||||
return '';
|
||||
@ -69,7 +71,7 @@ $(function(){
|
||||
}
|
||||
return lines.join("\n");
|
||||
},
|
||||
|
||||
*/
|
||||
activate: function() {
|
||||
$.fn.editabletypes.text.prototype.activate.call(this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user