summaryrefslogtreecommitdiffstats
path: root/public/javascripts/diff_browser.js
diff options
context:
space:
mode:
authorJohan Sørensen <johan@johansorensen.com>2009-11-03 16:40:01 +0100
committerJohan Sørensen <johan@johansorensen.com>2009-11-04 15:23:49 +0100
commit070f38dd8cf4b80ea1b869e42ea330d9e6e7c656 (patch)
tree8936e0b26a175171088b26693c38db624f1b2057 /public/javascripts/diff_browser.js
parent96668162586e518253b93a2d6dbb6914e3a2868b (diff)
downloadgitorious-mainline-outdated-070f38dd8cf4b80ea1b869e42ea330d9e6e7c656.zip
gitorious-mainline-outdated-070f38dd8cf4b80ea1b869e42ea330d9e6e7c656.tar.gz
gitorious-mainline-outdated-070f38dd8cf4b80ea1b869e42ea330d9e6e7c656.tar.bz2
When click 'reply' in an inline diff comment, insert the original quoted msg
Diffstat (limited to 'public/javascripts/diff_browser.js')
-rw-r--r--public/javascripts/diff_browser.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/public/javascripts/diff_browser.js b/public/javascripts/diff_browser.js
index fd7a310..cb89b80 100644
--- a/public/javascripts/diff_browser.js
+++ b/public/javascripts/diff_browser.js
@@ -569,6 +569,7 @@ Gitorious.enableCommenting = function() {
// Comment highlighting of associated lines
$("table tr td.code .diff-comment").each(function() {
var lines = $(this).attr("gts:lines").split(",");
+ var commentBody = $(this).find(".body").text();
var replyCallback = function() {
Gitorious.CommentForm.destroyAll();
var lines = $(this).parents("div.diff-comment").attr("gts:lines").split(",")
@@ -576,6 +577,7 @@ Gitorious.enableCommenting = function() {
).children(".title").text();
var commentForm = new Gitorious.CommentForm(path);
commentForm.setLineNumbers(lines);
+ commentForm.setInitialCommentBody(commentBody);
if (commentForm.hasLines())
commentForm.display({
inside: $(this).parents("table").prev(".comment_container"),
@@ -600,6 +602,7 @@ NotificationCenter.addObserver("DiffBrowserWillReloadDiffs",
Gitorious.CommentForm = function(path){
this.path = path;
this.numbers = [];
+ this.initialCommentBody = null;
this.setLineNumbers = function(n) {
var result = [];
@@ -608,7 +611,15 @@ Gitorious.CommentForm = function(path){
result.push(number);
});
this.numbers = result;
- }
+ };
+
+ this.setInitialCommentBody = function(body) {
+ var text = $.trim(body);
+ this.initialCommentBody = $.map(text.split("\n"), function(str) {
+ return "> " + str;
+ }).join("\n") + "\n\n";
+ return this.initialCommentBody;
+ };
// returns the lines as our internal representation
// The fomat is
@@ -645,6 +656,8 @@ Gitorious.CommentForm = function(path){
commentContainer.find(".cancel_button").click(Gitorious.CommentForm.destroyAll);
commentContainer.find("#comment_lines").val(this.linesAsInternalFormat());
this._positionAndShowContainer(commentContainer, options.trigger);
+ if (this.initialCommentBody && commentContainer.find("#comment_body").val() == "")
+ commentContainer.find("#comment_body").val(this.initialCommentBody);
commentContainer.find("#comment_body").focus();
var zeForm = commentContainer.find("form");
zeForm.submit(function(){