diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/form/upload/UploadInput.kt | 19 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/utils/Snabbdom.kt | 5 |
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)? } /** |