From 67a7dc468942e21f3de6dd4545cf00121399ed43 Mon Sep 17 00:00:00 2001 From: Caio SBA Date: Tue, 21 Sep 2010 01:36:41 -0300 Subject: [PATCH] Unify code for generating speech bubbles (ActionItem1696) --- app/helpers/application_helper.rb | 7 +++++++ app/views/content_viewer/_comment.rhtml | 26 +++++++++----------------- app/views/profile/_organization.rhtml | 2 +- app/views/profile/_person.rhtml | 9 +++++++++ app/views/profile/_profile_scrap.rhtml | 14 +++++++------- public/designs/icons/tango/style.css | 2 +- public/stylesheets/application.css | 59 +++++++++++++++++++++++++++++++++++++++++------------------ 7 files changed, 75 insertions(+), 44 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5585336..fbc6021 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1194,4 +1194,11 @@ module ApplicationHelper end end + def comment_balloon(options = {}, &block) + wrapper = content_tag(:div, capture(&block), :class => 'comment-balloon-content') + (1..8).to_a.reverse.each { |i| wrapper = content_tag(:div, wrapper, :class => "comment-wrapper-#{i}") } + classes = options.delete(:class) || options.delete("class") || '' + concat(content_tag('div', wrapper + tag('br', :style => 'clear: both;'), { :class => 'comment-balloon ' + classes.to_s }.merge(options)), block.binding) + end + end diff --git a/app/views/content_viewer/_comment.rhtml b/app/views/content_viewer/_comment.rhtml index f20bf0a..d2cfe1a 100644 --- a/app/views/content_viewer/_comment.rhtml +++ b/app/views/content_viewer/_comment.rhtml @@ -1,12 +1,6 @@ <%= content_tag('a', '', :name => comment.anchor) %>
- <% if logged_in? && (user == @page.profile || user == comment.author || user.has_permission?(:moderate_comments, @page.profile)) %> - <% button_bar(:style => 'float: right; margin-top: 0px;') do %> - <%= icon_button(:delete, _('Remove this comment'), { :profile => params[:profile], :remove_comment => comment.id, :view => params[:view] }, :method => :post, :confirm => _('Are you sure you want to remove this comment?')) %> - <% end %> - <% end %> - <% if comment.author %> <%= link_to content_tag( 'span', comment.author_name, :class => 'comment-info' ), comment.author.url, :class => 'comment-picture', @@ -21,14 +15,13 @@ %> <% end %> -
-
-
-
-
-
-
-
+ <% comment_balloon do %> + <% if logged_in? && (user == @page.profile || user == comment.author || user.has_permission?(:moderate_comments, @page.profile)) %> + <% button_bar(:style => 'float: right; margin-top: 0px;') do %> + <%= icon_button(:delete, _('Remove this comment'), { :profile => params[:profile], :remove_comment => comment.id, :view => params[:view] }, :method => :post, :confirm => _('Are you sure you want to remove this comment?')) %> + <% end %> + <% end %> +
<%= show_time(comment.created_at) %> @@ -39,7 +32,6 @@ <%= txt2html comment.body %>
-
-
-
+ <% end %> +
diff --git a/app/views/profile/_organization.rhtml b/app/views/profile/_organization.rhtml index e7773b7..0780922 100644 --- a/app/views/profile/_organization.rhtml +++ b/app/views/profile/_organization.rhtml @@ -4,7 +4,7 @@
diff --git a/app/views/profile/_person.rhtml b/app/views/profile/_person.rhtml index ddc8084..c012d97 100644 --- a/app/views/profile/_person.rhtml +++ b/app/views/profile/_person.rhtml @@ -22,6 +22,15 @@ <%= render :partial => 'profile_activity' %> <% end %> + +
diff --git a/app/views/profile/_profile_scrap.rhtml b/app/views/profile/_profile_scrap.rhtml index 8635228..9c9769b 100644 --- a/app/views/profile/_profile_scrap.rhtml +++ b/app/views/profile/_profile_scrap.rhtml @@ -5,7 +5,7 @@

<%= link_to_function _('Scrap'), "hide_and_show(['#profile-wall-message-response-#{scrap.id}'],['#profile-wall-message-#{scrap.id}', '#profile-wall-form-#{scrap.id}']);$('content_#{scrap.id}').value='';return false", :class => "profile-send-message icon-scrap" %>

<% end %> -
+ <% comment_balloon :class => 'profile-wall-description' do %>

<%= link_to scrap.sender.name, scrap.sender.url %>

<%= time_ago_as_sentence(scrap.created_at) + ' ' + _('ago') %>

<%= auto_link_urls scrap.content %>

@@ -13,12 +13,12 @@ <% if logged_in? && current_person.follows?(scrap.sender) && scrap.root.nil? %>

<%= link_to_function _('Reply'), "hide_and_show(['#profile-wall-reply-response-#{scrap.id}'],['#profile-wall-reply-#{scrap.id}', '#profile-wall-reply-form-#{scrap.id}']);$('reply_content_#{scrap.id}').value='';$('scrap_id_#{scrap.id}').value='#{scrap.id}';return false", :class => "profile-send-reply icon-reply" %>

<% end %> -
    - <% scrap.replies.map do |reply| %> - <%= render :partial => 'profile_scrap', :locals => {:scrap => reply} %> - <% end %> -
-
+ <% end %> +
    + <% scrap.replies.map do |reply| %> + <%= render :partial => 'profile_scrap', :locals => {:scrap => reply} %> + <% end %> +