diff options
author | Robert Jaros <rjaros@finn.pl> | 2020-02-09 01:57:15 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2020-02-09 01:57:15 +0100 |
commit | 7d08dca00e75c2d70fbcbd5d570e43b1b863c259 (patch) | |
tree | ba6e2beb53bbdc49fde1c6a2298eeff7014e30ad /kvision-modules/kvision-bootstrap-datetime | |
parent | 321fadf3b8381b9d33cb6c5208d0bf6c4d7923f7 (diff) | |
download | kvision-7d08dca00e75c2d70fbcbd5d570e43b1b863c259.tar.gz kvision-7d08dca00e75c2d70fbcbd5d570e43b1b863c259.tar.bz2 kvision-7d08dca00e75c2d70fbcbd5d570e43b1b863c259.zip |
Fix DateTimeInput positioning inside the Tabulator table
Diffstat (limited to 'kvision-modules/kvision-bootstrap-datetime')
-rw-r--r-- | kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt b/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt index f9f170a9..813059e8 100644 --- a/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt +++ b/kvision-modules/kvision-bootstrap-datetime/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt @@ -22,6 +22,7 @@ package pl.treksoft.kvision.form.time import com.github.snabbdom.VNode +import pl.treksoft.jquery.jQuery import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.StringBoolPair import pl.treksoft.kvision.form.FormInput @@ -328,6 +329,31 @@ open class DateTimeInput( this.dispatchEvent("change", obj { detail = e }) } this.getElementJQuery()?.on("dp.show") { e, _ -> + val inTabulator = this.getElementJQuery()?.closest(".tabulator-cell")?.length == 1 + if (inTabulator) { + val datepicker = jQuery("body").find(".bootstrap-datetimepicker-widget:last") + val position = datepicker.offset() + val parent = datepicker.parent() + val parentPos = parent.offset() + val width = datepicker.width() + val parentWid = parent.width() + datepicker.appendTo("body") + @Suppress("UnsafeCastFromDynamic") + datepicker.css(obj { + this.position = "absolute" + this.top = position.top + this.bottom = "auto" + this.left = position.left + this.right = "auto" + }) + if (parentPos.left.toInt() + parentWid.toInt() < position.left.toInt() + width.toInt()) { + var newLeft = parentPos.left.toInt() + newLeft += parentWid.toInt() / 2 + newLeft -= width.toInt() / 2 + @Suppress("UnsafeCastFromDynamic") + datepicker.css(obj { this.left = newLeft }) + } + } @Suppress("UnsafeCastFromDynamic") this.dispatchEvent("showBsDateTime", obj { detail = e }) } |