diff options
author | Robert Jaros <rjaros@finn.pl> | 2017-09-08 13:29:16 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2017-09-08 13:29:16 +0200 |
commit | 85b48891c61c604c952c8739b50bdae2998c44a7 (patch) | |
tree | 7281243392774153dfb7b700fb55bb9b169c8a4e /src/main/kotlin/pl/treksoft/kvision/dropdown | |
parent | 2072d1b9c1b9d4f515cc1759b12ca19db7106d82 (diff) | |
download | kvision-85b48891c61c604c952c8739b50bdae2998c44a7.tar.gz kvision-85b48891c61c604c952c8739b50bdae2998c44a7.tar.bz2 kvision-85b48891c61c604c952c8739b50bdae2998c44a7.zip |
Added code analyzing with Detekt
Refactoring
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/dropdown')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt index c0a87297..18946b27 100644 --- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt +++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt @@ -2,7 +2,14 @@ package pl.treksoft.kvision.dropdown import pl.treksoft.kvision.core.Container import pl.treksoft.kvision.core.ResString -import pl.treksoft.kvision.html.* +import pl.treksoft.kvision.html.BUTTONSIZE +import pl.treksoft.kvision.html.BUTTONSTYLE +import pl.treksoft.kvision.html.Button +import pl.treksoft.kvision.html.LIST +import pl.treksoft.kvision.html.Link +import pl.treksoft.kvision.html.ListTag +import pl.treksoft.kvision.html.TAG +import pl.treksoft.kvision.html.Tag import pl.treksoft.kvision.snabbdom.StringPair enum class DD(val POS: String) { @@ -11,10 +18,13 @@ enum class DD(val POS: String) { SEPARATOR("DD#SEPARATOR") } -open class DropDown(text: String, elements: List<StringPair>, icon: String? = null, style: BUTTON_STYLE = BUTTON_STYLE.DEFAULT, size: BUTTON_SIZE? = null, - block: Boolean = false, disabled: Boolean = false, image: ResString? = null, dropup: Boolean = false, classes: Set<String> = setOf()) : Container(classes) { +open class DropDown(text: String, elements: List<StringPair>, icon: String? = null, + style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, size: BUTTONSIZE? = null, + block: Boolean = false, disabled: Boolean = false, image: ResString? = null, + dropup: Boolean = false, classes: Set<String> = setOf()) : Container(classes) { val idc = "kv_dropdown_" + counter - val button: DropDownButton = DropDownButton(idc, text, icon, style, size, block, disabled, image, setOf("dropdown")) + val button: DropDownButton = DropDownButton(idc, text, icon, style, size, block, + disabled, image, setOf("dropdown")) val list: DropDownListTag = DropDownListTag(idc, setOf("dropdown-menu")) init { @@ -46,8 +56,9 @@ open class DropDown(text: String, elements: List<StringPair>, icon: String? = nu } } -open class DropDownButton(id: String, text: String, icon: String? = null, style: BUTTON_STYLE = BUTTON_STYLE.DEFAULT, size: BUTTON_SIZE? = null, - block: Boolean = false, disabled: Boolean = false, image: ResString? = null, classes: Set<String> = setOf()) : +open class DropDownButton(id: String, text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, + size: BUTTONSIZE? = null, block: Boolean = false, disabled: Boolean = false, + image: ResString? = null, classes: Set<String> = setOf()) : Button(text, icon, style, size, block, disabled, image, classes) { init { @@ -55,12 +66,14 @@ open class DropDownButton(id: String, text: String, icon: String? = null, style: } override fun getSnAttrs(): List<StringPair> { - return super.getSnAttrs() + listOf("data-toggle" to "dropdown", "aria-haspopup" to "true", "aria-expanded" to "false") + return super.getSnAttrs() + listOf("data-toggle" to "dropdown", "aria-haspopup" to "true", + "aria-expanded" to "false") } } -open class DropDownListTag(val ariaId: String, classes: Set<String> = setOf()) : ListTag(LIST.UL, null, false, classes) { +open class DropDownListTag(val ariaId: String, classes: Set<String> = setOf()) : ListTag(LIST.UL, null, + false, classes) { override fun getSnAttrs(): List<StringPair> { return super.getSnAttrs() + listOf("aria-labelledby" to ariaId) } -}
\ No newline at end of file +} |