diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-03-22 20:23:54 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-03-22 20:23:54 +0100 |
commit | 7081cfaed23fe8b34bfdf15918775a846d7649e0 (patch) | |
tree | 15458e3d7fb2cc0ebf32281362ba44f82d27fa0b /src/main/kotlin/pl/treksoft/kvision/html/Link.kt | |
parent | 6ba1eefc59a2940a7258655da4e88b4118e61746 (diff) | |
download | kvision-7081cfaed23fe8b34bfdf15918775a846d7649e0.tar.gz kvision-7081cfaed23fe8b34bfdf15918775a846d7649e0.tar.bz2 kvision-7081cfaed23fe8b34bfdf15918775a846d7649e0.zip |
Context menu component based on Bootstrap dropdown.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/html/Link.kt')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Link.kt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt index 94c7c594..50a45047 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt @@ -25,6 +25,7 @@ import com.github.snabbdom.VNode import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.ResString import pl.treksoft.kvision.core.StringPair +import pl.treksoft.kvision.dropdown.DropDown import pl.treksoft.kvision.panel.SimplePanel /** @@ -81,5 +82,37 @@ open class Link( this.add(link) return link } + + /** + * DSL builder extension function for a disabled link in a dropdown list. + * + * It takes the same parameters as the constructor of the built component. + */ + fun ListTag.linkDisabled( + label: String, icon: String? = null, image: ResString? = null, + classes: Set<String> = setOf(), init: (Link.() -> Unit)? = null + ): Link { + val link = Link(label, "javascript:void(0)", icon, image, classes).apply { init?.invoke(this) } + val tag = Tag(TAG.LI, classes = setOf("disabled")) + tag.add(link) + this.add(tag) + return link + } + + /** + * DSL builder extension function for a disabled link in a dropdown list. + * + * It takes the same parameters as the constructor of the built component. + */ + fun DropDown.linkDisabled( + label: String, icon: String? = null, image: ResString? = null, + classes: Set<String> = setOf(), init: (Link.() -> Unit)? = null + ): Link { + val link = Link(label, "javascript:void(0)", icon, image, classes).apply { init?.invoke(this) } + val tag = Tag(TAG.LI, classes = setOf("disabled")) + tag.add(link) + this.add(tag) + return link + } } } |