Sha256: 928fcb9477d5007ddb03111529279f61a52d382a1eae826c21b90bf8557f9544

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'tab_builder'

# Helpers that control center uses
module ControlCenter::Helpers
  
  def title(title)
    @control_center_title = title
  end
  
  def select_tab(tab)
    @cc_current_tab = tab
  end
  def current_tab
    @cc_current_tab
  end
  
  def sub_tabs
    if block_given?
      content_for :sub_tabs do
        yield
      end
    end
  end
  
  def select_sub_tab(tab)
    @cc_current_sub_tab = tab
  end
  def current_sub_tab
    @cc_current_sub_tab
  end
  
  # Sets up a sidebar in control center.
  def sidebar(&block)
    if block_given?
      @sidebar_set = true
      content_for :sidebar do
        yield
      end
    end
  end
  
  def sidebar?
    @sidebar_set ||= false
    @sidebar_set
  end
  
  def tab(tab_name, tab_url)
    options = {}
    options[:class] = "active" if  current_tab == tab_name
    content_tag "li", options, true do
      link_to tab_name, tab_url
    end
  end
  
  def sub_tab(tab_name, tab_url)
    options = {}
    options[:class] = "active" if  current_sub_tab == tab_name
    content_tag "li", options, true do
      link_to tab_name, tab_url
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
commondream-control_center-0.99.1 lib/helpers.rb
commondream-control_center-0.99.2 lib/helpers.rb
commondream-control_center-1.0.0 lib/helpers.rb