diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index 6f5feeef5..61cee6f8e 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -5,7 +5,7 @@ module StreamHelper def comment_toggle(count) - if count > 0 + if count < 3 link_to "#{t('stream_helper.hide_comments')} (#{count})", '#', :class => "show_post_comments" else link_to "#{t('stream_helper.show_comments')} (#{count})", '#', :class => "show_post_comments" diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index 4ebf4d455..2b0298c81 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. - comment = hash[:comment] - person = hash[:person] -%li.comment{:data=>{:guid=>comment.id}} +%li.comment{:data=>{:guid=>comment.id}, :class => ("hidden" if(defined? hidden))} =person_image_link(person) .content .from diff --git a/app/views/comments/_comments.html.haml b/app/views/comments/_comments.html.haml index 3d80c6cf3..e41964902 100644 --- a/app/views/comments/_comments.html.haml +++ b/app/views/comments/_comments.html.haml @@ -3,7 +3,12 @@ -# the COPYRIGHT file. %ul.comments{:id => post_id, :class => ("hidden" if comment_hashes.size == 0)} - = render :partial => 'comments/comment', :collection => comment_hashes, :as => :hash + -if comment_hashes.size > 3 + .older_comments.hidden.inactive + = render :partial => 'comments/comment', :collection => comment_hashes[0..-3], :as => :hash + = render :partial => 'comments/comment', :collection => comment_hashes[-3, 3], :as => :hash + -else + = render :partial => 'comments/comment', :collection => comment_hashes, :as => :hash %li.comment.show = render 'comments/new_comment', :post_id => post_id diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 89638de21..84cbe64b0 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -434,7 +434,7 @@ en: simplicity_explanation: "Diaspora makes sharing clean and easy – and this goes for privacy too. Inherently private, Diaspora doesn’t make you wade through pages of settings and options just to keep your profile secure." learn_about_host: "Learn about how to host your own Diaspora server." stream_helper: - show_comments: "show comments" + show_comments: "show all comments" hide_comments: "hide comments" webfinger: fetch_failed: "failed to fetch webfinger profile for %{profile_url}" diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js index c45964d2d..6cab70efe 100644 --- a/public/javascripts/stream.js +++ b/public/javascripts/stream.js @@ -103,11 +103,21 @@ var Stream = { var $this = $(this), text = $this.html(), commentBlock = $this.closest("li").find("ul.comments", ".content"), + commentBlockMore = $this.closest("li").find(".older_comments", ".content"), show = (text.indexOf("show") != -1); - commentBlock.fadeToggle(150, function() { - commentBlock.toggleClass("hidden"); + + if( commentBlockMore.hasClass("inactive") ) { + commentBlockMore.fadeIn(150, function(){ + commentBlockMore.removeClass("inactive"); + commentBlockMore.removeClass("hidden"); + }); + } else { + commentBlock.fadeToggle(150, function() { + commentBlock.toggleClass("hidden"); }); + } + $this.html(text.replace((show) ? "show" : "hide", (show) ? "hide" : "show")); } };