diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb index c81f49d37..ad3b9ab48 100644 --- a/app/helpers/aspects_helper.rb +++ b/app/helpers/aspects_helper.rb @@ -22,4 +22,13 @@ module AspectsHelper def remove_from_aspect_button(aspect_id, person_id) link_to image_tag('icons/monotone_check_yes.png'), {:controller => "aspects", :action => 'remove_from_aspect', :aspect_id => aspect_id, :person_id => person_id}, :remote => true, :class => 'added button' end + + def aspect_membership_button(aspect_id, contact) + unless contact.aspect_ids.include?(aspect_id) + add_to_aspect_button(aspect_id, contact.person.id) + else + remove_from_aspect_button(aspect_id, contact.person.id) + end + end end + diff --git a/app/helpers/dashboards_helper.rb b/app/helpers/dashboards_helper.rb deleted file mode 100644 index a5cf68cd5..000000000 --- a/app/helpers/dashboards_helper.rb +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. - -module DashboardsHelper - def title_for_page - I18n.t('_home') - end -end diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb new file mode 100644 index 000000000..4f93c4596 --- /dev/null +++ b/app/helpers/stream_helper.rb @@ -0,0 +1,15 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3 or later. See +# the COPYRIGHT file. + +module StreamHelper + + def comment_toggle(count) + if count > 0 + link_to "#{t('.hide_comments')} (#{count})", '#', :class => "show_post_comments" + else + link_to "#{t('.show_comments')} (#{count})", '#', :class => "show_post_comments" + end + end + +end diff --git a/app/views/comments/_comment.html.haml b/app/views/comments/_comment.html.haml index fe94bd6fd..431b326a1 100644 --- a/app/views/comments/_comment.html.haml +++ b/app/views/comments/_comment.html.haml @@ -2,11 +2,11 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -%li.comment{:data=>{:guid=>post.id}} - = person_image_link(post.person) +%li.comment{:data=>{:guid=>comment.id}} + = person_image_link(person) .content .from - = link_to post.person.real_name, post.person - = markdownify(post.text) + = link_to person.real_name, person + = markdownify(comment.text) %div.time - = "#{time_ago_in_words(post.updated_at)} #{t('ago')}" + = "#{time_ago_in_words(comment.updated_at)} #{t('ago')}" diff --git a/app/views/comments/_comments.html.haml b/app/views/comments/_comments.html.haml index 01ac7c0d7..e057db36a 100644 --- a/app/views/comments/_comments.html.haml +++ b/app/views/comments/_comments.html.haml @@ -2,9 +2,9 @@ -# licensed under the Affero General Public License version 3 or later. See -# the COPYRIGHT file. -%ul.comments{:id => post.id} +%ul.comments{:id => post.id, :class => ("hidden" if defined?(hidden) && hidden)} - for comment in post.comments - = render 'comments/comment', :post => comment + = render 'comments/comment', :comment => comment, :person => comment.person %li.comment.show = render 'comments/new_comment', :post => post diff --git a/app/views/shared/_contact_list.html.haml b/app/views/shared/_contact_list.html.haml index 01dd54a93..253c9c4a4 100644 --- a/app/views/shared/_contact_list.html.haml +++ b/app/views/shared/_contact_list.html.haml @@ -99,7 +99,4 @@ %span.name = link_to contact.person.real_name, contact.person .right - - unless contact.aspect_ids.include?(aspect.id) - = add_to_aspect_button(aspect.id, contact.person.id) - - else - = remove_from_aspect_button(aspect.id, contact.person.id) + = aspect_membership_button(aspect.id, contact) diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 1a4bd75df..ba5c42f89 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -28,7 +28,8 @@ .info %span.time= link_to(how_long_ago(post), object_path(post)) - = link_to "#{t('.show_comments')} (#{post.comments.count})", '#', :class => "show_post_comments" - = render "comments/comments", :post => post + = comment_toggle(post.comments.count) + + = render "comments/comments", :post => post, :hidden => (post.comments.count == 0) diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index f5f76c165..b1767c439 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -66,6 +66,7 @@ en: shared: stream_element: show_comments: "show comments" + hide_comments: "hide comments" publisher: posting: "Posting..." share: "Share" diff --git a/public/javascripts/stream.js b/public/javascripts/stream.js index 6ebde54ea..224c30dc2 100644 --- a/public/javascripts/stream.js +++ b/public/javascripts/stream.js @@ -7,19 +7,11 @@ $(document).ready(function(){ var $stream = $(".stream"); var $publisher = $("#publisher"); - // expand all comments on page load - $stream.not('.show').find('.comments').each(function(index) { - var comments = $(this); - if(comments.children("li").length > 1) { - var show_comments_toggle = comments.closest("li").find(".show_post_comments"); - expandComments(show_comments_toggle,false); - } - }); // comment toggle action $stream.not(".show").delegate("a.show_post_comments", "click", function(evt) { evt.preventDefault(); - expandComments($(this),true); + expandComments($(this)); }); // comment submit action @@ -116,24 +108,17 @@ function expandComments(toggler,animate){ var text = toggler.html(); commentBlock = toggler.closest("li").find("ul.comments", ".content"); - if( toggler.hasClass("visible")) { - toggler.removeClass("visible") - .html(text.replace("hide", "show")); - - if(animate) { - commentBlock.fadeOut(150); - } else { - commentBlock.hide(); - } + if(commentBlock.hasClass("hidden")) { + commentBlock.fadeIn(150, function(){ + commentBlock.removeClass("hidden"); + }); + toggler.html(text.replace("show", "hide")); } else { - toggler.addClass("visible") - .html(text.replace("show", "hide")); + commentBlock.fadeOut(100, function(){ + commentBlock.addClass("hidden"); + }); + toggler.html(text.replace("hide", "show")); - if(animate) { - commentBlock.fadeIn(150); - } else { - commentBlock.show(); - } } } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 542d0821c..11117a4f7 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -33,7 +33,7 @@ h4 :margin :bottom 5px -ol, ul +ol, ul, li :list-style none form @@ -536,7 +536,6 @@ li.message :border none .stream ul.comments - :display none .avatar :width 35px @@ -564,6 +563,8 @@ ul.comments :width 100% li.comment + :list + :style none :padding 0.6em :border :bottom 1px solid #ddd