Fix various bugs when clicking "Show all comments"

This commit is contained in:
Toks
2014-03-21 16:25:58 -04:00
parent 0add72f2bd
commit 413ac0a491
3 changed files with 18 additions and 13 deletions

View File

@@ -53,8 +53,9 @@
e.preventDefault(); e.preventDefault();
} }
Danbooru.Comment.initialize_reply_links = function() { Danbooru.Comment.initialize_reply_links = function($parent) {
$(".reply-link").click(Danbooru.Comment.quote); $parent = $parent || $(document);
$parent.find(".reply-link").click(Danbooru.Comment.quote);
} }
Danbooru.Comment.initialize_expand_links = function() { Danbooru.Comment.initialize_expand_links = function() {
@@ -79,9 +80,10 @@
$("div.new-comment form").hide(); $("div.new-comment form").hide();
} }
Danbooru.Comment.initialize_edit_links = function() { Danbooru.Comment.initialize_edit_links = function($parent) {
$(".edit_comment").hide(); $parent = $parent || $(document);
$(".edit_comment_link").click(function(e) { $parent.find(".edit_comment").hide();
$parent.find(".edit_comment_link").click(function(e) {
var link_id = $(this).attr("id"); var link_id = $(this).attr("id");
var comment_id = link_id.match(/^edit_comment_link_(\d+)$/)[1]; var comment_id = link_id.match(/^edit_comment_link_(\d+)$/)[1];
$("#edit_comment_" + comment_id).fadeToggle("fast"); $("#edit_comment_" + comment_id).fadeToggle("fast");
@@ -111,8 +113,9 @@
}); });
} }
Danbooru.Comment.initialize_vote_links = function() { Danbooru.Comment.initialize_vote_links = function($parent) {
$(".unvote-comment-link").hide(); $parent = $parent || $(document);
$parent.find(".unvote-comment-link").hide();
} }
})(); })();

View File

@@ -3,7 +3,7 @@
Danbooru.Dtext.initialize_all = function() { Danbooru.Dtext.initialize_all = function() {
Danbooru.Dtext.initialize_links(); Danbooru.Dtext.initialize_links();
Danbooru.Dtext.initialize_expandables($(document)); Danbooru.Dtext.initialize_expandables();
} }
Danbooru.Dtext.initialize_links = function() { Danbooru.Dtext.initialize_links = function() {
@@ -12,6 +12,7 @@
} }
Danbooru.Dtext.initialize_expandables = function($parent) { Danbooru.Dtext.initialize_expandables = function($parent) {
$parent = $parent || $(document);
$parent.find(".expandable-content").hide(); $parent.find(".expandable-content").hide();
$parent.find(".expandable-button").click(function(e) { $parent.find(".expandable-button").click(function(e) {
var button = $(this); var button = $(this);

View File

@@ -1,6 +1,7 @@
$("#hidden-comments-notice-for-<%= @post.id %>").hide(); $("#hidden-comments-notice-for-<%= @post.id %>").hide();
$("div.comments-for-post[data-post-id=<%= @post.id %>] div.list-of-comments").html("<%= j(render(:partial => 'comments/partials/show/comment', :collection => @comments))%>"); var current_comment_section = $("div.comments-for-post[data-post-id=<%= @post.id %>] div.list-of-comments");
current_comment_section.html("<%= j(render(:partial => 'comments/partials/show/comment', :collection => @comments))%>");
<% if params[:include_below_threshold] %> <% if params[:include_below_threshold] %>
$("#threshold-comments-notice-for-<%= @post.id %>").hide(); $("#threshold-comments-notice-for-<%= @post.id %>").hide();
@@ -9,7 +10,7 @@ $("div.comments-for-post[data-post-id=<%= @post.id %>] div.list-of-comments").ht
Danbooru.Comment.hide_threshold_comments(<%= @post.id %>); Danbooru.Comment.hide_threshold_comments(<%= @post.id %>);
<% end %> <% end %>
Danbooru.Comment.initialize_reply_links(); Danbooru.Comment.initialize_reply_links(current_comment_section);
Danbooru.Comment.initialize_edit_links(); Danbooru.Comment.initialize_edit_links(current_comment_section);
Danbooru.Comment.initialize_vote_links(); Danbooru.Comment.initialize_vote_links(current_comment_section);
Danbooru.Dtext.initialize_expandables($(document)); Danbooru.Dtext.initialize_expandables(current_comment_section);