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.
-
#profile_toolbar_menu(subject = current_subject) ⇒ Object
Prints the home profile menu.
-
#render_items(items) ⇒ Object
Renders array of navigation items with simple_navigation.
-
#toolbar(options = {}, &block) ⇒ Object
Define the toolbar content for your view.
Methods included from SocialStream::ToolbarConfig
#default_home_toolbar_menu, #default_profile_toolbar_menu
Instance Method Details
#home_toolbar_menu ⇒ Object
Prints the home toolbar menu.
84 85 86 |
# File 'app/helpers/toolbar_helper.rb', line 84 def 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
79 80 81 |
# File 'app/helpers/toolbar_helper.rb', line 79 def #:nodoc: ||= {} end |
#profile_toolbar_menu(subject = current_subject) ⇒ Object
Prints the home profile menu.
89 90 91 |
# File 'app/helpers/toolbar_helper.rb', line 89 def (subject=current_subject) (subject) end |
#render_items(items) ⇒ Object
Renders array of navigation items with simple_navigation
95 96 97 98 |
# File 'app/helpers/toolbar_helper.rb', line 95 def render_items(items) = :items => items return raw end |
#toolbar(options = {}, &block) ⇒ Object
Define the toolbar content for your view. There are two typical cases, depending on the value of options
-
If present, render the profile menu for the subject
-
If blank, render the home menu
The menu option allows overwriting a menu slot with the content of the given block
Autoexpanding a menu section on your view:
Toolbar allows you to autoexpand certain menu section that may be of interest for your view. For example, the messages menu when you are looking your inbox. This is done through :option element.
To get it working, you should use the proper :option to be expanded, “:option => :messages” in the mentioned example. This will try, automatically, to expand the section of the menu where its root 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 %>
41 42 43 44 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 |
# File 'app/helpers/toolbar_helper.rb', line 41 def ( = {}, &block) if [:option] && block_given? [[:option]] = capture(&block) end content = capture do if [:profile] render :partial => 'toolbar/profile', :locals => { :subject => [:profile] } else render :partial => 'toolbar/home' end end case request.format when Mime::JS response = "\n $('#toolbar').html(\"\#{ escape_javascript(content) }\");\n initMenu();\n expandSubMenu('\#{ options[:option] }');\n EOJ\n\n response.html_safe\n else\n content_for(:toolbar) do\n content\n end\n content_for(:javascript) do\n <<-EOJ\n expandSubMenu('\#{ options[:option] }');\n EOJ\n end\n end\nend\n" |