From 883d279558943d2937780d8884387e71880d64b9 Mon Sep 17 00:00:00 2001 From: Jan Schulz-Hofen Date: Fri, 14 Oct 2016 12:51:20 +0200 Subject: [PATCH 2/3] For 3 comments or more, show reply link at top of comments as well and jump to text area if clicked --- app/helpers/application_helper.rb | 1 + app/views/messages/show.html.erb | 3 +++ app/views/news/show.html.erb | 3 +++ 3 files changed, 7 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d257894..e6fd4eb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -226,6 +226,7 @@ module ApplicationHelper def toggle_link(name, id, options={}) onclick = "$('##{id}').toggle(); " onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ") + onclick << "$(window).scrollTop($('##{options[:focus]}').position().top); " if options[:scroll] onclick << "return false;" link_to(name, "#", :onclick => onclick) end diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index 0adf0f8..0911bd4 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -35,6 +35,9 @@ <% unless @replies.empty? %>

<%= l(:label_reply_plural) %> (<%= @reply_count %>)

+<% if !@topic.locked? && authorize_for('messages', 'reply') && @replies.size >= 3 %> +

<%= toggle_link l(:button_reply), "reply", :focus => 'message_content', :scroll => "message_content" %>

+<% end %> <% @replies.each do |message| %>
">
diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb index 2178e1c..09e14f6 100644 --- a/app/views/news/show.html.erb +++ b/app/views/news/show.html.erb @@ -33,6 +33,9 @@

<%= l(:label_comment_plural) %>

+<% if @news.commentable? && @comments.size >= 3 %> +

<%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments", :scroll => "comment_comments" %>

+<% end %> <% @comments.each do |comment| %> <% next if comment.new_record? %>
-- 2.7.2