diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-09-17 04:28:09 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-09-17 04:28:09 +0200 |
commit | ab12f9a29f7517e6ad5923b687f8ff476fc83a93 (patch) | |
tree | e22a30fd6d54f63f538dd81a609f794991d986ea /src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt | |
parent | 5d5db76ff0d9d1505c4a41cd84e871793a7a7b8d (diff) | |
download | kvision-ab12f9a29f7517e6ad5923b687f8ff476fc83a93.tar.gz kvision-ab12f9a29f7517e6ad5923b687f8ff476fc83a93.tar.bz2 kvision-ab12f9a29f7517e6ad5923b687f8ff476fc83a93.zip |
Modals
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt new file mode 100644 index 00000000..5e0e910a --- /dev/null +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Alert.kt @@ -0,0 +1,54 @@ +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.TAG +import pl.treksoft.kvision.html.Tag + +open class Alert(caption: String? = null, text: String? = null, rich: Boolean = false, + align: ALIGN = ALIGN.NONE, size: MODALSIZE? = null, animation: Boolean = true, + private val callback: (() -> Unit)? = null) : Modal(caption, true, size, animation) { + var text + get() = content.text + set(value) { + content.text = value + } + var rich + get() = content.rich + set(value) { + content.rich = value + } + var align + get() = content.align + set(value) { + content.align = value + } + + val content = Tag(TAG.SPAN, text, rich, align) + + init { + body.add(content) + val okButton = Button("OK", "ok", BUTTONSTYLE.PRIMARY) + okButton.setEventListener { + click = { + hide() + } + } + this.addButton(okButton) + } + + override fun hide() { + super.hide() + this.callback?.invoke() + } + + companion object { + @Suppress("LongParameterList") + fun show(caption: String? = null, text: String? = null, rich: Boolean = false, + align: ALIGN = ALIGN.NONE, size: MODALSIZE? = null, animation: Boolean = true, + callback: (() -> Unit)? = null) { + Alert(caption, text, rich, align, size, animation, callback).show() + } + } +} |