Commit 0683d55e authored by bbaer's avatar bbaer
Browse files

Edit function added

parent 8a3c6f51
Pipeline #1456 passed with stage
in 1 minute and 57 seconds
......@@ -28,7 +28,8 @@ var QfqNS = QfqNS || {};
this.user = user;
this.$parent = $container;
this.$comment = {};
if (arguments.length == 3) {
this.$text = {};
if (arguments.length === 3) {
this.options = { readonly: false };
} else {
this.options = options;
......@@ -73,14 +74,20 @@ var QfqNS = QfqNS || {};
}).appendTo($topLine);
$topLine.appendTo($commentWrap);
var $comment = $('<div />', {
class: "qfqCommentText",
class: "qfqCommentText"
});
$comment.html(this.comment.comment);
$comment.append(this._getCommands());
this.$text= $comment;
$comment.appendTo($commentWrap);
return $commentWrap;
};
n.Comment.prototype._updateText = function(text) {
this.$text.html(text);
this.$text.append(this._getCommands());
};
n.Comment.prototype._getCommands = function () {
var $commentCommands = $("<div />", {
class: "qfqCommentCommands"
......@@ -115,6 +122,15 @@ var QfqNS = QfqNS || {};
n.Comment.prototype._editMe = function(e) {
console.log("Edit pressed for:");
console.log(this.comment);
this.$comment.hide();
var that = this;
var editor = new QfqNS.Editor();
var $editor = editor.buildEditor(this.comment.comment);
editor.on("editor.submit", function(e) {
that._updateComment(e);
});
this.$comment.after($editor);
};
n.Comment.prototype._replyToMe = function(e) {
......@@ -123,4 +139,12 @@ var QfqNS = QfqNS || {};
console.log(e);
};
n.Comment.prototype._updateComment = function(e) {
console.log(e);
this.comment.comment = e.data.text;
this._updateText(e.data.text);
this.$comment.show();
e.data.$container.destroy();
};
})(QfqNS);
\ No newline at end of file
......@@ -33,7 +33,8 @@ var QfqNS = QfqNS || {};
n.Editor.prototype.on = n.EventEmitter.onMixin;
n.Editor.prototype.buildEditor = function() {
n.Editor.prototype.buildEditor = function(text) {
var that = this;
this.$container = $("<div />", {
class: "qfqEditorContainer"
......@@ -42,6 +43,9 @@ var QfqNS = QfqNS || {};
class: "qfqEditor",
contenteditable: true
});
if (text) {
this.$textArea.html(text);
}
this.$textArea.keydown(function() { that.activateSubmit(); });
this._addEditorControls();
var controls = $("<div />", {
......
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