summaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-01-28 13:55:54 +0100
committerRobert Jaros <rjaros@finn.pl>2018-01-28 13:55:54 +0100
commitc8922a145826834a0be8059cb5b8c6fd5da593dd (patch)
tree2c88740971796734cabec2641f10c17826860aae /src/main/kotlin/pl/treksoft/kvision
parent9f1bc01e0e42a92cdfc483037df89ca28069abdd (diff)
downloadkvision-c8922a145826834a0be8059cb5b8c6fd5da593dd.tar.gz
kvision-c8922a145826834a0be8059cb5b8c6fd5da593dd.tar.bz2
kvision-c8922a145826834a0be8059cb5b8c6fd5da593dd.zip
More stable DropDown implementation
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 53d722b1..80329d92 100644
--- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -2,6 +2,7 @@ package pl.treksoft.kvision.dropdown
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.Component
+import pl.treksoft.kvision.core.CssSize
import pl.treksoft.kvision.html.BUTTONSTYLE
import pl.treksoft.kvision.html.Button
import pl.treksoft.kvision.html.LIST
@@ -71,6 +72,12 @@ open class DropDown(
field = value
refresh()
}
+ override var width: CssSize?
+ get() = super.width
+ set(value) {
+ super.width = value
+ button.width = value
+ }
private val idc = "kv_dropdown_" + counter
internal val button: DropDownButton = DropDownButton(
@@ -80,7 +87,6 @@ open class DropDown(
internal val list: DropDownListTag = DropDownListTag(idc, setOf("dropdown-menu"))
init {
- list.hide()
setChildrenFromElements()
this.addInternal(button)
this.addInternal(list)
@@ -142,7 +148,6 @@ open class DropDown(
@Suppress("UnsafeCastFromDynamic")
override fun afterInsert(node: VNode) {
this.getElementJQuery()?.on("show.bs.dropdown", { e, _ ->
- if (!list.visible) list.visible = true
this.dispatchEvent("showBsDropdown", obj { detail = e })
})
this.getElementJQuery()?.on("shown.bs.dropdown", { e, _ ->
@@ -152,7 +157,6 @@ open class DropDown(
this.dispatchEvent("hideBsDropdown", obj { detail = e })
})
this.getElementJQuery()?.on("hidden.bs.dropdown", { e, _ ->
- if (list.visible) list.visible = false
this.dispatchEvent("hiddenBsDropdown", obj { detail = e })
})
}
@@ -167,12 +171,7 @@ open class DropDown(
}
open fun toggle() {
- if (this.list.visible) {
- this.list.getElementJQueryD()?.dropdown("toggle")
- } else {
- this.list.visible = true
- window.setTimeout({ this.list.getElementJQueryD()?.dropdown("toggle") }, 0)
- }
+ this.list.getElementJQueryD()?.dropdown("toggle")
}
}