aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/dropdown
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-09-09 22:17:34 +0200
committerRobert Jaros <rjaros@finn.pl>2017-09-09 22:17:34 +0200
commit037c9c22bfe23064b2e110225261a26247649967 (patch)
tree53ab791f98500a9921372c027cef6db02c48aff5 /src/main/kotlin/pl/treksoft/kvision/dropdown
parent85b48891c61c604c952c8739b50bdae2998c44a7 (diff)
downloadkvision-037c9c22bfe23064b2e110225261a26247649967.tar.gz
kvision-037c9c22bfe23064b2e110225261a26247649967.tar.bz2
kvision-037c9c22bfe23064b2e110225261a26247649967.zip
Integrate jQuery mappings
Globally disabled Data API Added support for dropdown events
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/dropdown')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 18946b27..d33b53d9 100644
--- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -1,5 +1,7 @@
package pl.treksoft.kvision.dropdown
+import com.github.snabbdom.VNode
+import org.w3c.dom.CustomEvent
import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.ResString
import pl.treksoft.kvision.html.BUTTONSIZE
@@ -11,6 +13,7 @@ import pl.treksoft.kvision.html.ListTag
import pl.treksoft.kvision.html.TAG
import pl.treksoft.kvision.html.Tag
import pl.treksoft.kvision.snabbdom.StringPair
+import pl.treksoft.kvision.snabbdom.obj
enum class DD(val POS: String) {
HEADER("DD#HEADER"),
@@ -45,6 +48,12 @@ open class DropDown(text: String, elements: List<StringPair>, icon: String? = nu
else -> Link(it.first, it.second)
}
}
+ button.setEventListener {
+ click = {
+ list.getElementJQueryD().dropdown("toggle")
+ }
+ }
+
list.addAll(children)
this.add(button)
this.add(list)
@@ -54,6 +63,29 @@ open class DropDown(text: String, elements: List<StringPair>, icon: String? = nu
companion object {
var counter = 0
}
+
+ override fun afterInsert(node: VNode) {
+ this.getElementJQuery()?.on("show.bs.dropdown", { e, _ ->
+ val event = CustomEvent("showBsDropdown", obj({ detail = button }))
+ this.getElement()?.dispatchEvent(event) as Any
+ })
+ this.getElementJQuery()?.on("shown.bs.dropdown", { e, _ ->
+ val event = CustomEvent("shownBsDropdown", obj({ detail = button }))
+ this.getElement()?.dispatchEvent(event) as Any
+ })
+ this.getElementJQuery()?.on("hide.bs.dropdown", { e, _ ->
+ val event = CustomEvent("hideBsDropdown", obj({ detail = button }))
+ this.getElement()?.dispatchEvent(event) as Any
+ })
+ this.getElementJQuery()?.on("hidden.bs.dropdown", { e, _ ->
+ val event = CustomEvent("hiddenBsDropdown", obj({ detail = button }))
+ this.getElement()?.dispatchEvent(event) as Any
+ })
+ }
+
+ open fun toggle() {
+ list.getElementJQueryD().dropdown("toggle")
+ }
}
open class DropDownButton(id: String, text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT,