comment ajax on mobile.

This commit is contained in:
danielgrippi 2011-09-26 00:52:23 -07:00
parent 91c9fffb81
commit d972802142
7 changed files with 37 additions and 6 deletions

View file

@ -0,0 +1,18 @@
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
.comment_stream
- unless comments_expanded
%ul.show_comments{:class => ("hidden" if post.comments.size <= 3)}
%li
= comment_toggle( post)
%ul.comments{:class => ('loaded' if post.comments.size <= 3)}
-if post.comments.size > 3 && !comments_expanded
= render :partial => 'comments/comment', :collection => post.last_three_comments, :locals => {:post => post}
-else
= render :partial => 'comments/comment', :collection => post.comments, :locals => {:post => post}
- unless !user_signed_in? || @commenting_disabled
.new_comment_form_wrapper{:class => comment_form_wrapper_class(post)}
= new_comment_form(post.id, current_user)

View file

@ -0,0 +1 @@
= render :partial => 'comments/comment', :collection => @comments, :locals => {:post => @post}

View file

@ -59,5 +59,5 @@
- else - else
= link_to '', post_likes_path(post.id), :class => "image_link like_action inactive" = link_to '', post_likes_path(post.id), :class => "image_link like_action inactive"
= link_to "#{t('reactions', :count => (post.comments.length + post.likes_count))}", post_comments_path(post), :class => 'show_comments' = link_to "#{t('reactions', :count => (post.comments.length + post.likes_count))}", post_comments_path(post, :format => "mobile"), :class => 'show_comments'

View file

@ -45,14 +45,15 @@ $(document).ready(function(){
$("a.show_comments").live('tap click', function(evt){ $("a.show_comments").live('tap click', function(evt){
evt.preventDefault(); evt.preventDefault();
var postId = $(this).data('post-id'); var link = $(this),
parent = $(this).closest(".bottom_bar").first(); parent = link.closest(".bottom_bar").first();
var link = $(this);
$.ajax({ $.ajax({
url: link.attr('href'), url: link.attr('href'),
success: function(data){ success: function(data){
parent.append(data); var comments = $("<ul class='comments'></ul>");
parent.append(comments.append(data));
} }
}); });
}); });

View file

@ -81,12 +81,19 @@ body {
padding: 10px; padding: 10px;
} }
.comments { .stream_element .comments {
padding: 0; padding: 0;
margin: 0; margin: 0;
width: 100%;
.content { .content {
padding: 0; padding: 0;
} }
.comment {
padding: {
top: 10px;
}
}
} }
.comment { .comment {
@ -375,3 +382,7 @@ form {
-webkit-appearance: none; -webkit-appearance: none;
} }
} }
.show_comments {
font-size: larger;
}