X-Git-Url: http://nitlanguage.org?ds=sidebyside
diff --git a/src/doc/html_templates/html_components.nit b/src/doc/html_templates/html_components.nit
index 221162b..630d28e 100644
--- a/src/doc/html_templates/html_components.nit
+++ b/src/doc/html_templates/html_components.nit
@@ -36,6 +36,120 @@ class DocHTMLLabel
end
end
+# A component that display tabbed data.
+class DocTabs
+ super BSComponent
+
+ # HTML id of this component.
+ var html_id: String
+
+ # Text displayed on the tabs dropdown button.
+ var drop_text: String
+
+ # Panels to display in this tab group.
+ var panels = new Array[DocTabPanel]
+
+ # Droplist containing links to panels.
+ #
+ # Can also be used to add external links.
+ var drop_list: DocTabsDrop is lazy do return new DocTabsDrop(html_id, drop_text)
+
+ # Adds a new `panel` to that tab.
+ #
+ # You should always use this instead of `panels.add` because it also set the
+ # `drop_list` entry.
+ fun add_panel(panel: DocTabPanel) do
+ drop_list.add_li panel.render_tab
+ panels.add panel
+ end
+
+ redef fun rendering do
+ if panels.is_empty then return
+ panels.first.is_active = true
+ add "
"
+ if drop_list.items.length > 1 then add drop_list
+ add "
"
+ for panel in panels do
+ add panel
+ end
+ add "
"
+ add "
"
+ end
+end
+
+# A list of tab regrouped in a dropdown
+class DocTabsDrop
+ super UnorderedList
+
+ # HTML id used by the tabs group.
+ var html_id: String
+
+ # Title to display in the tab item.
+ var html_title: String
+
+ redef fun rendering do
+ add """"
+ end
+end
+
+# A panel that goes in a DocTabs.
+class DocTabPanel
+ super BSComponent
+
+ # HTML id of this panel.
+ var html_id: String
+
+ # Title of this panel as displayed in the tab label.
+ var tab_title: String
+
+ # HTML content of this panel.
+ var html_content: Writable is writable
+
+ # Is this panel visible by default?
+ var is_active = false
+
+ redef fun rendering do
+ var active = ""
+ if is_active then active = "active in"
+ add ""
+ add html_content
+ add "
"
+ end
+
+ private fun render_tab: DocTabItem do return new DocTabItem(tab_title, html_id)
+end
+
+# A ListItem that goes in a DocTabsDrop.
+private class DocTabItem
+ super ListItem
+
+ # Panel id to trigger when the link is clicked.
+ var target_id: String
+
+ redef fun rendering do
+ add ""
+ add " "
+ add text
+ add " "
+ add ""
+ end
+end
+
# A HTML tag attribute
# ``
#