diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-10-28 23:45:26 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-10-28 23:45:26 +0200 |
commit | 06f297d68887c7934e66d2c757abc8bf619df66a (patch) | |
tree | a828eec09f0bdc99b0f3fd45972b8cead37fbdec /src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt | |
parent | 6b13b8909a302b0f0f2155b81b83cd5ab4d7a046 (diff) | |
download | kvision-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.kt | 33 |
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 + } } |