Module: ToolbarHelper
- Includes:
- SocialStream::ToolbarConfig
- Defined in:
- app/helpers/toolbar_helper.rb
Instance Method Summary collapse
-
#home_toolbar_menu ⇒ Object
Prints the home toolbar menu.
-
#menu_options ⇒ Object
private
Cache menu options for toolbar.
-
#messages_toolbar_menu ⇒ Object
Prints the messages toolbar menu.
-
#profile_toolbar_menu(subject = current_subject) ⇒ Object
Prints the profile toolbar menu.
-
#render_items(items) ⇒ Object
Renders array of navigation items with simple_navigation.
-
#toolbar(options = {}, &block) ⇒ Object
list link, the one expanding the section, has an id equal to “#messages_menu”.
Instance Method Details
#home_toolbar_menu ⇒ Object
Prints the home toolbar menu.
90 91 92 |
# File 'app/helpers/toolbar_helper.rb', line 90 def render_items end |
#menu_options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Cache menu options for toolbar
85 86 87 |
# File 'app/helpers/toolbar_helper.rb', line 85 def #:nodoc: @menu_options ||= {} end |
#messages_toolbar_menu ⇒ Object
Prints the messages toolbar menu.
100 101 102 |
# File 'app/helpers/toolbar_helper.rb', line 100 def render_items end |
#profile_toolbar_menu(subject = current_subject) ⇒ Object
Prints the profile toolbar menu.
95 96 97 |
# File 'app/helpers/toolbar_helper.rb', line 95 def (subject=current_subject) render_items (subject) end |
#render_items(items) ⇒ Object
Renders array of navigation items with simple_navigation
105 106 107 108 |
# File 'app/helpers/toolbar_helper.rb', line 105 def render_items(items) = :items => items return raw end |
#toolbar(options = {}, &block) ⇒ Object
list link, the one expanding the section, has an id equal to “#messages_menu”. If you use “:options => :contacts” it will try to expand “#contacts_menu”.
For now its working with :option => :messages, :contacts or :groups
Examples:
Render the home toolbar:
<% toolbar %>
Render the profile toolbar for a user:
<% toolbar :profile => @user %>
Render the home toolbar changing the messages menu option:
<% toolbar :option => :messages %>
Render the profile toolbar for group changing the contacts menu option:
<% toolbar :profile => @group, :option => :contacts %>
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'app/helpers/toolbar_helper.rb', line 45 def ( = {}, &block) if [:option] && block_given? [[:option]] = capture(&block) end content = capture do if [:profile] render :partial => 'toolbar/profile', :locals => { :subject => [:profile] } elsif [:option].present? and [:option].to_s.eql? 'messages' render :partial => 'toolbar/messages' else render :partial => 'toolbar/home' end end case request.format when Mime::JS response = <<-EOJ $('#toolbarContent').html("#{ escape_javascript(content) }"); initMenu(); expandSubMenu('#{ [:option] }'); EOJ response.html_safe else content_for(:toolbar) do content end content_for(:javascript) do <<-EOJ expandSubMenu('#{ [:option] }'); EOJ end end end |