diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-09-02 22:58:49 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-09-02 22:58:49 +0200 |
commit | 64e2bca354a1eb6018086427365336c3acb75cb8 (patch) | |
tree | 0a154d36120fc731d5704d4320af3dba711de37b /src/main/kotlin | |
parent | 0407e661dced3adcf8386b27738295e285a043a0 (diff) | |
download | kvision-64e2bca354a1eb6018086427365336c3acb75cb8.tar.gz kvision-64e2bca354a1eb6018086427365336c3acb75cb8.tar.bz2 kvision-64e2bca354a1eb6018086427365336c3acb75cb8.zip |
Tag widget refactoring
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/Showcase.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/basic/Label.kt | 7 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/InTag.kt | 48 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Tag.kt | 17 |
4 files changed, 20 insertions, 54 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt index caa66269..2a376f17 100644 --- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt +++ b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt @@ -31,7 +31,7 @@ class Showcase : ApplicationBase() { val p = Tag(TAG.P, "To jest prawo", align = ALIGN.RIGHT) p.title = "Tytuł" root.add(p) - val del = InTag(INTAG.DEL, "To jest deleted") + val del = Tag(TAG.DEL, "To jest deleted") root.add(del) val list = ListTag(LIST.DL_HORIZ, listOf("abc", "de<b>fdasdasdasddasd</b>tdasdas", "Dasdsada", "dasdasdads"), true) diff --git a/src/main/kotlin/pl/treksoft/kvision/basic/Label.kt b/src/main/kotlin/pl/treksoft/kvision/basic/Label.kt index c0aa5ad2..cf0587db 100644 --- a/src/main/kotlin/pl/treksoft/kvision/basic/Label.kt +++ b/src/main/kotlin/pl/treksoft/kvision/basic/Label.kt @@ -1,7 +1,6 @@ package pl.treksoft.kvision.basic -import pl.treksoft.kvision.html.InTag -import pl.treksoft.kvision.html.INTAG +import pl.treksoft.kvision.html.TAG +import pl.treksoft.kvision.html.Tag -open class Label(text: String, rich: Boolean = false) : InTag(INTAG.SPAN, text, rich) { -}
\ No newline at end of file +open class Label(text: String, rich: Boolean = false) : Tag(TAG.SPAN, text, rich)
\ No newline at end of file diff --git a/src/main/kotlin/pl/treksoft/kvision/html/InTag.kt b/src/main/kotlin/pl/treksoft/kvision/html/InTag.kt deleted file mode 100644 index 88f69435..00000000 --- a/src/main/kotlin/pl/treksoft/kvision/html/InTag.kt +++ /dev/null @@ -1,48 +0,0 @@ -package pl.treksoft.kvision.html - -import com.github.snabbdom.VNode -import pl.treksoft.kvision.core.KVManager -import pl.treksoft.kvision.core.Widget - -enum class INTAG(val tagName: String) { - MARK("mark"), - DEL("del"), - S("s"), - INS("ins"), - U("u"), - SMALL("small"), - STRONG("strong"), - EM("em"), - CITE("cite"), - CODE("code"), - KBD("kbd"), - VAR("var"), - SAMP("samp"), - SPAN("span") -} - -open class InTag(type: INTAG, text: String, rich: Boolean = false, classes: Set<String> = setOf()) : Widget(classes) { - var type = type - set(value) { - field = value - refresh() - } - var text = text - set(value) { - field = value - refresh() - } - var rich = rich - set(value) { - field = value - refresh() - } - - override fun render(): VNode { - if (rich) { - return kvh(type.tagName, arrayOf(KVManager.virtualize("<span>$text</span>"))) - } else { - return kvh(type.tagName, arrayOf(text)) - } - } -}
\ No newline at end of file diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt index 60910707..4178fbfb 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Tag.kt @@ -17,7 +17,22 @@ enum class TAG(val tagName: String) { ADDRESS("address"), BLOCKQUOTE("blockquote"), FOOTER("footer"), - PRE("pre") + PRE("pre"), + + MARK("mark"), + DEL("del"), + S("s"), + INS("ins"), + U("u"), + SMALL("small"), + STRONG("strong"), + EM("em"), + CITE("cite"), + CODE("code"), + KBD("kbd"), + VAR("var"), + SAMP("samp"), + SPAN("span") } enum class ALIGN(val className: String) { |