aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/html
diff options
context:
space:
mode:
authorRobbie Cronin <robert.cronin@uqconnect.edu.au>2019-06-21 13:17:30 +0800
committerGitHub <noreply@github.com>2019-06-21 13:17:30 +0800
commit2f8e0060308b0f5b1eeac9541600bfed3ad5acc9 (patch)
tree80d40364c5f5957da8c82578dd1152adac06912e /src/main/kotlin/pl/treksoft/kvision/html
parent9038555f9e46a32a0a725112304e64cdd408bf8e (diff)
parentd9f1a90c772719d14540eb2bf7bc3b8384fa7a72 (diff)
downloadkvision-2f8e0060308b0f5b1eeac9541600bfed3ad5acc9.tar.gz
kvision-2f8e0060308b0f5b1eeac9541600bfed3ad5acc9.tar.bz2
kvision-2f8e0060308b0f5b1eeac9541600bfed3ad5acc9.zip
Merge pull request #1 from rjaros/master
merge
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Tag.kt16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
index 32119a90..68e43da0 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt
@@ -69,6 +69,7 @@ enum class TAG(internal val tagName: String) {
SAMP("samp"),
SPAN("span"),
LI("li"),
+ HR("hr"),
CAPTION("caption"),
THEAD("thead"),
@@ -78,7 +79,10 @@ enum class TAG(internal val tagName: String) {
TD("td"),
FORM("form"),
- INPUT("input")
+ INPUT("input"),
+ SELECT("select"),
+ OPTION("option"),
+ BUTTON("button")
}
/**
@@ -101,11 +105,13 @@ enum class Align(val className: String) {
* @param rich determines if [content] can contain HTML code
* @param align content align
* @param classes a set of CSS class names
+ * @param attributes a map of additional attributes
* @param init an initializer extension function
*/
open class Tag(
type: TAG, content: String? = null, rich: Boolean = false, align: Align? = null,
- classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null
+ classes: Set<String> = setOf(), attributes: Map<String, String> = mapOf(),
+ init: (Tag.() -> Unit)? = null
) : SimplePanel(classes), Template {
/**
@@ -139,6 +145,7 @@ open class Tag(
override var templates: Map<String, (Any?) -> String> by refreshOnUpdate(mapOf())
init {
+ this.attributes += attributes
@Suppress("LeakingThis")
init?.invoke(this)
}
@@ -187,9 +194,10 @@ open class Tag(
*/
fun Container.tag(
type: TAG, content: String? = null, rich: Boolean = false, align: Align? = null,
- classes: Set<String> = setOf(), init: (Tag.() -> Unit)? = null
+ classes: Set<String> = setOf(), attributes: Map<String, String> = mapOf(),
+ init: (Tag.() -> Unit)? = null
): Tag {
- val tag = Tag(type, content, rich, align, classes, init)
+ val tag = Tag(type, content, rich, align, classes, attributes, init)
this.add(tag)
return tag
}