From 73ab234bad21da33c06020195870cb046b702239 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 20 Jan 2020 12:32:15 +0100 Subject: Fix empty links in Navbar and DropDown components --- .../kotlin/pl/treksoft/kvision/dropdown/DropDown.kt | 2 +- .../main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'kvision-modules/kvision-bootstrap/src/main') diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt index 891cd226..3fa6cd36 100644 --- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt +++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt @@ -392,7 +392,7 @@ internal class DropDownButton( inherited } + listOf( "data-toggle" to "dropdown", "aria-haspopup" to "true", - "aria-expanded" to "false", "href" to "#" + "aria-expanded" to "false", "href" to "javascript:void(0)" ) } } diff --git a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt index 68975f8d..c6f6fe3f 100644 --- a/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt +++ b/kvision-modules/kvision-bootstrap/src/main/kotlin/pl/treksoft/kvision/navbar/Navbar.kt @@ -64,7 +64,8 @@ enum class NavbarExpand(internal val navbarExpand: String) { * The Bootstrap Navbar container. * * @constructor - * @param label the navbar label + * @param label the navbar header label + * @param link the navbar header link * @param type the navbar type * @param expand the navbar responsive behavior * @param nColor the navbar color @@ -74,6 +75,7 @@ enum class NavbarExpand(internal val navbarExpand: String) { */ open class Navbar( label: String? = null, + link: String? = null, type: NavbarType? = null, expand: NavbarExpand? = NavbarExpand.LG, nColor: NavbarColor = NavbarColor.LIGHT, @@ -94,6 +96,14 @@ open class Navbar( brandLink.hide() } } + /** + * The navbar header link. + */ + var link + get() = brandLink.url + set(value) { + brandLink.url = value + } /** * The navbar type. @@ -114,7 +124,7 @@ open class Navbar( private val idc = "kv_navbar_$counter" - private val brandLink = Link(label ?: "", "#", classes = setOf("navbar-brand")) + private val brandLink = Link(label ?: "", link, classes = setOf("navbar-brand")) internal val container = SimplePanel(setOf("collapse", "navbar-collapse")) { id = idc } @@ -183,13 +193,14 @@ open class Navbar( */ fun Container.navbar( label: String? = null, + link: String? = null, type: NavbarType? = null, expand: NavbarExpand? = NavbarExpand.LG, nColor: NavbarColor = NavbarColor.LIGHT, bgColor: BsBgColor = BsBgColor.LIGHT, classes: Set = setOf(), init: (Navbar.() -> Unit)? = null ): Navbar { - val navbar = Navbar(label, type, expand, nColor, bgColor, classes, init) + val navbar = Navbar(label, link, type, expand, nColor, bgColor, classes, init) this.add(navbar) return navbar } -- cgit