aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Css.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt5
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Widget.kt7
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt67
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt13
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/CheckBox.kt15
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/CheckInput.kt9
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/Password.kt6
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/Radio.kt18
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/Text.kt7
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/TextArea.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/TextAreaInput.kt6
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/TextInput.kt7
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Button.kt6
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt24
15 files changed, 83 insertions, 123 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt
index eba7782a..a645ac83 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Css.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Css.kt
@@ -1,6 +1,6 @@
package pl.treksoft.kvision.core
-import pl.treksoft.kvision.utils.Utils
+import pl.treksoft.kvision.utils.toHexString
@Suppress("EnumNaming", "EnumEntryName")
enum class UNIT(val unit: String) {
@@ -215,7 +215,7 @@ class Border private constructor(private val width: CssSize? = null, private val
private val color: String? = null) {
constructor(width: CssSize? = null, style: BORDERSTYLE? = null) : this(width, style, null)
constructor(width: CssSize? = null, style: BORDERSTYLE? = null, color: Int) : this(width, style,
- "#" + Utils.intToHexString(color))
+ "#" + color.toHexString())
constructor(width: CssSize? = null, style: BORDERSTYLE? = null, color: COLOR) : this(width, style, color.color)
@@ -228,7 +228,7 @@ class Border private constructor(private val width: CssSize? = null, private val
}
class Color private constructor(private val color: String? = null) {
- constructor(color: Int) : this("#" + Utils.intToHexString(color))
+ constructor(color: Int) : this("#" + color.toHexString())
constructor(color: COLOR) : this(color.color)
fun asString(): String {
@@ -253,7 +253,7 @@ class Background private constructor(private val color: String? = null, private
sizeX: CssSize? = null, sizeY: CssSize? = null, size: BGSIZE? = null,
repeat: BGREPEAT? = null, origin: BGORIGIN? = null, clip: BGCLIP? = null,
attachment: BGATTACH? = null) : this("#" +
- Utils.intToHexString(color), image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip,
+ color.toHexString(), image, positionX, positionY, sizeX, sizeY, size, repeat, origin, clip,
attachment)
constructor(color: COLOR, image: ResString? = null, positionX: CssSize? = null,
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt b/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt
index e394db73..f603d944 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/KVManager.kt
@@ -8,7 +8,6 @@ import com.github.snabbdom.datasetModule
import com.github.snabbdom.eventListenersModule
import com.github.snabbdom.propsModule
import com.github.snabbdom.styleModule
-import pl.treksoft.jquery.jQuery
import pl.treksoft.kvision.require
import pl.treksoft.kvision.routing.routing
import kotlin.browser.document
@@ -19,6 +18,9 @@ object KVManager {
private val fontAwesomeWebpack = require("font-awesome-webpack")
private val resizable = require("jquery-resizable-dom")
private val awesomeBootstrapCheckbox = require("awesome-bootstrap-checkbox")
+ private val bootstrapSelectCss = require("bootstrap-select/dist/css/bootstrap-select.min.css")
+ private val bootstrapSelect = require("bootstrap-select")
+ private val bootstrapSelectI18n = require("./js/bootstrap-select-i18n.min.js")
private val sdPatch = Snabbdom.init(arrayOf(classModule, attributesModule, propsModule, styleModule,
eventListenersModule, datasetModule))
@@ -41,7 +43,6 @@ object KVManager {
}
fun init() {
- jQuery(document).off(".data-api")
}
fun shutdown() {
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
index 6ce1eade..123ffc4c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
@@ -215,6 +215,13 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent() {
return hooks
}
+ @Suppress("UNCHECKED_CAST")
+ protected fun <T : Widget> setInternalEventListener(block: SnOn<T>.() -> Unit): Widget {
+ internalListeners.add(block as SnOn<Widget>.() -> Unit)
+ refresh()
+ return this
+ }
+
protected fun setInternalEventListener(block: SnOn<Widget>.() -> Unit): Widget {
internalListeners.add(block)
refresh()
diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 1ba20211..eabed092 100644
--- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -1,8 +1,6 @@
package pl.treksoft.kvision.dropdown
import com.github.snabbdom.VNode
-import pl.treksoft.kvision.panel.SimplePanel
-import pl.treksoft.kvision.core.ResString
import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.html.BUTTONSTYLE
import pl.treksoft.kvision.html.Button
@@ -11,9 +9,11 @@ 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.panel.SimplePanel
import pl.treksoft.kvision.snabbdom.StringBoolPair
import pl.treksoft.kvision.snabbdom.StringPair
import pl.treksoft.kvision.snabbdom.obj
+import kotlin.browser.window
enum class DD(val type: String) {
HEADER("DD#HEADER"),
@@ -22,8 +22,8 @@ enum class DD(val type: String) {
}
open class DropDown(text: String, elements: List<StringPair>? = null, icon: String? = null,
- style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, disabled: Boolean = false, image: ResString? = null,
- dropup: Boolean = false, classes: Set<String> = setOf()) : SimplePanel(classes) {
+ style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, disabled: Boolean = false,
+ classes: Set<String> = setOf()) : SimplePanel(classes) {
var text
get() = button.text
set(value) {
@@ -31,7 +31,7 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri
}
private var elements = elements
set(value) {
- field = elements
+ field = value
setChildrenFromElements()
}
var icon
@@ -64,7 +64,7 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri
set(value) {
button.image = value
}
- private var dropup = dropup
+ var dropup = false
set(value) {
field = value
refresh()
@@ -72,16 +72,10 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri
private val idc = "kv_dropdown_" + counter
internal val button: DropDownButton = DropDownButton(idc, text, icon, style,
- disabled, image, setOf("dropdown"))
+ disabled, setOf("dropdown"))
internal val list: DropDownListTag = DropDownListTag(idc, setOf("dropdown-menu"))
init {
- button.setEventListener {
- click = {
- if (!button.disabled) toggle()
- }
- }
-
list.hide()
setChildrenFromElements()
this.addInternal(button)
@@ -104,8 +98,8 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri
}
private fun setChildrenFromElements() {
- val elems = elements
- if (elems != null) {
+ list.removeAll()
+ elements?.let { elems ->
val c = elems.map {
when (it.second) {
DD.HEADER.type -> Tag(TAG.LI, it.first, classes = setOf("dropdown-header"))
@@ -123,14 +117,13 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri
}
}
list.addAll(c)
- } else {
- list.removeAll()
}
}
@Suppress("UnsafeCastFromDynamic")
override fun afterInsert(node: VNode) {
this.getElementJQuery()?.on("show.bs.dropdown", { e, _ ->
+ if (!list.visible) list.visible = true
this.dispatchEvent("showBsDropdown", obj({ detail = e }))
})
this.getElementJQuery()?.on("shown.bs.dropdown", { e, _ ->
@@ -140,7 +133,7 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri
this.dispatchEvent("hideBsDropdown", obj({ detail = e }))
})
this.getElementJQuery()?.on("hidden.bs.dropdown", { e, _ ->
- list.visible = false
+ if (list.visible) list.visible = false
this.dispatchEvent("hiddenBsDropdown", obj({ detail = e }))
})
}
@@ -155,17 +148,18 @@ open class DropDown(text: String, elements: List<StringPair>? = null, icon: Stri
}
open fun toggle() {
- if (list.visible)
- list.hideInternal()
- else
- list.show()
+ if (this.list.visible) {
+ this.list.getElementJQueryD()?.dropdown("toggle")
+ } else {
+ this.list.visible = true
+ window.setTimeout({ this.list.getElementJQueryD()?.dropdown("toggle") }, 0)
+ }
}
}
open class DropDownButton(id: String, text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT,
- disabled: Boolean = false,
- image: ResString? = null, classes: Set<String> = setOf()) :
- Button(text, icon, style, disabled, image, classes) {
+ disabled: Boolean = false, classes: Set<String> = setOf()) :
+ Button(text, icon, style, disabled, classes) {
init {
this.id = id
@@ -183,27 +177,4 @@ open class DropDownListTag(private val ariaId: String, classes: Set<String> = se
override fun getSnAttrs(): List<StringPair> {
return super.getSnAttrs() + listOf("aria-labelledby" to ariaId)
}
-
- override fun hide(): Widget {
- if (visible) hideInternal()
- return super.hide()
- }
-
- override fun afterInsert(node: VNode) {
- if (visible) showInternal()
- }
-
- @Suppress("UnsafeCastFromDynamic")
- private fun showInternal() {
- if (getElementJQueryD()?.`is`(":hidden")) {
- getElementJQueryD()?.dropdown("toggle")
- }
- }
-
- @Suppress("UnsafeCastFromDynamic")
- internal fun hideInternal() {
- if (!getElementJQueryD()?.`is`(":hidden")) {
- getElementJQueryD()?.dropdown("toggle")
- }
- }
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
index 82846012..84ad5661 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
@@ -4,12 +4,9 @@ import pl.treksoft.kvision.core.Widget
import pl.treksoft.kvision.snabbdom.StringBoolPair
import pl.treksoft.kvision.snabbdom.StringPair
-abstract class AbstractTextInput(placeholder: String? = null,
- override var value: String? = null, name: String? = null, maxlength: Int? = null,
- disabled: Boolean = false, id: String? = null,
+abstract class AbstractTextInput(override var value: String? = null,
classes: Set<String> = setOf()) : Widget(classes + "form-control"), StringFormField {
init {
- this.id = id
this.setInternalEventListener {
input = {
val v = getElementJQuery()?.`val`() as String?
@@ -29,22 +26,22 @@ abstract class AbstractTextInput(placeholder: String? = null,
this.value = value
refresh()
}
- var placeholder: String? = placeholder
+ var placeholder: String? = null
set(value) {
field = value
refresh()
}
- var name: String? = name
+ var name: String? = null
set(value) {
field = value
refresh()
}
- var maxlength: Int? = maxlength
+ var maxlength: Int? = null
set(value) {
field = value
refresh()
}
- override var disabled: Boolean = disabled
+ override var disabled: Boolean = false
set(value) {
field = value
refresh()
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/CheckBox.kt b/src/main/kotlin/pl/treksoft/kvision/form/CheckBox.kt
index 65941495..f4598d4d 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/CheckBox.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/CheckBox.kt
@@ -1,7 +1,7 @@
package pl.treksoft.kvision.form
-import pl.treksoft.kvision.panel.SimplePanel
import pl.treksoft.kvision.core.Widget
+import pl.treksoft.kvision.panel.SimplePanel
import pl.treksoft.kvision.snabbdom.SnOn
import pl.treksoft.kvision.snabbdom.StringBoolPair
@@ -14,9 +14,8 @@ enum class CHECKBOXSTYLE(val className: String) {
DANGER("checkbox-danger"),
}
-open class CheckBox(value: Boolean = false, name: String? = null, style: CHECKBOXSTYLE? = null,
- circled: Boolean = false, inline: Boolean = false, disabled: Boolean = false,
- label: String? = null, rich: Boolean = false) : SimplePanel(setOf("checkbox")), BoolFormField {
+open class CheckBox(value: Boolean = false, label: String? = null,
+ rich: Boolean = false) : SimplePanel(setOf("checkbox")), BoolFormField {
override var value
get() = input.value
@@ -48,17 +47,17 @@ open class CheckBox(value: Boolean = false, name: String? = null, style: CHECKBO
set(value) {
flabel.rich = value
}
- var style = style
+ var style: CHECKBOXSTYLE? = null
set(value) {
field = value
refresh()
}
- var circled = circled
+ var circled: Boolean = false
set(value) {
field = value
refresh()
}
- var inline = inline
+ var inline: Boolean = false
set(value) {
field = value
refresh()
@@ -70,7 +69,7 @@ open class CheckBox(value: Boolean = false, name: String? = null, style: CHECKBO
}
private val idc = "kv_form_checkbox_" + counter
- val input: CheckInput = CheckInput(CHECKINPUTTYPE.CHECKBOX, value, name, disabled, idc, null, setOf("styled"))
+ val input: CheckInput = CheckInput(CHECKINPUTTYPE.CHECKBOX, value, setOf("styled")).apply { id = idc }
val flabel: FieldLabel = FieldLabel(idc, label, rich)
init {
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/CheckInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/CheckInput.kt
index 07008ddd..36e59e87 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/CheckInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/CheckInput.kt
@@ -11,12 +11,9 @@ enum class CHECKINPUTTYPE(val type: String) {
}
open class CheckInput(type: CHECKINPUTTYPE = CHECKINPUTTYPE.CHECKBOX, override var value: Boolean = false,
- name: String? = null, disabled: Boolean = false, id: String? = null,
- extraValue: String? = null,
classes: Set<String> = setOf()) : Widget(classes), BoolFormField {
init {
- this.id = id
this.setInternalEventListener {
click = {
val v = getElementJQuery()?.prop("checked") as Boolean?
@@ -41,17 +38,17 @@ open class CheckInput(type: CHECKINPUTTYPE = CHECKINPUTTYPE.CHECKBOX, override v
field = value
refresh()
}
- var name: String? = name
+ var name: String? = null
set(value) {
field = value
refresh()
}
- override var disabled: Boolean = disabled
+ override var disabled: Boolean = false
set(value) {
field = value
refresh()
}
- var extraValue: String? = extraValue
+ var extraValue: String? = null
set(value) {
field = value
refresh()
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Password.kt b/src/main/kotlin/pl/treksoft/kvision/form/Password.kt
index 86a862cd..9b505e8b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/Password.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/Password.kt
@@ -1,6 +1,4 @@
package pl.treksoft.kvision.form
-open class Password(placeholder: String? = null, value: String? = null,
- name: String? = null, maxlength: Int? = null, label: String? = null, rich: Boolean = false,
- disabled: Boolean = false) : Text(TEXTINPUTTYPE.PASSWORD, placeholder, value, name, maxlength,
- label, rich, disabled)
+open class Password(value: String? = null, label: String? = null, rich: Boolean = false) : Text(TEXTINPUTTYPE.PASSWORD,
+ value, label, rich)
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Radio.kt b/src/main/kotlin/pl/treksoft/kvision/form/Radio.kt
index 66c2d75c..3ee6edff 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/Radio.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/Radio.kt
@@ -1,7 +1,7 @@
package pl.treksoft.kvision.form
-import pl.treksoft.kvision.panel.SimplePanel
import pl.treksoft.kvision.core.Widget
+import pl.treksoft.kvision.panel.SimplePanel
import pl.treksoft.kvision.snabbdom.SnOn
import pl.treksoft.kvision.snabbdom.StringBoolPair
@@ -14,9 +14,8 @@ enum class RADIOSTYLE(val className: String) {
DANGER("radio-danger"),
}
-open class Radio(value: Boolean = false, extraValue: String? = null, name: String? = null, style: RADIOSTYLE? = null,
- squared: Boolean = false, inline: Boolean = false, disabled: Boolean = false,
- label: String? = null, rich: Boolean = false) : SimplePanel(), BoolFormField {
+open class Radio(value: Boolean = false, extraValue: String? = null, label: String? = null,
+ rich: Boolean = false) : SimplePanel(), BoolFormField {
override var value
get() = input.value
@@ -53,17 +52,17 @@ open class Radio(value: Boolean = false, extraValue: String? = null, name: Strin
set(value) {
flabel.rich = value
}
- var style = style
+ var style: RADIOSTYLE? = null
set(value) {
field = value
refresh()
}
- var squared = squared
+ var squared: Boolean = false
set(value) {
field = value
refresh()
}
- var inline = inline
+ var inline: Boolean = false
set(value) {
field = value
refresh()
@@ -75,7 +74,10 @@ open class Radio(value: Boolean = false, extraValue: String? = null, name: Strin
}
private val idc = "kv_form_radio_" + counter
- val input: CheckInput = CheckInput(CHECKINPUTTYPE.RADIO, value, name, disabled, idc, extraValue)
+ val input: CheckInput = CheckInput(CHECKINPUTTYPE.RADIO, value).apply {
+ this.id = idc
+ this.extraValue = extraValue
+ }
val flabel: FieldLabel = FieldLabel(idc, label, rich)
init {
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Text.kt b/src/main/kotlin/pl/treksoft/kvision/form/Text.kt
index 44cbf0c9..01816195 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/Text.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/Text.kt
@@ -1,9 +1,8 @@
package pl.treksoft.kvision.form
-open class Text(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, placeholder: String? = null, value: String? = null,
- name: String? = null, maxlength: Int? = null, label: String? = null, rich: Boolean = false,
- disabled: Boolean = false) : AbstractText(label, rich) {
+open class Text(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null,
+ label: String? = null, rich: Boolean = false) : AbstractText(label, rich) {
var type
get() = input.type
@@ -16,7 +15,7 @@ open class Text(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, placeholder: String? =
input.autocomplete = value
}
- final override val input: TextInput = TextInput(type, placeholder, value, name, maxlength, disabled, idc)
+ final override val input: TextInput = TextInput(type, value).apply { id = idc }
init {
this.addInternal(input)
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/TextArea.kt b/src/main/kotlin/pl/treksoft/kvision/form/TextArea.kt
index 7cc45971..9b65a306 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/TextArea.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/TextArea.kt
@@ -1,8 +1,7 @@
package pl.treksoft.kvision.form
-open class TextArea(cols: Int? = null, rows: Int? = null, placeholder: String? = null, value: String? = null,
- name: String? = null, maxlength: Int? = null, label: String? = null, rich: Boolean = false,
- disabled: Boolean = false) : AbstractText(label, rich) {
+open class TextArea(cols: Int? = null, rows: Int? = null, value: String? = null,
+ label: String? = null, rich: Boolean = false) : AbstractText(label, rich) {
var cols
get() = input.cols
@@ -20,8 +19,7 @@ open class TextArea(cols: Int? = null, rows: Int? = null, placeholder: String? =
input.wrapHard = value
}
- final override val input: TextAreaInput = TextAreaInput(cols, rows, placeholder, value, name, maxlength,
- disabled, idc)
+ final override val input: TextAreaInput = TextAreaInput(cols, rows, value).apply { id = idc }
init {
this.addInternal(input)
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/TextAreaInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/TextAreaInput.kt
index 0b2c69fd..5b8dd5b5 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/TextAreaInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/TextAreaInput.kt
@@ -3,10 +3,8 @@ package pl.treksoft.kvision.form
import com.github.snabbdom.VNode
import pl.treksoft.kvision.snabbdom.StringPair
-class TextAreaInput(cols: Int? = null, rows: Int? = null, placeholder: String? = null,
- value: String? = null, name: String? = null, maxlength: Int? = null,
- disabled: Boolean = false, id: String? = null, classes: Set<String> = setOf()) :
- AbstractTextInput(placeholder, value, name, maxlength, disabled, id, classes) {
+class TextAreaInput(cols: Int? = null, rows: Int? = null, value: String? = null, classes: Set<String> = setOf()) :
+ AbstractTextInput(value, classes) {
var cols: Int? = cols
set(value) {
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/TextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/TextInput.kt
index 6cf0f239..7b3510ac 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/TextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/TextInput.kt
@@ -8,10 +8,8 @@ enum class TEXTINPUTTYPE(val type: String) {
PASSWORD("password")
}
-class TextInput(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, placeholder: String? = null,
- value: String? = null, name: String? = null, maxlength: Int? = null,
- disabled: Boolean = false, id: String? = null, classes: Set<String> = setOf()) :
- AbstractTextInput(placeholder, value, name, maxlength, disabled, id, classes) {
+class TextInput(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? = null, classes: Set<String> = setOf()) :
+ AbstractTextInput(value, classes) {
var type: TEXTINPUTTYPE = type
set(value) {
@@ -28,7 +26,6 @@ class TextInput(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, placeholder: String? =
return kvh("input")
}
- @Suppress("ComplexMethod")
override fun getSnAttrs(): List<StringPair> {
val sn = super.getSnAttrs().toMutableList()
sn.add("type" to type.type)
diff --git a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
index f0cb91f7..d14ce66e 100644
--- a/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/html/Button.kt
@@ -23,8 +23,7 @@ enum class BUTTONSIZE(val className: String) {
}
open class Button(text: String, icon: String? = null, style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT,
- disabled: Boolean = false, image: ResString? = null,
- classes: Set<String> = setOf()) : Widget(classes) {
+ disabled: Boolean = false, classes: Set<String> = setOf()) : Widget(classes) {
var text = text
set(value) {
field = value
@@ -45,12 +44,11 @@ open class Button(text: String, icon: String? = null, style: BUTTONSTYLE = BUTTO
field = value
refresh()
}
- var image = image
+ var image: ResString? = null
set(value) {
field = value
refresh()
}
-
var size: BUTTONSIZE? = null
set(value) {
field = value
diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
index 9c88326b..e2396868 100644
--- a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt
@@ -1,4 +1,5 @@
@file:Suppress("TooManyFunctions")
+
package pl.treksoft.kvision.utils
import pl.treksoft.kvision.core.CssSize
@@ -14,25 +15,22 @@ fun Int.cm(): CssSize = Pair(this, UNIT.cm)
fun Int.mm(): CssSize = Pair(this, UNIT.mm)
@Suppress("FunctionNaming")
fun Int.`in`(): CssSize = Pair(this, UNIT.`in`)
+
fun Int.pc(): CssSize = Pair(this, UNIT.pc)
fun Int.vh(): CssSize = Pair(this, UNIT.vh)
fun Int.vw(): CssSize = Pair(this, UNIT.vw)
fun Int.vmin(): CssSize = Pair(this, UNIT.vmin)
fun Int.vmax(): CssSize = Pair(this, UNIT.vmax)
-object Utils {
+private val hex = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f")
- private val hex = arrayOf("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f")
-
- @Suppress("MagicNumber")
- fun intToHexString(n: Int): String {
- var result = ""
- var num = n
- for (i in 0 until 6) {
- result = hex[num and 0xF] + result
- num = num shr 4
- }
- return result
+@Suppress("MagicNumber")
+fun Int.toHexString(): String {
+ var result = ""
+ var num = this
+ for (i in 0 until 6) {
+ result = hex[num and 0xF] + result
+ num = num shr 4
}
-
+ return result
}