aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-03-23 13:18:22 +0100
committerRobert Jaros <rjaros@finn.pl>2018-03-23 13:18:22 +0100
commit6f3c026c4d70cb9c7b3ee156e988b6320e0ceb28 (patch)
tree748c8cd99c49821d9f0318d27fe08730b8a5d02f /src/main/kotlin/pl/treksoft/kvision
parent5f8790e7127df07a17f51e5641be66b7654dbb33 (diff)
downloadkvision-6f3c026c4d70cb9c7b3ee156e988b6320e0ceb28.tar.gz
kvision-6f3c026c4d70cb9c7b3ee156e988b6320e0ceb28.tar.bz2
kvision-6f3c026c4d70cb9c7b3ee156e988b6320e0ceb28.zip
Small fixes for links in dropdowns.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Link.kt12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 4622ceca..8a37cf6c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -190,7 +190,7 @@ open class DropDown(
DD.SEPARATOR.option -> Separator()
DD.DISABLED.option -> {
val tag = Tag(TAG.LI, classes = setOf("disabled"))
- tag.add(Link(it.first, "javascript:void(0)"))
+ tag.add(Link(it.first))
tag
}
else -> Link(it.first, it.second)
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
index 50a45047..d1cf9a12 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Link.kt
@@ -39,7 +39,7 @@ import pl.treksoft.kvision.panel.SimplePanel
* @param classes a set of CSS class names
*/
open class Link(
- label: String, url: String, icon: String? = null, image: ResString? = null,
+ label: String, url: String? = null, icon: String? = null, image: ResString? = null,
classes: Set<String> = setOf()
) : SimplePanel(classes) {
/**
@@ -65,7 +65,11 @@ open class Link(
}
override fun getSnAttrs(): List<StringPair> {
- return super.getSnAttrs() + ("href" to url)
+ val pr = super.getSnAttrs().toMutableList()
+ url?.let {
+ pr.add("href" to it)
+ }
+ return pr
}
companion object {
@@ -75,7 +79,7 @@ open class Link(
* It takes the same parameters as the constructor of the built component.
*/
fun Container.link(
- label: String, url: String, icon: String? = null, image: ResString? = null,
+ label: String, url: String? = null, icon: String? = null, image: ResString? = null,
classes: Set<String> = setOf(), init: (Link.() -> Unit)? = null
): Link {
val link = Link(label, url, icon, image, classes).apply { init?.invoke(this) }
@@ -92,7 +96,7 @@ open class Link(
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 link = Link(label, null, icon, image, classes).apply { init?.invoke(this) }
val tag = Tag(TAG.LI, classes = setOf("disabled"))
tag.add(link)
this.add(tag)