aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-10-28 23:45:26 +0200
committerRobert Jaros <rjaros@finn.pl>2017-10-28 23:45:26 +0200
commit06f297d68887c7934e66d2c757abc8bf619df66a (patch)
treea828eec09f0bdc99b0f3fd45972b8cead37fbdec /src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
parent6b13b8909a302b0f0f2155b81b83cd5ab4d7a046 (diff)
downloadkvision-06f297d68887c7934e66d2c757abc8bf619df66a.tar.gz
kvision-06f297d68887c7934e66d2c757abc8bf619df66a.tar.bz2
kvision-06f297d68887c7934e66d2c757abc8bf619df66a.zip
Databinding components
Event handlers refactoring
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
index 817ecaa0..4190dbae 100644
--- a/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt
@@ -1,15 +1,12 @@
package pl.treksoft.kvision.panel
-import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.ResString
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.html.Link
import pl.treksoft.kvision.html.TAG
import pl.treksoft.kvision.html.Tag
-open class TabPanel : Container(setOf()) {
- private var nav = Tag(TAG.UL, classes = setOf("nav", "nav-tabs"))
- private var content = StackPanel(false)
+open class TabPanel : SimplePanel(setOf()) {
var activeIndex
get() = content.activeIndex
set(value) {
@@ -20,9 +17,12 @@ open class TabPanel : Container(setOf()) {
}
}
+ private var nav = Tag(TAG.UL, classes = setOf("nav", "nav-tabs"))
+ private var content = StackPanel(false)
+
init {
- this.add(nav)
- this.add(content)
+ this.addInternal(nav)
+ this.addInternal(content)
}
open fun addTab(title: String, panel: Widget, icon: String? = null,
@@ -52,4 +52,25 @@ open class TabPanel : Container(setOf()) {
activeIndex = content.activeIndex
return this
}
+
+ override fun add(child: Widget): TabPanel {
+ return addTab("", child)
+ }
+
+ override fun addAll(children: List<Widget>): TabPanel {
+ children.forEach { add(it) }
+ return this
+ }
+
+ override fun remove(child: Widget): TabPanel {
+ val index = content.children.indexOf(child)
+ return removeTab(index)
+ }
+
+ override fun removeAll(): TabPanel {
+ content.removeAll()
+ nav.removeAll()
+ refresh()
+ return this
+ }
}