Module: Golden::Theme::Bootstrap::TabHelper

Defined in:
lib/golden/theme/bootstrap/tab_helper.rb

Instance Method Summary collapse

Instance Method Details



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/golden/theme/bootstrap/tab_helper.rb', line 28

def bootstrap_remote_tab_link_to text, url, tab_pane_id, options = {}
  options = {
    remote: true,
    data: {
      toggle: 'tab',
      target: tab_pane_id,
      type: 'html'
    }
  }.deep_merge options
  link_to text, url, options
end

#bootstrap_remote_tab_nav(text, url, tag_id, default) ⇒ Object



40
41
42
43
44
# File 'lib/golden/theme/bootstrap/tab_helper.rb', line 40

def bootstrap_remote_tab_nav text, url, tag_id, default
  active = current_page?(url) || tag_id == default
  li_class = 'active' if active
  [ bootstrap_remote_tab_link_to(text, url, "##{tag_id}"), { class: li_class } ]
end

#bootstrap_remote_tab_pane(url, tag_id, default) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/golden/theme/bootstrap/tab_helper.rb', line 46

def bootstrap_remote_tab_pane url, tag_id, default
  active = current_page?(url) || tag_id == default
  tab_class = 'tab-pane fade'
  tab_class << ' active in' if active
   :div, class: tab_class, id: tag_id do
    yield active if block_given?
  end
end


3
4
5
6
7
8
9
10
11
# File 'lib/golden/theme/bootstrap/tab_helper.rb', line 3

def bootstrap_tab_link_to text, tab_pane_id, options = {}
  options = {
    data: {
      toggle: 'tab',
      target: tab_pane_id
    }
  }.deep_merge options
  link_to text, tab_pane_id, options
end

#bootstrap_tab_nav(text, tag_id, default) ⇒ Object



13
14
15
16
17
# File 'lib/golden/theme/bootstrap/tab_helper.rb', line 13

def bootstrap_tab_nav text, tag_id, default
  active = tag_id == default
  li_class = 'active' if active
  [ bootstrap_tab_link_to(text, "##{tag_id}"), { class: li_class } ]
end

#bootstrap_tab_pane(tag_id, default) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/golden/theme/bootstrap/tab_helper.rb', line 19

def bootstrap_tab_pane tag_id, default
  active = tag_id == default
  tab_class = 'tab-pane fade'
  tab_class << ' active in' if active
   :div, class: tab_class, id: tag_id do
    yield active if block_given?
  end
end