commontator 6.0.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 493bb858e4b65e4edeb26a496fe56b93d9119ffd2555097af8ab84a016aa29a9
4
- data.tar.gz: f6dd0195a93216cc8900c10de23e2055f4eb539cebd86410970f58b4f4724795
3
+ metadata.gz: c63a6212f25d57ea206e1cfb23f4c8dff604ce26f6fb1a5d1ddb0088b030a4a5
4
+ data.tar.gz: 23ecd8f13e5af29e8968882361b2e87506d80ac23a209e4116c638a63514f46e
5
5
  SHA512:
6
- metadata.gz: 0b7e38a1081300cdf9ed8c711b295d0fc8494a0cafddb5c2f03f96a4041770edef63d1a11e4e74046c3f23e6cb51f770d26b224ea8c597da4b021f706ff7932b
7
- data.tar.gz: 033432442ad4e7f81d382398e0e37eeea3bcd46c54e627ecef298e435c3f186244e264cebc300527e727b365b9a82e1769e1d782571535668499448f8459e18d
6
+ metadata.gz: 04c523c45acc09a1062fbeeefbe1e328ee439b7f929f9fdb5d00a7d510d547434d2648cfbb1326d6ad0e7c182d91e2c745839434ac948af297fce964cb2c0724
7
+ data.tar.gz: 64b8731da68531908d2230936f21d647a5b2567d044490ebdbce8d85aa2dcdddff84ae68f31bd88b282df59f5ca7df19d2bf9d657a644715a0f6324c3e8ae548
@@ -1,9 +1,12 @@
1
1
  <%
2
- # Views that use this partial must provide the following variables:
2
+ # Views that use this partial must provide the following variable:
3
3
  # comment
4
4
  #
5
+
6
+ new_record = comment.new_record?
7
+
5
8
  # Optionally, they can also supply the following variables:
6
- thread ||= nil
9
+ thread ||= new_record ? comment.thread : nil
7
10
  no_remote ||= false
8
11
  %>
9
12
 
@@ -11,7 +14,7 @@
11
14
 
12
15
  <% if comment.errors.any? %>
13
16
  <div class="error-explanation">
14
- <h3><%= t "commontator.comment.errors.#{comment.id.blank? ? 'create' : 'update'}" %></h3>
17
+ <h3><%= t "commontator.comment.errors.#{new_record ? 'create' : 'update'}" %></h3>
15
18
 
16
19
  <ul>
17
20
  <% comment.errors.full_messages.each do |msg| %>
@@ -33,15 +36,20 @@
33
36
 
34
37
  <div class="field">
35
38
  <%=
36
- form.text_area :body, rows: '7', id: comment.id.blank? ?
37
- "commontator-thread-#{@commontator_thread.id}-new-comment-body" :
39
+ form.text_area :body, rows: '7', id: new_record ?
40
+ comment.parent.nil? ? "commontator-thread-#{@commontator_thread.id}-new-comment-body" :
41
+ "commontator-comment-#{comment.parent.id}-reply" :
38
42
  "commontator-comment-#{comment.id}-edit-body"
39
43
  %>
40
44
  <%= javascript_tag('Commontator.initMentions();') if config.mentions_enabled %>
41
45
  </div>
42
46
 
43
47
  <div class="submit">
44
- <%= form.submit t("commontator.comment.actions.#{comment.id.blank? ? 'create' : 'update'}") %>
45
- <%= form.submit t('commontator.comment.actions.cancel'), name: 'cancel' %>
48
+ <%= form.submit t("commontator.comment.actions.#{new_record ? 'create' : 'update'}") %>
49
+ <%=
50
+ form.submit(
51
+ t('commontator.comment.actions.cancel'), name: 'cancel'
52
+ ) unless config.new_comment_style == :t && new_record && comment.parent.nil?
53
+ %>
46
54
  </div>
47
55
  <% end %>
@@ -62,7 +62,7 @@
62
62
 
63
63
  <div id="commontator-comment-<%= comment.id %>-section-bottom" class="section bottom">
64
64
  <% unless comment.is_deleted? %>
65
- <span id="commontator-comment-<%= comment.id %>-reply" class="reply">
65
+ <span id="commontator-comment-<%= comment.id %>-reply-link" class="reply">
66
66
  <%=
67
67
  link_to(
68
68
  t('commontator.comment.actions.reply'),
@@ -83,8 +83,16 @@
83
83
  </div>
84
84
 
85
85
  <div id="commontator-comment-<%= comment.id %>-children" class="children">
86
+ <% if thread.config.comment_order == :l %>
87
+ <div id="commontator-comment-<%= comment.id %>-reply" class="reply"></div>
88
+ <% end %>
89
+
86
90
  <%= render partial: 'commontator/comments/list',
87
91
  locals: { user: user, nested_comments: nested_children } %>
92
+
93
+ <% if thread.config.comment_order != :l %>
94
+ <div id="commontator-comment-<%= comment.id %>-reply" class="reply"></div>
95
+ <% end %>
88
96
  </div>
89
97
 
90
98
  <div id="commontator-comment-<%= comment.id %>-pagination" class="pagination">
@@ -1,7 +1,13 @@
1
- <% if @comment.nil? || !@comment.persisted? %>
2
- $("#commontator-thread-<%= @commontator_thread.id %>-new-comment").hide();
1
+ <% if @comment.nil? || @comment.new_record? %>
2
+ <%
3
+ id = @comment.nil? || @comment.parent.nil? ?
4
+ "commontator-thread-#{@commontator_thread.id}-new-comment" :
5
+ "commontator-comment-#{@comment.parent.id}-reply"
6
+ %>
3
7
 
4
- $("#commontator-thread-<%= @commontator_thread.id %>-new-comment-link").fadeIn();
8
+ $("#<%= id %>").hide();
9
+
10
+ $("#<%= id %>-link").fadeIn();
5
11
  <% else %>
6
12
  $("#commontator-comment-<%= @comment.id %>-body").html("<%= escape_javascript(
7
13
  render partial: 'body', locals: { comment: @comment }
@@ -2,9 +2,11 @@
2
2
  if @comment.parent.nil?
3
3
  partial = 'threads'
4
4
  extra_locals = {}
5
+ id = "commontator-thread-#{@commontator_thread.id}-new-comment"
5
6
  else
6
7
  partial = 'comments'
7
8
  extra_locals = { comment: @comment.parent }
9
+ id = "commontator-comment-#{@comment.parent.id}-reply"
8
10
  end
9
11
 
10
12
  render partial: "commontator/#{partial}/show", locals: extra_locals.merge(
@@ -16,17 +18,20 @@
16
18
  %>
17
19
 
18
20
  <% if @commontator_new_comment.nil? %>
19
- $("#commontator-thread-<%= @commontator_thread.id %>-new-comment").hide();
21
+ $("#<%= id %>").hide();
20
22
 
21
- $("#commontator-thread-<%= @commontator_thread.id %>-new-comment-link").fadeIn();
23
+ $("#<%= id %>-link").fadeIn();
22
24
  <% else %>
23
- $("#commontator-thread-<%= @commontator_thread.id %>-new-comment").html("<%= escape_javascript(
25
+ $("#<%= id %>").html("<%= escape_javascript(
24
26
  render partial: 'form', locals: {
25
27
  comment: @commontator_new_comment, thread: @commontator_thread
26
28
  }
27
29
  ) %>");
28
30
  <% end %>
29
31
 
30
- $("#commontator-comment-<%= @comment.id %>").hide().fadeIn()[0].scrollIntoView();
32
+ var commontatorComment = $("#commontator-comment-<%= @comment.id %>").hide().fadeIn();
33
+ $('html, body').animate(
34
+ { scrollTop: commontatorComment.offset().top - window.innerHeight/2 }, 'fast'
35
+ );
31
36
 
32
37
  <%= javascript_proc %>
@@ -1,9 +1,15 @@
1
- $("#commontator-thread-<%= @commontator_thread.id %>-new-comment").html("<%= escape_javascript(
1
+ <%
2
+ id = @comment.parent.nil? ? "commontator-thread-#{@commontator_thread.id}-new-comment" :
3
+ "commontator-comment-#{@comment.parent.id}-reply"
4
+ %>
5
+
6
+ var commontatorForm = $("#<%= id %>").html("<%= escape_javascript(
2
7
  render partial: 'form', locals: { comment: @comment, thread: @commontator_thread }
3
- ) %>").fadeIn()[0].scrollIntoView();
8
+ ) %>").hide().fadeIn();
9
+ $('html, body').animate({ scrollTop: commontatorForm.offset().top - window.innerHeight/2 }, 'fast');
4
10
 
5
- $("#commontator-thread-<%= @commontator_thread.id %>-new-comment-link").hide();
11
+ $("#<%= id %>-link").hide();
6
12
 
7
- $('#commontator-thread-<%= @commontator_thread.id %>-new-comment-body').focus();
13
+ $('#<%= id %>-body').focus();
8
14
 
9
15
  <%= javascript_proc %>
@@ -14,17 +14,11 @@ var commontatorOldCommentIds = $("#commontator-comment-<%=
14
14
  }
15
15
  %>
16
16
 
17
- var commontatorOldComments = $(commontatorOldCommentIds);
18
17
  var commontatorNewComments = $("#commontator-comment-<%=
19
18
  @comment.id
20
- %>-children").children().not(commontatorOldComments);
21
-
22
- commontatorNewComments.hide().fadeIn();
23
-
24
- if (commontatorOldComments.length > 0) {
25
- commontatorOldComments[commontatorOldComments.length - 1].scrollIntoView();
26
- } else {
27
- $("#commontator-comment-<%= @comment.id %>")[0].scrollIntoView();
28
- }
19
+ %>-children").children().not(commontatorOldCommentIds).hide().fadeIn();
20
+ $('html, body').animate(
21
+ { scrollTop: commontatorNewComments.offset().top - window.innerHeight/2 }, 'fast'
22
+ );
29
23
 
30
24
  <%= javascript_proc %>
@@ -6,11 +6,17 @@
6
6
  $("#commontator-thread-<%= thread.id %>-hide-link").click(function() {
7
7
  $("#commontator-thread-<%= thread.id %>-content").hide();
8
8
 
9
- $("#commontator-thread-<%= thread.id %>-show").fadeIn()[0].scrollIntoView();
9
+ var commontatorLink = $("#commontator-thread-<%= thread.id %>-show").fadeIn();
10
+ $('html, body').animate(
11
+ { scrollTop: commontatorLink.offset().top - window.innerHeight/2 }, 'fast'
12
+ );
10
13
  });
11
14
 
12
15
  $("#commontator-thread-<%= thread.id %>-show-link").click(function() {
13
- $("#commontator-thread-<%= thread.id %>-content").fadeIn()[0].scrollIntoView();
16
+ var commontatorThread = $("#commontator-thread-<%= thread.id %>-content").fadeIn();
17
+ $('html, body').animate(
18
+ { scrollTop: commontatorThread.offset().top - window.innerHeight/2 }, 'fast'
19
+ );
14
20
 
15
21
  $("#commontator-thread-<%= thread.id %>-show").hide();
16
22
  });
@@ -10,6 +10,14 @@
10
10
  <% elsif !user %>
11
11
  <p><%= t 'commontator.require_login' %>.</p>
12
12
  <% else %>
13
+ <% if @commontator_new_comment.nil? %>
14
+ <div id="commontator-thread-<%= thread.id %>-new-comment-link" class="new-comment">
15
+ <%= link_to t('commontator.comment.actions.new'),
16
+ commontator.new_thread_comment_path(thread),
17
+ remote: true %>
18
+ </div>
19
+ <% end %>
20
+
13
21
  <div id="commontator-thread-<%= thread.id %>-new-comment" class="new-comment<%=
14
22
  @commontator_new_comment.nil? ? ' hidden' : '' %>">
15
23
  <% unless @commontator_new_comment.nil? %>
@@ -20,13 +28,5 @@
20
28
  %>
21
29
  <% end %>
22
30
  </div>
23
-
24
- <% if @commontator_new_comment.nil? %>
25
- <div id="commontator-thread-<%= thread.id %>-new-comment-link" class="new-comment">
26
- <%= link_to t('commontator.comment.actions.new'),
27
- commontator.new_thread_comment_path(thread),
28
- remote: true %>
29
- </div>
30
- <% end %>
31
31
  <% end %>
32
32
  </div>
@@ -210,9 +210,7 @@ Commontator.configure do |config|
210
210
  # How to display the "new comment" form
211
211
  # Valid options:
212
212
  # :t (always present in the thread's page)
213
- # :l (link to the form; opens in the same page using JS)
214
- # Not yet implemented:
215
- # :n (link to the form; opens in a new window)
213
+ # :l (link to the form, which appears in the same location the new comment will appear)
216
214
  # Default: :l
217
215
  config.new_comment_style = :l
218
216
 
@@ -1 +1 @@
1
- COMMONTATOR_VERSION = '6.0.1'
1
+ COMMONTATOR_VERSION = '6.1.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commontator
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dante Soares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2019-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails