- add "</a>"
- end
-end
-
-# A <ul> list
-class TplList
- super TplListElt
-
- # Elements contained in this list
- # can be <li> or <ul> elements
- var elts = new Array[TplListElt]
-
- # CSS classes of the <ul> element
- var css_classes = new Array[String]
-
- # Add content wrapped in a <li> element
- fun add_li(item: TplListItem) do elts.add item
-
- init with_classes(classes: Array[String]) do self.css_classes = classes
-
- fun is_empty: Bool do return elts.is_empty
-
- redef fun rendering do
- if elts.is_empty then return
- addn "<ul class='{css_classes.join(" ")}'>"
- for elt in elts do add elt
- addn "</ul>"
- end
-end
-
-# Something that can be added to a TplList
-class TplListElt
- super Template
-end
-
-# A list item <li>
-class TplListItem
- super TplListElt
-
- # Content of the list item
- var content = new Template
-
- # CSS classes of the <li> element
- var css_classes = new Array[String]
-
- init with_content(content: Writable) do append(content)
-
- init with_classes(content: Writable, classes: Array[String]) do
- with_content(content)
- css_classes = classes
- end
-
- # Append `content` to the item
- # similar to `self.content.add`
- fun append(content: Writable) do self.content.add content
-
- redef fun rendering do
- add "<li class='{css_classes.join(" ")}'>"
- add content
- addn "</li>"
- end
-end
-
-# A Bootstrap tab component that contains `TplTabPanel`.
-class TplTab
- super Template
-
- # Panels contained in the tab.
- var panels = new Array[TplTabPanel]
-
- # Add a new panel.
- fun add_panel(panel: TplTabPanel) do panels.add panel
-
- # CSS classes of the tab component.
- var css_classes = new Array[String]
-
- redef fun rendering do
- addn "<div class='tab-content'>"
- for panel in panels do add panel
- addn "</div>"
- end
-end
-
-# A panel that goes in a `TplTab`.
-class TplTabPanel
- super Template
-
- # CSS classes of the pane element.
- var css_classes = new Array[String]
-
- # The panel id.
- #
- # Used to show/hide panel.
- var id: String is noinit
-
- # The panel name.
- #
- # Displayed in the tab header or in the pointing link.
- var name: Writable
-
- # Is the panel visible by default?
- var is_active = false is writable
-
- # Body of the panel
- var content: nullable Writable = null is writable
-
- # Get a link pointing to this panel.
- fun tpl_link_to: Writable do
- var lnk = new Template
- lnk.add "<a data-target='#{id}' data-toggle='pill'>"
- lnk.add name
- lnk.add "</a>"
- return lnk
- end
-
- redef fun rendering do
- add "<div class='tab-pane {css_classes.join(" ")}"
- if is_active then add "active"
- addn "' id='{id}'>"
- if content != null then add content.as(not null)
- addn "</div>"
- end
-end
-
-# A label with a text content
-class TplLabel
- super Template
-
- # Content of the label if any
- var content: nullable Writable = null is writable
-
- # CSS classes of the <span> element
- var css_classes = new Array[String]
-
- init with_content(content: Writable) do self.content = content
- init with_classes(classes: Array[String]) do self.css_classes = classes
-
- redef fun rendering do
- add "<span class='label {css_classes.join(" ")}'>"
- if content != null then add content.as(not null)
- add "</span>"
- end
-end
-
-# A label with an icon
-class TplIcon
- super TplLabel
-
- # Bootsrap icon name
- # see: http://getbootstrap.com/components/#glyphicons
- var icon: String
-
- init with_icon(icon: String) do self.icon = icon
-
- redef fun rendering do
- add "<span class='glyphicon glyphicon-{icon} {css_classes.join(" ")}'>"
- if content != null then add content.as(not null)
- add "</span>"