Cards: Text filtering

This commit is contained in:
2015-06-17 07:49:57 +02:00
parent 71d81d2df9
commit c12549ac6b

View File

@@ -6,6 +6,7 @@
this.X = x; this.X = x;
this.Y = y; this.Y = y;
// Create DOM // Create DOM
this.container = null; this.container = null;
this.divCard = document.createElement("div"); this.divCard = document.createElement("div");
@@ -16,12 +17,12 @@
this.divTitle = document.createElement("div"); this.divTitle = document.createElement("div");
this.divCard.appendChild(this.divTitle); this.divCard.appendChild(this.divTitle);
this.divTitle.className = "divTitle"; this.divTitle.className = "divTitle";
this.divTitle.innerHTML = title; this.divTitle.innerHTML = this.FilterText(title);
this.divBody = document.createElement("div"); this.divBody = document.createElement("div");
this.divCard.appendChild(this.divBody); this.divCard.appendChild(this.divBody);
this.divBody.className = "divBody"; this.divBody.className = "divBody";
this.divBody.innerHTML = body; this.divBody.innerHTML = this.FilterText(body);
this.divOverlay = document.createElement("div"); this.divOverlay = document.createElement("div");
this.divCard.appendChild(this.divOverlay); this.divCard.appendChild(this.divOverlay);
@@ -78,6 +79,11 @@
this.Editing = false; this.Editing = false;
}; };
Card.prototype = { Card.prototype = {
FilterText: function (text) {
text = text.split(" ").join(" ");
text = text.split("\n").join("<br />");
return text;
},
InsertInContainer: function (container) { InsertInContainer: function (container) {
this.container = container; this.container = container;
this.container.appendChild(this.divCard); this.container.appendChild(this.divCard);
@@ -101,8 +107,8 @@ Card.prototype = {
this.Body = body; this.Body = body;
this.newTitle = title; this.newTitle = title;
this.newBody = body; this.newBody = body;
this.divTitle.innerHTML = this.Title; this.divTitle.innerHTML = this.FilterText(this.Title);
this.divBody.innerHTML = this.Body; this.divBody.innerHTML = this.FilterText(this.Body);
}, },
Reset: function () { Reset: function () {
this.newX = this.X; this.newX = this.X;
@@ -111,8 +117,8 @@ Card.prototype = {
this.newBody = this.Body; this.newBody = this.Body;
this.divCard.style.left = this.X + "px"; this.divCard.style.left = this.X + "px";
this.divCard.style.top = this.Y + "px"; this.divCard.style.top = this.Y + "px";
this.divTitle.innerHTML = this.Title; this.divTitle.innerHTML = this.FilterText(this.Title);
this.divBody.innerHTML = this.Body; this.divBody.innerHTML = this.FilterText(this.Body);
}, },
SetNew: function () { SetNew: function () {
this.X = this.newX; this.X = this.newX;
@@ -121,8 +127,8 @@ Card.prototype = {
this.Body = this.newBody; this.Body = this.newBody;
this.divCard.style.left = this.X + "px"; this.divCard.style.left = this.X + "px";
this.divCard.style.top = this.Y + "px"; this.divCard.style.top = this.Y + "px";
this.divTitle.innerHTML = this.Title; this.divTitle.innerHTML = this.FilterText(this.Title);
this.divBody.innerHTML = this.Body; this.divBody.innerHTML = this.FilterText(this.Body);
}, },
OnMove: function () { OnMove: function () {
if (this.X != this.newX || this.Y != this.newY) { if (this.X != this.newX || this.Y != this.newY) {
@@ -292,8 +298,8 @@ Card.prototype = {
this.newTitle = this.txtTitle.value; this.newTitle = this.txtTitle.value;
this.newBody = this.txtBody.value; this.newBody = this.txtBody.value;
this.ExitEditionMode(); this.ExitEditionMode();
this.divTitle.innerHTML = this.newTitle; this.divTitle.innerHTML = this.FilterText(this.newTitle);
this.divBody.innerHTML = this.newBody; this.divBody.innerHTML = this.FilterText(this.newBody);
this.OnEdit(); this.OnEdit();
return false; return false;
}, },