From 9fbc710662e398199ba0082cbd3add9aa22c16a3 Mon Sep 17 00:00:00 2001 From: Bartosz Malkowski Date: Wed, 29 Apr 2020 10:20:10 +0200 Subject: Add property to scrolling long content in Modal --- .../main/kotlin/pl/treksoft/kvision/modal/Modal.kt | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision') diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt index baf1d4e0..afc5f5fd 100644 --- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt +++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/modal/Modal.kt @@ -60,7 +60,7 @@ enum class ModalSize(val className: String) { @Suppress("TooManyFunctions") open class Modal( caption: String? = null, closeButton: Boolean = true, - size: ModalSize? = null, animation: Boolean = true, centered: Boolean = false, private val escape: Boolean = true, + size: ModalSize? = null, animation: Boolean = true, centered: Boolean = false, scrollable: Boolean = false, private val escape: Boolean = true, classes: Set = setOf(), init: (Modal.() -> Unit)? = null ) : SimplePanel(classes) { @@ -105,7 +105,16 @@ open class Modal( dialog.centered = value } - private val dialog = ModalDialog(size, centered) + /** + * Determines if modal body is scrollable. + */ + var scrollable + get() = dialog.scrollable + set(value) { + dialog.scrollable = value + } + + private val dialog = ModalDialog(size, centered, scrollable) private val header = SimplePanel(setOf("modal-header")) /** * @suppress @@ -284,7 +293,7 @@ open class Modal( * @param size modal window size * @param centered determines if modal dialog is vertically centered */ -internal class ModalDialog(size: ModalSize?, centered: Boolean = false) : SimplePanel(setOf("modal-dialog")) { +internal class ModalDialog(size: ModalSize?, centered: Boolean = false, scrollable: Boolean = false) : SimplePanel(setOf("modal-dialog")) { /** * Modal window size. @@ -296,6 +305,11 @@ internal class ModalDialog(size: ModalSize?, centered: Boolean = false) : Simple */ var centered by refreshOnUpdate(centered) + /** + * Determines if content is scrollable. + */ + var scrollable by refreshOnUpdate(scrollable) + override fun getSnClass(): List { val cl = super.getSnClass().toMutableList() size?.let { @@ -304,6 +318,9 @@ internal class ModalDialog(size: ModalSize?, centered: Boolean = false) : Simple if (centered) { cl.add("modal-dialog-centered" to true) } + if (scrollable) { + cl.add("modal-dialog-scrollable" to true) + } return cl } } -- cgit