Sha256: 4db310458aa73069488db96f76633aed5052064c8b09ab17068316b955966352

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

(function() {
  var rootCommentableId = <%== "comments-for-#{@comment.root_commentable.commentable_type.demodulize}-#{@comment.root_commentable.id}".to_json %>;
  var commentHtml = '<%== j(render @comment).strip %>';
  var inReplyTo = <%== (reply?(@comment) ? @commentable.id : nil).to_json %>;

  var $comments = $("#" + rootCommentableId);
  var component = $comments.data("comments");
  if (inReplyTo) {
    component.addReply(inReplyTo, commentHtml, true);

    var hideButton = $("#comment_" + <%= root_comment.id %>).find("[data-comment-hide]").first();
    hideButton.find("[data-show-comment-reply]").first().html('<%= t("decidim.components.comment.show_replies", count: Decidim::Comments::SortedComments.for(root_comment.reload).size) %>');

  } else {
    component.addThread(commentHtml, true);
  }

  Rails.fire(document, "comments:loaded", {
    commentsIds: [<%= @comment.id %>, <%= @comment.commentable.id %>]
  });

  // Update the comments count
  $(".comments-count", $comments).text(<%== t("decidim.components.comments.title", count: @comments_count).to_json %>);
}());

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-comments-0.29.1 app/views/decidim/comments/comments/create.js.erb
decidim-comments-0.29.0 app/views/decidim/comments/comments/create.js.erb
decidim-comments-0.29.0.rc4 app/views/decidim/comments/comments/create.js.erb
decidim-comments-0.29.0.rc3 app/views/decidim/comments/comments/create.js.erb
decidim-comments-0.29.0.rc2 app/views/decidim/comments/comments/create.js.erb
decidim-comments-0.29.0.rc1 app/views/decidim/comments/comments/create.js.erb