diff --git a/Gemfile b/Gemfile
index 2c2c3e208..f3661c06c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -25,7 +25,7 @@ gem "globalize-accessors", "~> 0.2.1"
gem "graphiql-rails", "~> 1.4.1"
gem "graphql", "~> 1.7.8"
gem "groupdate", "~> 3.2.0"
-gem "initialjs-rails", "~> 0.2.0.5"
+gem "initialjs-rails", "~> 0.2.0.8"
gem "invisible_captcha", "~> 0.10.0"
gem "jquery-fileupload-rails"
gem "jquery-rails", "~> 4.3.3"
diff --git a/Gemfile.lock b/Gemfile.lock
index 1d64d39ba..4494283b4 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -282,7 +282,7 @@ GEM
rainbow (>= 2.2.2, < 4.0)
terminal-table (>= 1.5.1)
ice_nine (0.11.2)
- initialjs-rails (0.2.0.5)
+ initialjs-rails (0.2.0.8)
railties (>= 3.1, < 6.0)
invisible_captcha (0.10.0)
rails (>= 3.2.0)
@@ -642,7 +642,7 @@ DEPENDENCIES
graphql (~> 1.7.8)
groupdate (~> 3.2.0)
i18n-tasks (~> 0.9.29)
- initialjs-rails (~> 0.2.0.5)
+ initialjs-rails (~> 0.2.0.8)
invisible_captcha (~> 0.10.0)
jquery-fileupload-rails
jquery-rails (~> 4.3.3)
diff --git a/app/assets/javascripts/comments.js b/app/assets/javascripts/comments.js
index e8127b705..05229bce5 100644
--- a/app/assets/javascripts/comments.js
+++ b/app/assets/javascripts/comments.js
@@ -1,15 +1,8 @@
(function() {
"use strict";
App.Comments = {
- add_comment: function(parent_id, response_html) {
- $(response_html).insertAfter($("#js-comment-form-" + parent_id));
- this.update_comments_count();
- },
- add_reply: function(parent_id, response_html) {
- if ($("#" + parent_id + " .comment-children").length === 0) {
- $("#" + parent_id).append("
");
- }
- $("#" + parent_id + " .comment-children:first").prepend($(response_html));
+ add_comment: function(parent_selector, response_html) {
+ $(parent_selector + " .comment-list:first").prepend($(response_html));
this.update_comments_count();
},
update_comments_count: function() {
@@ -24,24 +17,19 @@
display_error: function(field_with_errors, error_html) {
$(error_html).insertAfter($("" + field_with_errors));
},
- reset_and_hide_form: function(id) {
- var form_container, input;
- form_container = $("#js-comment-form-" + id);
- input = form_container.find("form textarea");
- input.val("");
- form_container.hide();
- },
- reset_form: function(id) {
- var input;
- input = $("#js-comment-form-" + id + " form textarea");
- input.val("");
+ reset_form: function(parent_selector) {
+ var form_container;
+
+ form_container = $(parent_selector + " .comment-form:first");
+ form_container.find("textarea").val("");
+
+ if (parent_selector !== "") {
+ form_container.hide();
+ }
},
toggle_form: function(id) {
$("#js-comment-form-" + id).toggle();
},
- toggle_arrow: function(id) {
- $("span#" + id + "_arrow").toggleClass("fa-minus-square").toggleClass("fa-plus-square");
- },
initialize: function() {
$("body").on("click", ".js-add-comment-link", function() {
App.Comments.toggle_form($(this).data().id);
@@ -49,10 +37,8 @@
});
$("body").on("click", ".js-toggle-children", function() {
- var children_container_id;
- children_container_id = ($(this).data().id) + "_children";
- $("#" + children_container_id).toggle("slow");
- App.Comments.toggle_arrow(children_container_id);
+ $(this).closest(".comment").find(".comment-list:first").toggle("slow");
+ $(this).children(".far").toggleClass("fa-minus-square fa-plus-square");
$(this).children(".js-child-toggle").toggle();
return false;
});
diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss
index 82aee720f..3c195b1d8 100644
--- a/app/assets/stylesheets/layout.scss
+++ b/app/assets/stylesheets/layout.scss
@@ -2084,6 +2084,7 @@ table {
}
.comment {
+ line-height: $list-lineheight;
margin: $line-height / 4 0;
position: relative;
@@ -2171,12 +2172,24 @@ table {
}
}
-.comment-children {
- border-left: 1px dashed $border;
- display: inline-block;
- margin-left: rem-calc(16);
- padding-left: rem-calc(8);
- width: 100%;
+.comment-list {
+ margin: $line-height / 4 0;
+
+ .comment-list {
+ border-left: 1px dashed $border;
+ display: inline-block;
+ padding-left: rem-calc(8);
+ width: 100%;
+
+ }
+
+ .comment-form {
+ display: none;
+ }
+
+ &:empty {
+ display: none;
+ }
}
.comment-info {
diff --git a/app/views/budgets/investments/show.html.erb b/app/views/budgets/investments/show.html.erb
index de38661a5..b0eee0ec3 100644
--- a/app/views/budgets/investments/show.html.erb
+++ b/app/views/budgets/investments/show.html.erb
@@ -19,7 +19,6 @@
diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb
index 0f51daac0..382555b62 100644
--- a/app/views/comments/_comment.html.erb
+++ b/app/views/comments/_comment.html.erb
@@ -1,12 +1,7 @@
-<% comment_flags ||= @comment_flags %>
<% valuation = local_assigns.fetch(:valuation, false) %>
-<% allow_votes = local_assigns.fetch(:allow_votes, true) %>
-<% allow_actions = local_assigns.fetch(:allow_actions, true) %>
-<% allow_comments = local_assigns.fetch(:allow_comments, true) %>
-<% admin_layout = local_assigns.fetch(:admin_layout, false) %>
-<% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags), (admin_layout if admin_layout)] do %>
-
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
- comment_flags: @comment_flags,
display_comments_count: true %>
diff --git a/app/views/polls/_comments.html.erb b/app/views/polls/_comments.html.erb
index 5ac2dfb64..b99b9f351 100644
--- a/app/views/polls/_comments.html.erb
+++ b/app/views/polls/_comments.html.erb
@@ -1,18 +1,16 @@
-<% cache [locale_and_user_status, @current_order, commentable_cache_key(@poll), @comment_tree.comments, @comment_tree.comment_authors, @poll.comments_count, @comment_flags] do %>
+<% cache [locale_and_user_status, @current_order, commentable_cache_key(@poll), @comment_tree.comments, @comment_tree.comment_authors, @poll.comments_count] do %>
diff --git a/app/views/proposals/_comments.html.erb b/app/views/proposals/_comments.html.erb
index a3b0c635e..a8e657835 100644
--- a/app/views/proposals/_comments.html.erb
+++ b/app/views/proposals/_comments.html.erb
@@ -1,18 +1,16 @@
-<% cache [locale_and_user_status, @current_order, commentable_cache_key(@proposal), @comment_tree.comments, @comment_tree.comment_authors, @proposal.comments_count, @comment_flags] do %>
+<% cache [locale_and_user_status, @current_order, commentable_cache_key(@proposal), @comment_tree.comments, @comment_tree.comment_authors, @proposal.comments_count] do %>
diff --git a/app/views/topics/_comments.html.erb b/app/views/topics/_comments.html.erb
index a5ca165fe..abcaba601 100644
--- a/app/views/topics/_comments.html.erb
+++ b/app/views/topics/_comments.html.erb
@@ -1,17 +1,14 @@
-<% cache [locale_and_user_status, @current_order, commentable_cache_key(@topic), @comment_tree.comments, @comment_tree.comment_authors, @topic.comments_count, @comment_flags] do %>
+<% cache [locale_and_user_status, @current_order, commentable_cache_key(@topic), @comment_tree.comments, @comment_tree.comment_authors, @topic.comments_count] do %>
- <% child_comments_of(comment).each do |child| %> --
- <%= render "comments/comment", { comment: child,
- valuation: valuation,
- allow_votes: allow_votes,
- allow_actions: allow_actions,
- allow_comments: allow_comments } %>
-
- <% end %>
-
-