1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package pl.treksoft.kvision.modal
import pl.treksoft.kvision.core.Widget
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? = null, 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
}
private 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(): Widget {
super.hide()
this.callback?.invoke()
return this
}
companion object {
@Suppress("LongParameterList")
fun show(
caption: String? = null, text: String? = null, rich: Boolean = false,
align: ALIGN? = null, size: MODALSIZE? = null, animation: Boolean = true,
callback: (() -> Unit)? = null
) {
Alert(caption, text, rich, align, size, animation, callback).show()
}
}
}
|