Module: ToolbarHelper

Includes:
SocialStream::ToolbarConfig
Defined in:
app/helpers/toolbar_helper.rb

Instance Method Summary collapse

Instance Method Details

#home_toolbar_menuObject

Prints the home toolbar menu.



90
91
92
# File 'app/helpers/toolbar_helper.rb', line 90

def home_toolbar_menu
  render_items home_toolbar_items
end

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 menu_options #:nodoc:
  @menu_options ||= {}
end

#messages_toolbar_menuObject

Prints the messages toolbar menu.



100
101
102
# File 'app/helpers/toolbar_helper.rb', line 100

def messages_toolbar_menu
  render_items messages_toolbar_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 profile_toolbar_menu(subject=current_subject)
  render_items profile_toolbar_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)
  menu = render_navigation :items => items
  return raw menu
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 toolbar(options = {}, &block)
  if options[:option] && block_given?
    menu_options[options[:option]] = capture(&block)
  end

  content = capture do
    if options[:profile]
      render :partial => 'toolbar/profile', :locals => { :subject => options[:profile] }
    elsif options[:option].present? and options[: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('#{ options[:option] }');
        EOJ

    response.html_safe
  else
  content_for(:toolbar) do
  content
  end
  content_for(:javascript) do
  <<-EOJ
  expandSubMenu('#{ options[:option] }');
  EOJ
  end
  end
end