From a307519e94b64a7bb97bdac1ccf0f6b30574d9fe Mon Sep 17 00:00:00 2001 From: Raphael Sofaer Date: Thu, 10 Feb 2011 11:05:12 -0800 Subject: [PATCH] Put avatar on cmment form all the time, fix socketed comment form --- app/helpers/stream_helper.rb | 4 ++-- app/views/comments/_comments.haml | 2 +- ...ew_comment.haml => _new_comment.html.haml} | 2 +- app/views/shared/_stream_element.html.haml | 2 +- public/javascripts/web-socket-receiver.js | 9 ++++---- public/stylesheets/sass/application.sass | 21 ++++++++----------- 6 files changed, 19 insertions(+), 21 deletions(-) rename app/views/comments/{_new_comment.haml => _new_comment.html.haml} (94%) diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index 4e17e10a6..3fdb1c680 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -12,9 +12,9 @@ module StreamHelper end end - def new_comment_form(post_id) + def new_comment_form(post_id, current_user) @form ||= controller.render_to_string( - :partial => 'comments/new_comment', :locals => {:post_id => GSUB_THIS}) + :partial => 'comments/new_comment', :locals => {:post_id => GSUB_THIS, :current_user => current_user}) @form.gsub(GSUB_THIS, post_id.to_s) end end diff --git a/app/views/comments/_comments.haml b/app/views/comments/_comments.haml index 31669a289..dd7112062 100644 --- a/app/views/comments/_comments.haml +++ b/app/views/comments/_comments.haml @@ -19,4 +19,4 @@ - unless @commenting_disabled %li.comment.show - = new_comment_form(post_id) + = new_comment_form(post_id, current_user) diff --git a/app/views/comments/_new_comment.haml b/app/views/comments/_new_comment.html.haml similarity index 94% rename from app/views/comments/_new_comment.haml rename to app/views/comments/_new_comment.html.haml index 5f0b7a307..1dd3aaa28 100644 --- a/app/views/comments/_new_comment.haml +++ b/app/views/comments/_new_comment.html.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. = form_tag( comments_path, :id => "new_comment_on_#{post_id}", :class => 'new_comment', :remote => true) do - = owner_image_tag + = person_image_tag(current_user, nil) %p = label_tag "comment_text_on_#{post_id}", t('.comment') = text_area_tag :text, nil, :rows => 2, :class => "comment_box",:id => "comment_text_on_#{post_id}" diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index ded969c3e..9b976cd18 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -34,4 +34,4 @@ %span.timeago= link_to(how_long_ago(post), status_message_path(post)) = link_to t('comments.new_comment.comment').downcase, '#', :class => 'focus_comment_textarea' - = render "comments/comments", :post_id => post.id, :comments => post.comments, :condensed => true, :commenting_disabled => defined?(@commenting_disabled) + = render "comments/comments", :post_id => post.id, :comments => post.comments, :current_user => current_user, :condensed => true, :commenting_disabled => defined?(@commenting_disabled) diff --git a/public/javascripts/web-socket-receiver.js b/public/javascripts/web-socket-receiver.js index d18acde2b..9af68cfcf 100644 --- a/public/javascripts/web-socket-receiver.js +++ b/public/javascripts/web-socket-receiver.js @@ -120,10 +120,12 @@ var WebSocketReceiver = { addPostToStream: function(postId, html) { if( $(".stream_element[data-guid='" + postId + "']").length == 0 ) { + var streamElement = $(html); + var showMessage = function() { $("#main_stream:not('.show')").prepend( - $(html).fadeIn("fast", function() { - $("#main_stream").find("label").first().inFieldLabels(); + streamElement.fadeIn("fast", function() { + streamElement.find("label").inFieldLabels(); }) ); }; @@ -133,9 +135,8 @@ var WebSocketReceiver = { } else { showMessage(); } + Diaspora.widgets.timeago.updateTimeAgo(); } - Diaspora.widgets.timeago.updateTimeAgo(); - $("label").inFieldLabels(); }, onPageForClass: function(className) { diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index d86f00a33..ba8088629 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -600,10 +600,16 @@ ul.show_comments :size 1em :margin :bottom -3px - :width 482px + :width 445px + :min-height 23px - .avatar - :display none + p + :position relative + :left 36px + + .avatar + :position absolute + :display inline form.open .submit_button @@ -611,18 +617,9 @@ ul.show_comments :margin :bottom 2px :right 2px - textarea :min-height 2.4em - :width 445px - p - :position relative - :left 36px - - .avatar - :position absolute - :display inline .stream.show ul.comments