21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/bootstrap_builders/tabs.rb', line 21
def to_html
set_default_first_active
container = HtmlGen::Element.new(:div, classes: ["bb-tabs-container"])
ul = container.add_ele(:ul, classes: nav_classes)
container.add_ele(:div, classes: ["clearfix"])
@tabs.each do |tab|
li = ul.add_ele(:li, attr: {class: "nav-item"}, data: {specific_id_given: tab.specific_id_given?, tab_container_id: tab.container_id})
link = li.add_ele(:a, str: tab.label, attr: {class: "nav-link", href: "##{tab.container_id}"}, data: {toggle: "tab"})
if tab.active?
link.classes << "show"
link.classes << "active"
end
li.data[:ajax_url] = tab.ajax_url if tab.ajax_url.present?
end
tabs_content = container.add_ele(:div, classes: ["tab-content"])
@tabs.each do |tab|
tab_content = tabs_content.add_ele(:div, classes: ["tab-pane"], attr: {id: tab.container_id})
tab_content.add_html(tab.container_html)
tab_content.classes << "active" if tab.active?
end
container.html
end
|