aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules
diff options
context:
space:
mode:
Diffstat (limited to 'kvision-modules')
-rw-r--r--kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt13
-rw-r--r--kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt13
-rw-r--r--kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt3
-rw-r--r--kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt13
-rw-r--r--kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt3
-rw-r--r--kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt13
-rw-r--r--kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt3
-rw-r--r--kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt13
-rw-r--r--kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt3
9 files changed, 48 insertions, 29 deletions
diff --git a/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt b/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt
index fdf9f95a..4f3f3f48 100644
--- a/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt
+++ b/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt
@@ -217,15 +217,18 @@ open class DateTime(
}
@Suppress("UNCHECKED_CAST")
- override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Widget {
- input.setEventListener(block)
- return this
+ override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Int {
+ return input.setEventListener(block)
}
@Deprecated("Use onEvent extension function instead.", ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent"))
- override fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget {
+ override fun setEventListener(block: SnOn<Widget>.() -> Unit): Int {
@Suppress("DEPRECATION")
- input.setEventListener(block)
+ return input.setEventListener(block)
+ }
+
+ override fun removeEventListener(id: Int): Widget {
+ input.removeEventListener(id)
return this
}
diff --git a/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt b/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt
index 550de427..e2f84fff 100644
--- a/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt
+++ b/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemote.kt
@@ -187,15 +187,18 @@ open class SelectRemote<T : Any>(
}
@Suppress("UNCHECKED_CAST")
- override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Widget {
- input.setEventListener(block)
- return this
+ override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Int {
+ return input.setEventListener(block)
}
@Deprecated("Use onEvent extension function instead.", ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent"))
- override fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget {
+ override fun setEventListener(block: SnOn<Widget>.() -> Unit): Int {
@Suppress("DEPRECATION")
- input.setEventListener(block)
+ return input.setEventListener(block)
+ }
+
+ override fun removeEventListener(id: Int): Widget {
+ input.removeEventListener(id)
return this
}
diff --git a/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt b/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt
index 96277728..d6abc0f6 100644
--- a/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt
+++ b/kvision-modules/kvision-bootstrap-select-remote/src/main/kotlin/pl/treksoft/kvision/form/select/SelectRemoteInput.kt
@@ -29,6 +29,7 @@ import kotlinx.serialization.list
import kotlinx.serialization.stringify
import org.w3c.dom.get
import pl.treksoft.kvision.core.Container
+import pl.treksoft.kvision.core.onEvent
import pl.treksoft.kvision.remote.CallAgent
import pl.treksoft.kvision.remote.HttpMethod
import pl.treksoft.kvision.remote.JsonRpcRequest
@@ -114,7 +115,7 @@ open class SelectRemoteInput<T : Any>(
preserveSelected = ajaxOptions?.preserveSelected ?: true
)
if (this.ajaxOptions?.emptyRequest == true) {
- this.setInternalEventListener<SelectRemote<*>> {
+ this.onEvent {
shownBsSelect = {
val input = self.getElementJQuery()?.parent()?.find("input")
input?.trigger("keyup", null)
diff --git a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
index cd8b5817..9f66afd8 100644
--- a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
+++ b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
@@ -205,15 +205,18 @@ open class Select(
}
@Suppress("UNCHECKED_CAST")
- override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Widget {
- input.setEventListener(block)
- return this
+ override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Int {
+ return input.setEventListener(block)
}
@Deprecated("Use onEvent extension function instead.", ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent"))
- override fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget {
+ override fun setEventListener(block: SnOn<Widget>.() -> Unit): Int {
@Suppress("DEPRECATION")
- input.setEventListener(block)
+ return input.setEventListener(block)
+ }
+
+ override fun removeEventListener(id: Int): Widget {
+ input.removeEventListener(id)
return this
}
diff --git a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
index fe574fa7..a96e614e 100644
--- a/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
+++ b/kvision-modules/kvision-bootstrap-select/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
@@ -28,6 +28,7 @@ import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.CssSize
import pl.treksoft.kvision.core.StringBoolPair
import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.core.onEvent
import pl.treksoft.kvision.form.FormInput
import pl.treksoft.kvision.form.InputSize
import pl.treksoft.kvision.form.ValidationStatus
@@ -149,7 +150,7 @@ open class SelectInput(
init {
setChildrenFromOptions()
- this.setInternalEventListener<SelectInput> {
+ this.onEvent {
change = {
val v = getElementJQuery()?.`val`()
self.value = v?.let {
diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
index 69d9410b..c8b51372 100644
--- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
+++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
@@ -201,18 +201,21 @@ open class Spinner(
}
@Suppress("UNCHECKED_CAST")
- override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Widget {
- input.setEventListener(block)
- return this
+ override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Int {
+ return input.setEventListener(block)
}
@Deprecated(
"Use onEvent extension function instead.",
ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent")
)
- override fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget {
+ override fun setEventListener(block: SnOn<Widget>.() -> Unit): Int {
@Suppress("DEPRECATION")
- input.setEventListener(block)
+ return input.setEventListener(block)
+ }
+
+ override fun removeEventListener(id: Int): Widget {
+ input.removeEventListener(id)
return this
}
diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
index 3a52fed2..f195234a 100644
--- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
+++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
@@ -27,6 +27,7 @@ import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.StringBoolPair
import pl.treksoft.kvision.core.StringPair
import pl.treksoft.kvision.core.Widget
+import pl.treksoft.kvision.core.onEvent
import pl.treksoft.kvision.form.FormInput
import pl.treksoft.kvision.form.InputSize
import pl.treksoft.kvision.form.ValidationStatus
@@ -151,7 +152,7 @@ open class SpinnerInput(
ButtonsType.HORIZONTAL -> this.addSurroundingCssClass("kv-spinner-btn-horizontal")
}
this.surroundingSpan = true
- this.setInternalEventListener<SpinnerInput> {
+ this.onEvent {
change = {
self.changeValue()
}
diff --git a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt
index 20d836f0..3ba635fd 100644
--- a/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt
+++ b/kvision-modules/kvision-bootstrap-upload/src/main/kotlin/pl/treksoft/kvision/form/upload/Upload.kt
@@ -228,15 +228,18 @@ open class Upload(
}
@Suppress("UNCHECKED_CAST")
- override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Widget {
- input.setEventListener(block)
- return this
+ override fun <T : Widget> setEventListener(block: SnOn<T>.() -> Unit): Int {
+ return input.setEventListener(block)
}
@Deprecated("Use onEvent extension function instead.", ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent"))
- override fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget {
+ override fun setEventListener(block: SnOn<Widget>.() -> Unit): Int {
@Suppress("DEPRECATION")
- input.setEventListener(block)
+ return input.setEventListener(block)
+ }
+
+ override fun removeEventListener(id: Int): Widget {
+ input.removeEventListener(id)
return this
}
diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 3fa6cd36..a7f8992a 100644
--- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -28,6 +28,7 @@ import pl.treksoft.kvision.core.CssSize
import pl.treksoft.kvision.core.ResString
import pl.treksoft.kvision.core.StringBoolPair
import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.core.onEvent
import pl.treksoft.kvision.html.Button
import pl.treksoft.kvision.html.ButtonStyle
import pl.treksoft.kvision.html.ButtonType
@@ -355,7 +356,7 @@ internal class DropDownButton(
init {
this.id = id
if (!forNavbar && !forDropDown) this.role = "button"
- setInternalEventListener<DropDownButton> {
+ onEvent {
click = { e ->
if (parent?.parent is ContextMenu) {
e.asDynamic().dropDownCM = true