aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-03-30 13:50:01 +0200
committerRobert Jaros <rjaros@finn.pl>2018-03-30 13:50:01 +0200
commit1a7374b9d24bfcf1ea942d19d099f2c6c7edb81f (patch)
treea62f24e7d156f9517e82d7fe0e5ef1627a47e28c /src/main
parent5ff62fa68f1c6d9693aeb4c27116b77c43e1a309 (diff)
downloadkvision-1a7374b9d24bfcf1ea942d19d099f2c6c7edb81f.tar.gz
kvision-1a7374b9d24bfcf1ea942d19d099f2c6c7edb81f.tar.bz2
kvision-1a7374b9d24bfcf1ea942d19d099f2c6c7edb81f.zip
Support for some events of file upload control.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt19
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt5
2 files changed, 24 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt
index b0c07c3e..d77a9b9b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt
@@ -144,8 +144,27 @@ open class UploadInput(uploadUrl: String? = null, multiple: Boolean = false, cla
return if (v.isNotEmpty()) v else null
}
+ @Suppress("UnsafeCastFromDynamic")
override fun afterInsert(node: VNode) {
getElementJQueryD()?.fileinput(getSettingsObj())
+ this.getElementJQuery()?.on("fileselect", { e, _ ->
+ this.dispatchEvent("fileSelectUpload", obj { detail = e })
+ })
+ this.getElementJQuery()?.on("fileclear", { e, _ ->
+ this.dispatchEvent("fileClearUpload", obj { detail = e })
+ })
+ this.getElementJQuery()?.on("filereset", { e, _ ->
+ this.dispatchEvent("fileResetUpload", obj { detail = e })
+ })
+ this.getElementJQuery()?.on("filebrowse", { e, _ ->
+ this.dispatchEvent("fileBrowseUpload", obj { detail = e })
+ })
+ this.getElementJQueryD()?.on("filepreupload", lambda@{ _, data, previewId, index ->
+ data["previewId"] = previewId
+ data["index"] = index
+ this.dispatchEvent("filePreUpload", obj { detail = data })
+ return@lambda null
+ })
}
override fun afterDestroy() {
diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt
index e719d133..ccb11ff9 100644
--- a/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt
@@ -95,6 +95,11 @@ interface BtOn : On {
var onMinBsSpinner: ((KvEvent) -> kotlin.Unit)?
var onMaxBsSpinner: ((KvEvent) -> kotlin.Unit)?
var updateModel: ((KvEvent) -> kotlin.Unit)?
+ var fileSelectUpload: ((KvEvent) -> kotlin.Unit)?
+ var fileClearUpload: ((KvEvent) -> kotlin.Unit)?
+ var fileResetUpload: ((KvEvent) -> kotlin.Unit)?
+ var fileBrowseUpload: ((KvEvent) -> kotlin.Unit)?
+ var filePreUpload: ((KvEvent) -> kotlin.Unit)?
}
/**