review/static/comments.js @ b56935dc75b2
flask
Update README.
author |
Steve Losh <steve@stevelosh.com> |
date |
Fri, 11 Jun 2010 21:24:32 -0400 |
parents |
776a8c6e70a0 |
children |
eaa63ba9a24e |
$(function() {
$("div > form").hide();
$("tr:has(form)").hide();
$("span.cancel a").click(function(event) {
$(event.target).closest("div.input").children(".activate").children("a").show();
$(event.target).parents("form").hide();
return false;
});
$("span.cancel-line a").live("click", function(event) {
$(event.target).closest("tr").prev().removeClass("comment-line-selected").addClass("commentable");
$(event.target).closest("tr").remove();
return false;
});
$(".input .activate a").click(function(event) {
$(event.target).hide();
$(event.target).closest("div").children("form").fadeIn("fast");
return false;
});
$("tr.rem.commentable,tr.add.commentable,tr.con.commentable").live("click", function(event) {
$(event.target).closest("tr").addClass("comment-line-selected").removeClass("commentable");
var filename = $(event.target).closest("tr").find(".line-data").children(".filename").first().text();
var linenumber = $(event.target).closest("tr").find(".line-data").children(".linenumber").first().html();
var comment_form = '<tr class="comment-line">\n\
<td>\n\
<form id="comment-line-form" method="post" action="">\n\
<div class="field">\n\
<label for="body">Add a comment on this line:</label>\n\
<textarea cols="60" rows="6" name="new-comment-body"></textarea>\n\
</div>\n\
<div class="buttons">\n\
<input type="submit" class="button" value="Submit" />\n\
<span class="cancel-line"><a href="">Cancel</a></span>\n\
</div>\n\
<input type="hidden" name="filename" value="<<<FILENAME>>>" />\n\
<input type="hidden" name="lines" value="<<<LINENUMBER>>>" />\n\
</form>\n\
</td>\n\
</tr>';
comment_form = comment_form.replace('<<<FILENAME>>>', filename);
comment_form = comment_form.replace('<<<LINENUMBER>>>', linenumber);
$(event.target).closest("tr").after(comment_form);
return false;
});
});