Use 'white-space: pre-line' for multi-line compliment.

This commit is contained in:
ubertao
2018-09-24 23:01:17 +08:00
parent d76c924ad1
commit ba428c6cfe
2 changed files with 7 additions and 8 deletions

View File

@@ -128,6 +128,10 @@ sup {
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.pre-line {
white-space: pre-line;
}
/** /**
* Region Definitions. * Region Definitions.
*/ */

View File

@@ -157,15 +157,10 @@ Module.register("compliments", {
getDom: function() { getDom: function() {
var complimentText = this.randomCompliment(); var complimentText = this.randomCompliment();
var compliment = document.createTextNode(complimentText);
var wrapper = document.createElement("div"); var wrapper = document.createElement("div");
wrapper.className = this.config.classes ? this.config.classes : "thin xlarge bright"; wrapper.className = this.config.classes ? this.config.classes : "thin xlarge bright pre-line";
complimentText.split("\n").forEach(function(line, index) { wrapper.appendChild(compliment);
if (index > 0) {
wrapper.appendChild(document.createElement("br"));
}
wrapper.appendChild(document.createTextNode(line));
});
return wrapper; return wrapper;
}, },