fixes #1424 for comments

This commit is contained in:
Toks
2013-06-14 12:23:10 -04:00
parent 5fa931f148
commit 739da4c4b9
3 changed files with 20 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
this.initialize_response_link();
this.initialize_reply_links();
this.initialize_expand_links();
this.initialize_edit_links();
}
if ($("#c-posts").length && $("#a-show").length) {
@@ -63,6 +64,16 @@
$("div.new-comment form").hide();
}
Danbooru.Comment.initialize_edit_links = function() {
$(".edit_comment").hide();
$(".edit_comment_link").click(function(e) {
var link_id = $(this).attr("id");
var comment_id = link_id.match(/^edit_comment_link_(\d+)$/)[1];
$("#edit_comment_" + comment_id).toggle();
e.preventDefault();
});
}
Danbooru.Comment.highlight_threshold_comments = function(post_id) {
var threshold = parseInt(Danbooru.meta("user-comment-threshold"));
var articles = $("article.comment[data-post-id=" + post_id + "]");

View File

@@ -0,0 +1,5 @@
<%= simple_form_for(comment) do |f| %>
<%= dtext_field "comment", "body", :value => comment.body, :input_id => "comment_body_for_#{comment.id}", :preview_id => "dtext-preview-for-#{comment.id}" %>
<%= f.button :submit, "Submit" %>
<%= dtext_preview_button "comment", "body", :input_id => "comment_body_for_#{comment.id}", :preview_id => "dtext-preview-for-#{comment.id}" %>
<% end %>

View File

@@ -20,12 +20,15 @@
<li><%= link_to "Reply", new_comment_path(:post_id => comment.post_id), :class => "reply-link", "data-comment-id" => comment.id %></li>
<% if comment.editable_by?(CurrentUser.user) %>
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Are you sure you want to delete this comment?", :method => :delete, :remote => true %></li>
<li><%= link_to "Edit", edit_comment_path(comment.id) %></li>
<li><%= link_to "Edit", edit_comment_path(comment.id), :id => "edit_comment_link_#{comment.id}", :class => "edit_comment_link" %></li>
<% end %>
<li id="comment-vote-up-link-for-<%= comment.id %>"><%= link_to "Vote up", comment_votes_path(:comment_id => comment.id, :score => "up"), :method => :post, :remote => true %></li>
<li id="comment-vote-down-link-for-<%= comment.id %>"><%= link_to "Vote down", comment_votes_path(:comment_id => comment.id, :score => "down"), :method => :post, :remote => true %></li>
<% end %>
</menu>
<% if comment.editable_by?(CurrentUser.user) %>
<%= render "comments/edit", :comment => comment %>
<% end %>
<% end %>
</div>
<div class="clearfix"></div>