diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-08-22 02:29:28 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-08-22 02:29:28 +0200 |
commit | 1d86be75d10f3d5330776f6bab090d14dd1aa3a0 (patch) | |
tree | 0266a496486a78e50a1a0119f653680174176541 /src/main/kotlin/pl/treksoft/kvision/modal | |
parent | db000e6176e6e49a6a3f6b50ddbb8f0e5ae771a1 (diff) | |
download | kvision-1d86be75d10f3d5330776f6bab090d14dd1aa3a0.tar.gz kvision-1d86be75d10f3d5330776f6bab090d14dd1aa3a0.tar.bz2 kvision-1d86be75d10f3d5330776f6bab090d14dd1aa3a0.zip |
I18n fixes for modal components.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/modal')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt index ffd67a1b..693ecbaa 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Confirm.kt @@ -22,8 +22,8 @@ package pl.treksoft.kvision.modal import pl.treksoft.kvision.html.Align -import pl.treksoft.kvision.html.ButtonStyle import pl.treksoft.kvision.html.Button +import pl.treksoft.kvision.html.ButtonStyle import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag @@ -38,13 +38,16 @@ import pl.treksoft.kvision.html.Tag * @param size modal window size * @param animation determines if animations are used * @param cancelVisible determines if Cancel button is visible + * @param yesTitle yes button text + * @param noTitle no button text + * @param cancelTitle cancel button text * @param noCallback a function called after closing window with No button * @param yesCallback a function called after closing window with Yes button */ open class Confirm( caption: String? = null, text: String? = null, rich: Boolean = false, align: Align? = null, size: ModalSize? = null, animation: Boolean = true, - cancelVisible: Boolean = false, + cancelVisible: Boolean = false, yesTitle: String = "Yes", noTitle: String = "No", cancelTitle: String = "Cancel", private val noCallback: (() -> Unit)? = null, private val yesCallback: (() -> Unit)? = null ) : Modal(caption, false, size, animation, false) { @@ -77,8 +80,37 @@ open class Confirm( */ var cancelVisible by refreshOnUpdate(cancelVisible, { refreshCancelButton() }) + /** + * Yes button text. + */ + var yesTitle + get() = yesButton.text + set(value) { + yesButton.text = value + } + + /** + * No button text. + */ + var noTitle + get() = noButton.text + set(value) { + noButton.text = value + } + + /** + * Cancel button text. + */ + var cancelTitle + get() = cancelButton.text + set(value) { + cancelButton.text = value + } + private val contentTag = Tag(TAG.DIV, text, rich, align) - private val cancelButton = Button("Cancel", "remove") + private val cancelButton = Button(cancelTitle, "remove") + private val noButton = Button(noTitle, "ban-circle") + private val yesButton = Button(yesTitle, "ok", ButtonStyle.PRIMARY) init { body.add(contentTag) @@ -88,7 +120,6 @@ open class Confirm( } } this.addButton(cancelButton) - val noButton = Button("No", "ban-circle") noButton.setEventListener { click = { hide() @@ -96,7 +127,6 @@ open class Confirm( } } this.addButton(noButton) - val yesButton = Button("Yes", "ok", ButtonStyle.PRIMARY) yesButton.setEventListener { click = { hide() @@ -134,10 +164,13 @@ open class Confirm( fun show( caption: String? = null, text: String? = null, rich: Boolean = false, align: Align? = null, size: ModalSize? = null, animation: Boolean = true, - cancelVisible: Boolean = false, - noCallback: (() -> Unit)? = null, yesCallback: (() -> Unit)? = null + cancelVisible: Boolean = false, yesTitle: String = "Yes", noTitle: String = "No", + cancelTitle: String = "Cancel", noCallback: (() -> Unit)? = null, yesCallback: (() -> Unit)? = null ) { - Confirm(caption, text, rich, align, size, animation, cancelVisible, noCallback, yesCallback).show() + Confirm( + caption, text, rich, align, size, animation, cancelVisible, yesTitle, noTitle, cancelTitle, + noCallback, yesCallback + ).show() } } } |