diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-03-08 11:28:01 +0100 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-03-08 11:28:01 +0100 |
commit | 19906e0305e054c1d951705335a61d41949565f4 (patch) | |
tree | 2d892436af252abca86ea6dd267681d371b2e1d7 /src | |
parent | 09d81e12fd4a41132cb711c282e98425dc1334cf (diff) | |
download | kvision-19906e0305e054c1d951705335a61d41949565f4.tar.gz kvision-19906e0305e054c1d951705335a61d41949565f4.tar.bz2 kvision-19906e0305e054c1d951705335a61d41949565f4.zip |
Add focus() and blur() methods to all FormControls.
Diffstat (limited to 'src')
12 files changed, 115 insertions, 8 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt index 2b974379..b74ae533 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/FormControl.kt @@ -92,6 +92,16 @@ interface FormControl : Component { validationInfo.visible = value != null refresh() } + + /** + * Makes the input element focused. + */ + fun focus() + + /** + * Makes the input element blur. + */ + fun blur() } /** diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt index 80790bdd..f1d231c6 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt @@ -187,6 +187,14 @@ open class CheckBox( return this } + override fun focus() { + input.focus() + } + + override fun blur() { + input.blur() + } + companion object { internal var counter = 0 diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt index a9e7b33d..0ed85e44 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt @@ -152,6 +152,20 @@ open class CheckInput( return this } + /** + * Makes the input element focused. + */ + open fun focus() { + getElementJQuery()?.focus() + } + + /** + * Makes the input element blur. + */ + open fun blur() { + getElementJQuery()?.blur() + } + companion object { /** * DSL builder extension function. diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt index 31ad41a2..5b02938c 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt @@ -207,6 +207,14 @@ open class Radio( return this } + override fun focus() { + input.focus() + } + + override fun blur() { + input.blur() + } + companion object { internal var counter = 0 diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt index 9a331b14..2ed8a36c 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt @@ -152,6 +152,14 @@ open class RadioGroup( this.addInternal(validationInfo) } + override fun focus() { + getChildren().filterIsInstance<Radio>().firstOrNull()?.focus() + } + + override fun blur() { + getChildren().filterIsInstance<Radio>().firstOrNull()?.blur() + } + companion object { internal var counter = 0 diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt index 0e5c7693..8d443ecf 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt @@ -270,6 +270,14 @@ open class Select( input.toggleOptions() } + override fun focus() { + input.focus() + } + + override fun blur() { + input.blur() + } + companion object { internal var counter = 0 diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt index e94d7e2f..87580139 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt @@ -329,6 +329,19 @@ open class SelectInput( } ?: getElementJQueryD()?.selectpicker("val", null) } + /** + * Makes the input element focused. + */ + open fun focus() { + getElementJQuery()?.focus() + } + + /** + * Makes the input element blur. + */ + open fun blur() { + getElementJQuery()?.blur() + } companion object { /** diff --git a/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt b/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt index c96bae26..0aa514b7 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt @@ -236,6 +236,14 @@ open class Spinner( return this } + override fun focus() { + input.focus() + } + + override fun blur() { + input.blur() + } + companion object { internal var counter = 0 diff --git a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt index a0da7999..b9903ff8 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt @@ -281,6 +281,20 @@ open class SpinnerInput( } } + /** + * Makes the input element focused. + */ + open fun focus() { + getElementJQuery()?.focus() + } + + /** + * Makes the input element blur. + */ + open fun blur() { + getElementJQuery()?.blur() + } + companion object { internal var counter = 0 diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt index c946af8c..1d3b5e01 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt @@ -167,17 +167,11 @@ abstract class AbstractText(label: String? = null, rich: Boolean = false) : return this } - /** - * Makes the input element focused. - */ - open fun focus() { + override fun focus() { input.focus() } - /** - * Makes the input element blur. - */ - open fun blur() { + override fun blur() { input.blur() } } diff --git a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt index f8b77893..dd6f222d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt @@ -232,6 +232,14 @@ open class DateTime( return input.getValueAsString() } + override fun focus() { + input.focus() + } + + override fun blur() { + input.blur() + } + companion object { internal var counter = 0 diff --git a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt index 867a3aba..d935487b 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt @@ -248,6 +248,20 @@ open class DateTimeInput( return value?.toStringF(format) } + /** + * Makes the input element focused. + */ + open fun focus() { + getElementJQuery()?.focus() + } + + /** + * Makes the input element blur. + */ + open fun blur() { + getElementJQuery()?.blur() + } + companion object { private fun String.toDatePickerFormat(): String { return this.replace("YY", "yy").replace("m", "i").replace("MMMM", "{----}").replace("MMM", "{---}") |