aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2017-11-09 12:21:43 +0100
committerRobert Jaros <rjaros@finn.pl>2017-11-09 12:21:43 +0100
commit25ab470ea458b2652ff77e2a66a856c63553c486 (patch)
tree1bba0a1e4972b91664edb5948b2d41e4ce9870e0 /src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
parent5195caf0405eea7a6b34f60cb0a1bea3026bac3c (diff)
downloadkvision-25ab470ea458b2652ff77e2a66a856c63553c486.tar.gz
kvision-25ab470ea458b2652ff77e2a66a856c63553c486.tar.bz2
kvision-25ab470ea458b2652ff77e2a66a856c63553c486.zip
Refactoring packages
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt111
1 files changed, 0 insertions, 111 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
deleted file mode 100644
index 8f0a09e0..00000000
--- a/src/main/kotlin/pl/treksoft/kvision/form/AbstractTextInput.kt
+++ /dev/null
@@ -1,111 +0,0 @@
-package pl.treksoft.kvision.form
-
-import pl.treksoft.kvision.core.Widget
-import pl.treksoft.kvision.snabbdom.StringBoolPair
-import pl.treksoft.kvision.snabbdom.StringPair
-
-abstract class AbstractTextInput(value: String? = null,
- classes: Set<String> = setOf()) : Widget(classes + "form-control"), StringFormField {
-
- init {
- this.setInternalEventListener<AbstractTextInput> {
- input = {
- val v = getElementJQuery()?.`val`() as String?
- if (v != null && v.isNotEmpty()) {
- self.value = v
- } else {
- self.value = null
- }
- }
- }
- }
-
- override var value: String? = value
- set(value) {
- field = value
- refreshState()
- }
- @Suppress("LeakingThis")
- var startValue: String? = value
- set(value) {
- field = value
- this.value = value
- refresh()
- }
- var placeholder: String? = null
- set(value) {
- field = value
- refresh()
- }
- var name: String? = null
- set(value) {
- field = value
- refresh()
- }
- var maxlength: Int? = null
- set(value) {
- field = value
- refresh()
- }
- override var disabled: Boolean = false
- set(value) {
- field = value
- refresh()
- }
- var autofocus: Boolean? = null
- set(value) {
- field = value
- refresh()
- }
- var readonly: Boolean? = null
- set(value) {
- field = value
- refresh()
- }
- override var size: INPUTSIZE? = null
- set(value) {
- field = value
- refresh()
- }
-
- override fun getSnClass(): List<StringBoolPair> {
- val cl = super.getSnClass().toMutableList()
- size?.let {
- cl.add(it.className to true)
- }
- return cl
- }
-
- override fun getSnAttrs(): List<StringPair> {
- val sn = super.getSnAttrs().toMutableList()
- placeholder?.let {
- sn.add("placeholder" to it)
- }
- name?.let {
- sn.add("name" to it)
- }
- autofocus?.let {
- if (it) {
- sn.add("autofocus" to "autofocus")
- }
- }
- maxlength?.let {
- sn.add("maxlength" to ("" + it))
- }
- readonly?.let {
- if (it) {
- sn.add("readonly" to "readonly")
- }
- }
- if (disabled) {
- sn.add("disabled" to "true")
- }
- return sn
- }
-
- private fun refreshState() {
- value?.let {
- getElementJQuery()?.`val`(it)
- } ?: getElementJQueryD()?.`val`(null)
- }
-}