From dbdf14b926fb9d93af2f122e9aa8e3fd12a3dd55 Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Mon, 18 Jan 2021 21:45:06 -0800 Subject: [PATCH 1/3] move comment.js & dragdrop.js to higher-level views #9004 --- app/views/comments/_form.html.erb | 3 --- app/views/notes/show.html.erb | 2 ++ app/views/questions/show.html.erb | 2 ++ app/views/wiki/show.html.erb | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 886d12d68d..3e949f50a3 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -103,11 +103,8 @@ $E.refresh(); } - - <%= javascript_include_tag "dragdrop" %> - <%= javascript_include_tag "comment.js" %>
diff --git a/app/views/notes/show.html.erb b/app/views/notes/show.html.erb index c9e08dc04c..d4fa4efebd 100644 --- a/app/views/notes/show.html.erb +++ b/app/views/notes/show.html.erb @@ -117,6 +117,8 @@
<% end %> <% if !@preview %> + <%= javascript_include_tag "dragdrop" %> + <%= javascript_include_tag "comment" %> <%= render partial: "notes/responses" %>
<%= render partial: "notes/comments" %>
<% end %> diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb index 24a1e6f0f4..9bb7fee155 100644 --- a/app/views/questions/show.html.erb +++ b/app/views/questions/show.html.erb @@ -55,6 +55,8 @@ <% comments = @node.comments_viewable_by(current_user) %>

<%= comments.size %> Comments

+ <%= javascript_include_tag "dragdrop" %> + <%= javascript_include_tag "comment" %> <% comments.includes([:node, :replied_comments]).order("timestamp ASC").each do |comment| %> <% if comment.reply_to.nil? %> <%= render :partial => "notes/comment", :locals => {:comment => comment} %> diff --git a/app/views/wiki/show.html.erb b/app/views/wiki/show.html.erb index 875a37e571..2d7a0377f6 100644 --- a/app/views/wiki/show.html.erb +++ b/app/views/wiki/show.html.erb @@ -32,7 +32,9 @@
<% if controller.action_name == 'comments' %> - <%= render partial: "notes/comments", :locals => {:nodes => @nodes} %> + <%= javascript_include_tag "dragdrop" %> + <%= javascript_include_tag "comment" %> + <%= render partial: "notes/comments", :locals => {:nodes => @nodes} %> <% else %>
style="max-width:800px;"<% end %> id="content" class="pl-content wiki"> <% if @node.has_tag('format:raw') %> From b8402a0e58d921640efe11f6547d8f6b9dfa85c8 Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Mon, 18 Jan 2021 23:35:20 -0800 Subject: [PATCH 2/3] attach eventListeners on document.load #9004 --- app/assets/javascripts/comment.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/comment.js b/app/assets/javascripts/comment.js index da5dc92abf..039b5af104 100644 --- a/app/assets/javascripts/comment.js +++ b/app/assets/javascripts/comment.js @@ -1,5 +1,4 @@ -(function() { - +$(function() { $('.comment-form').each(function() { if(!$(this).hasClass('bound-success')) { $(this).addClass('bound-success').on('ajax:success', function(e, data, status, xhr){ @@ -46,7 +45,7 @@ } }); -}()); +}); function insertTitleSuggestionTemplate() { var element = $('#text-input'); From 7a1b0f2f27e2858bf431bc288ec6ee2bb9e97966 Mon Sep 17 00:00:00 2001 From: Will Gutierrez Date: Mon, 18 Jan 2021 23:35:55 -0800 Subject: [PATCH 3/3] move dragdrop.js & comment.js to notes/comments partial #9004 --- app/views/notes/_comments.html.erb | 3 ++- app/views/notes/show.html.erb | 2 -- app/views/wiki/show.html.erb | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/views/notes/_comments.html.erb b/app/views/notes/_comments.html.erb index 38a520eefd..985a6c14d0 100644 --- a/app/views/notes/_comments.html.erb +++ b/app/views/notes/_comments.html.erb @@ -2,7 +2,8 @@
<% comments = @node.comments_viewable_by(current_user) %>

<%= comments.size %> <%= translation('notes._comments.comments') %>

- + <%= javascript_include_tag "dragdrop" %> + <%= javascript_include_tag "comment" %>
<% comments.includes([:replied_comments, :node]).order('timestamp ASC').each do |comment| %> <% if comment.cid == @node.comments&.first&.cid %><% end %> diff --git a/app/views/notes/show.html.erb b/app/views/notes/show.html.erb index d4fa4efebd..c9e08dc04c 100644 --- a/app/views/notes/show.html.erb +++ b/app/views/notes/show.html.erb @@ -117,8 +117,6 @@
<% end %> <% if !@preview %> - <%= javascript_include_tag "dragdrop" %> - <%= javascript_include_tag "comment" %> <%= render partial: "notes/responses" %>
<%= render partial: "notes/comments" %>
<% end %> diff --git a/app/views/wiki/show.html.erb b/app/views/wiki/show.html.erb index 2d7a0377f6..2ddc8a1bec 100644 --- a/app/views/wiki/show.html.erb +++ b/app/views/wiki/show.html.erb @@ -32,8 +32,6 @@
<% if controller.action_name == 'comments' %> - <%= javascript_include_tag "dragdrop" %> - <%= javascript_include_tag "comment" %> <%= render partial: "notes/comments", :locals => {:nodes => @nodes} %> <% else %>
style="max-width:800px;"<% end %> id="content" class="pl-content wiki">