Skip to content
Extraits de code Groupes Projets
Valider b56af997 rédigé par danielvincent's avatar danielvincent
Parcourir les fichiers

comment streams rendered expanded/collapsed initially by server.

parent b5dbfc12
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -22,4 +22,13 @@ module AspectsHelper ...@@ -22,4 +22,13 @@ module AspectsHelper
def remove_from_aspect_button(aspect_id, person_id) 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' 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 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 end
...@@ -2,8 +2,14 @@ ...@@ -2,8 +2,14 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
module DashboardsHelper module StreamHelper
def title_for_page
I18n.t('_home') 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
end end
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
%li.comment{:data=>{:guid=>post.id}} %li.comment{:data=>{:guid=>comment.id}}
= person_image_link(post.person) = person_image_link(person)
.content .content
.from .from
= link_to post.person.real_name, post.person = link_to person.real_name, person
= markdownify(post.text) = markdownify(comment.text)
%div.time %div.time
= "#{time_ago_in_words(post.updated_at)} #{t('ago')}" = "#{time_ago_in_words(comment.updated_at)} #{t('ago')}"
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
-# licensed under the Affero General Public License version 3 or later. See -# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file. -# the COPYRIGHT file.
%ul.comments{:id => post.id} %ul.comments{:id => post.id, :class => ("hidden" if defined?(hidden) && hidden)}
- for comment in post.comments - for comment in post.comments
= render 'comments/comment', :post => comment = render 'comments/comment', :comment => comment, :person => comment.person
%li.comment.show %li.comment.show
= render 'comments/new_comment', :post => post = render 'comments/new_comment', :post => post
...@@ -99,7 +99,4 @@ ...@@ -99,7 +99,4 @@
%span.name %span.name
= link_to contact.person.real_name, contact.person = link_to contact.person.real_name, contact.person
.right .right
- unless contact.aspect_ids.include?(aspect.id) = aspect_membership_button(aspect.id, contact)
= add_to_aspect_button(aspect.id, contact.person.id)
- else
= remove_from_aspect_button(aspect.id, contact.person.id)
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
.info .info
%span.time= link_to(how_long_ago(post), object_path(post)) %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: ...@@ -66,6 +66,7 @@ en:
shared: shared:
stream_element: stream_element:
show_comments: "show comments" show_comments: "show comments"
hide_comments: "hide comments"
publisher: publisher:
posting: "Posting..." posting: "Posting..."
share: "Share" share: "Share"
......
...@@ -7,19 +7,11 @@ ...@@ -7,19 +7,11 @@
$(document).ready(function(){ $(document).ready(function(){
var $stream = $(".stream"); var $stream = $(".stream");
var $publisher = $("#publisher"); 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 // comment toggle action
$stream.not(".show").delegate("a.show_post_comments", "click", function(evt) { $stream.not(".show").delegate("a.show_post_comments", "click", function(evt) {
evt.preventDefault(); evt.preventDefault();
expandComments($(this),true); expandComments($(this));
}); });
// comment submit action // comment submit action
...@@ -116,24 +108,17 @@ function expandComments(toggler,animate){ ...@@ -116,24 +108,17 @@ function expandComments(toggler,animate){
var text = toggler.html(); var text = toggler.html();
commentBlock = toggler.closest("li").find("ul.comments", ".content"); commentBlock = toggler.closest("li").find("ul.comments", ".content");
if( toggler.hasClass("visible")) { if(commentBlock.hasClass("hidden")) {
toggler.removeClass("visible") commentBlock.fadeIn(150, function(){
.html(text.replace("hide", "show")); commentBlock.removeClass("hidden");
});
if(animate) { toggler.html(text.replace("show", "hide"));
commentBlock.fadeOut(150);
} else {
commentBlock.hide();
}
} else { } else {
toggler.addClass("visible") commentBlock.fadeOut(100, function(){
.html(text.replace("show", "hide")); commentBlock.addClass("hidden");
});
toggler.html(text.replace("hide", "show"));
if(animate) {
commentBlock.fadeIn(150);
} else {
commentBlock.show();
}
} }
} }
......
...@@ -33,7 +33,7 @@ h4 ...@@ -33,7 +33,7 @@ h4
:margin :margin
:bottom 5px :bottom 5px
ol, ul ol, ul, li
:list-style none :list-style none
form form
...@@ -536,7 +536,6 @@ li.message ...@@ -536,7 +536,6 @@ li.message
:border none :border none
.stream ul.comments .stream ul.comments
:display none
.avatar .avatar
:width 35px :width 35px
...@@ -564,6 +563,8 @@ ul.comments ...@@ -564,6 +563,8 @@ ul.comments
:width 100% :width 100%
li.comment li.comment
:list
:style none
:padding 0.6em :padding 0.6em
:border :border
:bottom 1px solid #ddd :bottom 1px solid #ddd
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter