From d972802142f7c6b2b807c75f38eecf0438deffaf Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Mon, 26 Sep 2011 00:52:23 -0700 Subject: [PATCH] comment ajax on mobile. --- .../{_comments.haml => _comments.html.haml} | 0 app/views/comments/_comments.mobile.haml | 18 ++++++++++++++++++ .../comments/{index.haml => index.html.haml} | 0 app/views/comments/index.mobile.haml | 1 + app/views/shared/_stream_element.mobile.haml | 2 +- public/javascripts/mobile.js | 9 +++++---- public/stylesheets/sass/mobile.scss | 13 ++++++++++++- 7 files changed, 37 insertions(+), 6 deletions(-) rename app/views/comments/{_comments.haml => _comments.html.haml} (100%) create mode 100644 app/views/comments/_comments.mobile.haml rename app/views/comments/{index.haml => index.html.haml} (100%) create mode 100644 app/views/comments/index.mobile.haml diff --git a/app/views/comments/_comments.haml b/app/views/comments/_comments.html.haml similarity index 100% rename from app/views/comments/_comments.haml rename to app/views/comments/_comments.html.haml diff --git a/app/views/comments/_comments.mobile.haml b/app/views/comments/_comments.mobile.haml new file mode 100644 index 000000000..f1c261983 --- /dev/null +++ b/app/views/comments/_comments.mobile.haml @@ -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) diff --git a/app/views/comments/index.haml b/app/views/comments/index.html.haml similarity index 100% rename from app/views/comments/index.haml rename to app/views/comments/index.html.haml diff --git a/app/views/comments/index.mobile.haml b/app/views/comments/index.mobile.haml new file mode 100644 index 000000000..839637079 --- /dev/null +++ b/app/views/comments/index.mobile.haml @@ -0,0 +1 @@ += render :partial => 'comments/comment', :collection => @comments, :locals => {:post => @post} diff --git a/app/views/shared/_stream_element.mobile.haml b/app/views/shared/_stream_element.mobile.haml index 6e9785fff..d51d753ee 100644 --- a/app/views/shared/_stream_element.mobile.haml +++ b/app/views/shared/_stream_element.mobile.haml @@ -59,5 +59,5 @@ - else = 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' diff --git a/public/javascripts/mobile.js b/public/javascripts/mobile.js index d7b1d9c3d..f8d277905 100644 --- a/public/javascripts/mobile.js +++ b/public/javascripts/mobile.js @@ -45,14 +45,15 @@ $(document).ready(function(){ $("a.show_comments").live('tap click', function(evt){ evt.preventDefault(); - var postId = $(this).data('post-id'); - parent = $(this).closest(".bottom_bar").first(); - var link = $(this); + var link = $(this), + parent = link.closest(".bottom_bar").first(); + $.ajax({ url: link.attr('href'), success: function(data){ - parent.append(data); + var comments = $(""); + parent.append(comments.append(data)); } }); }); diff --git a/public/stylesheets/sass/mobile.scss b/public/stylesheets/sass/mobile.scss index 1f6ff8dd5..57b41a216 100644 --- a/public/stylesheets/sass/mobile.scss +++ b/public/stylesheets/sass/mobile.scss @@ -81,12 +81,19 @@ body { padding: 10px; } -.comments { +.stream_element .comments { padding: 0; margin: 0; + width: 100%; .content { padding: 0; } + + .comment { + padding: { + top: 10px; + } + } } .comment { @@ -375,3 +382,7 @@ form { -webkit-appearance: none; } } + +.show_comments { + font-size: larger; +}