comment streams rendered expanded/collapsed initially by server.
This commit is contained in:
parent
b5dbfc129c
commit
b56af997cb
10 changed files with 49 additions and 49 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
15
app/helpers/stream_helper.rb
Normal file
15
app/helpers/stream_helper.rb
Normal file
|
|
@ -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
|
||||
|
|
@ -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')}"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ en:
|
|||
shared:
|
||||
stream_element:
|
||||
show_comments: "show comments"
|
||||
hide_comments: "hide comments"
|
||||
publisher:
|
||||
posting: "Posting..."
|
||||
share: "Share"
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue