Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize comment.js & dragdrop.js Script-Loading #9037

Merged
merged 3 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that all along, these eventHandlers weren't being attached on document.load!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch 🎉

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