Sha256: 4e263c55eb805f848c3cf621426cdeea30c727ce96880617f49de8a2679f8ce6

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require_relative 'tab_builder'

# Helpers that control center uses
module ControlCenter
  module Helpers
    module LayoutHelper
  
      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
        if block_given?
          @sidebar_set = true
          content_for :sidebar do
            yield
          end
        end
      end
  
      def sidebar?
        @sidebar_set ||= false
      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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
control_center-1.0.2 lib/control_center/helpers/layout_helper.rb
control_center-1.0.1 lib/control_center/helpers/layout_helper.rb