Skip to content

Commit

Permalink
Feature: Reorganize comment.js & dragdrop.js Script-Loading (publicla…
Browse files Browse the repository at this point in the history
…b#9037)

* move comment.js & dragdrop.js to higher-level views publiclab#9004

* attach eventListeners on document.load publiclab#9004

* move dragdrop.js & comment.js to notes/comments partial publiclab#9004
  • Loading branch information
noi5e authored and lagunasmel committed Mar 2, 2021
1 parent 850a2d8 commit 9e284b8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions app/assets/javascripts/comment.js
Original file line number Diff line number Diff line change
@@ -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){
Expand Down Expand Up @@ -46,7 +45,7 @@
}

});
}());
});

function insertTitleSuggestionTemplate() {
var element = $('#text-input');
Expand Down
3 changes: 0 additions & 3 deletions app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@
$E.refresh();
}
</script>

<%= javascript_include_tag "dragdrop" %>
<script src="/emoji.js" type="text/javascript"></script>
<script src="/assets/atwho_autocomplete.js" type="text/javascript"></script>
<%= javascript_include_tag "comment.js" %>

<div class="control-group">
<button type="submit" class="btn btn-primary"><%= translation('comments._form.publish') %></button>
Expand Down
3 changes: 2 additions & 1 deletion app/views/notes/_comments.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<div id="comments" class="col-lg-10 comments">
<% comments = @node.comments_viewable_by(current_user) %>
<h3><span id="comment-count"><%= comments.size %></span> <%= translation('notes._comments.comments') %></h3>

<%= javascript_include_tag "dragdrop" %>
<%= javascript_include_tag "comment" %>
<div style="margin-bottom: 50px;" id="comments-list">
<% comments.includes([:replied_comments, :node]).order('timestamp ASC').each do |comment| %>
<% if comment.cid == @node.comments&.first&.cid %><a id="last" name="last"></a><% end %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/questions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
<% comments = @node.comments_viewable_by(current_user) %>
<h3><span id="comment-count"><%= comments.size %></span> Comments</h3>
<div id="comments-list">
<%= 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} %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/wiki/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<div class="tab-pane active" id="tab-overview">
<% if controller.action_name == 'comments' %>
<%= render partial: "notes/comments", :locals => {:nodes => @nodes} %>
<%= render partial: "notes/comments", :locals => {:nodes => @nodes} %>
<% else %>
<div <% unless @node.has_tag('style:wide') %>style="max-width:800px;"<% end %> id="content" class="pl-content wiki">
<% if @node.has_tag('format:raw') %>
Expand Down

0 comments on commit 9e284b8

Please sign in to comment.