Module: RailsTheme::Bootstrap::TabHelper

Defined in:
app/helpers/rails_theme/bootstrap/tab_helper.rb

Instance Method Summary collapse

Instance Method Details



14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/rails_theme/bootstrap/tab_helper.rb', line 14

def link_to_remote_tab 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


4
5
6
7
8
9
10
11
12
# File 'app/helpers/rails_theme/bootstrap/tab_helper.rb', line 4

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


26
27
28
29
30
# File 'app/helpers/rails_theme/bootstrap/tab_helper.rb', line 26

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

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



41
42
43
44
45
# File 'app/helpers/rails_theme/bootstrap/tab_helper.rb', line 41

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

#remote_tab_pane(url, tag_id, default) ⇒ Object



47
48
49
50
51
52
53
54
# File 'app/helpers/rails_theme/bootstrap/tab_helper.rb', line 47

def 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

#tab_pane(tag_id, default) ⇒ Object



32
33
34
35
36
37
38
39
# File 'app/helpers/rails_theme/bootstrap/tab_helper.rb', line 32

def 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