aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-09-03 03:23:34 +0200
committerRobert Jaros <rjaros@finn.pl>2017-09-03 03:23:34 +0200
commit70bc6412e0b54119d3f0b6a82c1def78a9088d16 (patch)
tree5df87cf5b18ac4623116851f55bd5244a50a3191 /src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
parentc056275c522db3f2f391ce44a405da0cedae60ca (diff)
downloadkvision-70bc6412e0b54119d3f0b6a82c1def78a9088d16.tar.gz
kvision-70bc6412e0b54119d3f0b6a82c1def78a9088d16.tar.bz2
kvision-70bc6412e0b54119d3f0b6a82c1def78a9088d16.zip
DropDown attributes
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 1a3f63c9..7176f725 100644
--- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -5,15 +5,36 @@ import pl.treksoft.kvision.core.ResString
import pl.treksoft.kvision.html.*
import pl.treksoft.kvision.snabbdom.StringPair
+enum class DD(val POS: String) {
+ HEADER("DD#HEADER"),
+ DISABLED("DD#DISABLED"),
+ SEPARATOR("DD#SEPARATOR")
+}
+
open class DropDown(text: String, elements: List<StringPair>, icon: String? = null, style: BUTTON_STYLE = BUTTON_STYLE.DEFAULT, size: BUTTON_SIZE? = null,
- block: Boolean = false, disabled: Boolean = false, image: ResString? = null, classes: Set<String> = setOf()) : Container(classes) {
+ block: Boolean = false, disabled: Boolean = false, image: ResString? = null, dropup: Boolean = false, classes: Set<String> = setOf()) : Container(classes) {
val idc = "kv_dropdown_" + counter
val button: DropDownButton = DropDownButton(idc, text, icon, style, size, block, disabled, image, setOf("dropdown"))
val list: DropDownListTag = DropDownListTag(idc, setOf("dropdown-menu"))
init {
- this.addCssClass("dropdown")
- val children = elements.map { Link(it.first, it.second) }
+ this.addCssClass(if (dropup) "dropup" else "dropdown")
+ val children = elements.map {
+ when (it.second) {
+ DD.HEADER.POS -> Tag(TAG.LI, it.first, classes = setOf("dropdown-header"))
+ DD.SEPARATOR.POS -> {
+ val tag = Tag(TAG.LI, classes = setOf("divider"))
+ tag.role = "separator"
+ tag
+ }
+ DD.DISABLED.POS -> {
+ val tag = Tag(TAG.LI, classes = setOf("disabled"))
+ tag.add(Link(it.first, "#"))
+ tag
+ }
+ else -> Link(it.first, it.second)
+ }
+ }
list.addAll(children)
this.add(button)
this.add(list)