diff --git a/app/helpers/comment_helper.rb b/app/helpers/comment_helper.rb index e6095a7..5156256 100644 --- a/app/helpers/comment_helper.rb +++ b/app/helpers/comment_helper.rb @@ -25,7 +25,10 @@ module CommentHelper def comment_actions(comment) url = url_for(:profile => profile.identifier, :controller => :comment, :action => :check_actions, :id => comment.id) links = links_for_comment_actions(comment) - content_tag(:li, link_to(content_tag(:span, _('Contents menu')), '#', :onclick => "toggleSubmenu(this,'',#{links.to_json}); return false", :class => 'menu-submenu-trigger comment-trigger', :url => url), :class=> 'vcard') unless links.empty? + links_submenu = links.select{|link| link[:action_bar].nil? || !link[:action_bar]} + links_action_bar = links - links_submenu + links_submenu = links_submenu.collect {|link| link.slice(:link)} + render :partial => 'comment/comment_actions', :locals => {:links_submenu => links_submenu, :links_action_bar => links_action_bar, :url => url, :comment => comment} end private diff --git a/app/views/comment/_comment.rhtml b/app/views/comment/_comment.rhtml index e7fb23b..1da1081 100644 --- a/app/views/comment/_comment.rhtml +++ b/app/views/comment/_comment.rhtml @@ -32,19 +32,7 @@
- - <% unless comment.spam? %> - <%= link_to_function '', - "var f = add_comment_reply_form(this, %s); f.find('comment_title, textarea').val(''); return false" % comment.id, - :class => 'comment-footer comment-footer-link comment-footer-hide comment-actions-reply button', - :id => 'comment-reply-to-' + comment.id.to_s, - :title => _('Reply') - %> - <% end %> + <%= comment_actions(comment) %>
diff --git a/app/views/comment/_comment_actions.rhtml b/app/views/comment/_comment_actions.rhtml new file mode 100644 index 0000000..ae04c88 --- /dev/null +++ b/app/views/comment/_comment_actions.rhtml @@ -0,0 +1,21 @@ + +
+ <% unless comment.spam? %> + <%= link_to_function '', + "var f = add_comment_reply_form(this, %s); f.find('comment_title, textarea').val(''); return false" % comment.id, + :class => 'comment-footer comment-footer-link comment-footer-hide comment-actions-reply button', + :id => 'comment-reply-to-' + comment.id.to_s + %> + <% end %> + <% links_action_bar.collect do |link| %> + <%= link[:link] %> + <% end %> +
diff --git a/test/unit/comment_helper_test.rb b/test/unit/comment_helper_test.rb index 479c7f7..c9cce31 100644 --- a/test/unit/comment_helper_test.rb +++ b/test/unit/comment_helper_test.rb @@ -21,14 +21,14 @@ class CommentHelperTest < ActiveSupport::TestCase article = Article.new(:profile => profile) comment = Comment.new(:article => article) menu = comment_actions(comment) - assert menu + assert_match /class=\"comment-actions\"/, menu end should 'do not show menu if it has no actions' do comment = Comment.new self.stubs(:links_for_comment_actions).returns([]) menu = comment_actions(comment) - assert !menu + assert_no_match /class=\"comment-actions\"/, menu end should 'do not show menu if it has nil actions only' do @@ -38,7 +38,7 @@ class CommentHelperTest < ActiveSupport::TestCase self.stubs(:link_for_edit).returns(nil) self.stubs(:link_for_remove).returns(nil) menu = comment_actions(comment) - assert !menu + assert_no_match /class=\"comment-actions\"/, menu end should 'include actions of plugins in menu' do @@ -131,6 +131,14 @@ class CommentHelperTest < ActiveSupport::TestCase assert link end + should 'include actions of plugins in action bar' do + comment = Comment.new + plugin_action = {:link => 'plugin_action', :action_bar => true} + @plugins.stubs(:dispatch).returns([plugin_action]) + html = comment_actions(comment) + assert_match /plugin_action/, Hpricot(html).search('.comments-action-bar').html + end + def link_to_function(content, url, options = {}) link_to(content, url, options) end -- libgit2 0.21.2