aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form
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/kotlin/pl/treksoft/kvision/form
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/kotlin/pl/treksoft/kvision/form')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt19
1 files changed, 19 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() {