class TabsHelper::Tabs

Attributes

controller[RW]

Public Class Methods

new(controller) click to toggle source
# File app/helpers/tabs_helper.rb, line 15
def initialize(controller)
  self.controller = controller
  @tabs = []
end

Public Instance Methods

_routes() click to toggle source

FIXME

# File app/helpers/tabs_helper.rb, line 95
def _routes
  self.controller._routes
end
add(name, options = {}, html_options = {}, &block) click to toggle source
# File app/helpers/tabs_helper.rb, line 20
def add(name, options = {}, html_options = {}, &block)
  _html_options = { :onmouseover => "hover(this)", :onmouseout => "hoverOut(this)" }
  _html_options.merge!(html_options) if html_options
  @tabs << Tab.new(name, options, _html_options)
end
request() click to toggle source
# File app/helpers/tabs_helper.rb, line 99
def request
  self.controller.request
end
select(name) click to toggle source

Show tab named name as selected

# File app/helpers/tabs_helper.rb, line 27
def select(name)
  @selected_name = name
end
to_html(select_current_page = true) click to toggle source

Builder escapes text, which is not what we want

# File app/helpers/tabs_helper.rb, line 32
    def to_html(select_current_page = true)
      table_class = "tabs"
      table_class = "tabs_solo" if @tabs.size < 2
      html = "    <table class="#{table_class} centered">
      <tr>
"
      @tabs.each_with_index do |tab, index|
        if index == 0
          if select_current_page && current_page?(tab.options)
            html << "      <td class=\"first_selected\"><div class=\"first_selected\"><span>"
          else
            html << "      <td class=\"first\"><div class=\"first\"><span>"
          end
          if select_current_page
            html << link_to_unless_current(tab.name, tab.options, tab.html_options).to_s
          else
            html << link_to(tab.name, tab.options, tab.html_options).to_s
          end
          html << "</span></div>"
          if @tabs.size < 2
            if select_current_page && current_page?(tab.options)
              html << "</td>\n      <td class=\"last_selected\"><div class=\"last_selected\">"
              html << "<span>&nbsp;</span></div>"
            else
              html << "</td>\n      <td class=\"last\"><div class=\"last\"><span>&nbsp;</span></div>"
            end
          end
        elsif index == @tabs.size - 1
          if select_current_page && current_page?(tab.options)
            html << "      <td class=\"last_selected\"><div class=\"last_selected\"><span>"
          else
            html << "      <td class=\"last\"><div class=\"last\"><span>"
          end
          if select_current_page
            html << link_to_unless_current(tab.name, tab.options, tab.html_options).to_s
          else
            html << link_to(tab.name, tab.options, tab.html_options).to_s
          end
          html << "</span></div>"
        else
          if select_current_page && current_page?(tab.options)
            html << "      <td class=\"selected\"><div class=\"selected\"><span>"
          else
            html << "      <td><div><span>"
          end
          if select_current_page
            html << link_to_unless_current(tab.name, tab.options, tab.html_options).to_s
          else
            html << link_to(tab.name, tab.options, tab.html_options).to_s
          end
          html << "</span></div>"
        end
        html << "</td>\n"
      end
      end_html = "      </tr>
    </table>
"
      html << end_html
    end