diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-10-17 21:58:34 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-10-17 21:58:34 +0200 |
commit | 736b80835f67c9c34657074ebcfbe0752bef1c18 (patch) | |
tree | 82d1e18a9ec07692dfe5dd31f470b842a9950a89 /kvision-modules/kvision-bootstrap-spinner/src/main | |
parent | 53b325d52208bfd44ba6a524ce3dda5379aed699 (diff) | |
download | kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.gz kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.bz2 kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.zip |
Move DSL builder functions out of the companion objects (#93)
Diffstat (limited to 'kvision-modules/kvision-bootstrap-spinner/src/main')
2 files changed, 47 insertions, 50 deletions
diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt index 7e3048d1..450d4466 100644 --- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt +++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt @@ -254,34 +254,34 @@ open class Spinner( companion object { internal var counter = 0 + } +} - /** - * DSL builder extension function. - * - * It takes the same parameters as the constructor of the built component. - */ - fun Container.spinner( - value: Number? = null, - name: String? = null, - min: Int? = null, - max: Int? = null, - step: Double = DEFAULT_STEP, - decimals: Int = 0, - buttonsType: ButtonsType = ButtonsType.VERTICAL, - forceType: ForceType = ForceType.NONE, - buttonStyle: ButtonStyle? = null, - label: String? = null, - rich: Boolean = false, - init: (Spinner.() -> Unit)? = null - ): Spinner { - val spinner = - Spinner(value, name, min, max, step, decimals, buttonsType, forceType, buttonStyle, label, rich).apply { - init?.invoke( - this - ) - } - this.add(spinner) - return spinner +/** + * DSL builder extension function. + * + * It takes the same parameters as the constructor of the built component. + */ +fun Container.spinner( + value: Number? = null, + name: String? = null, + min: Int? = null, + max: Int? = null, + step: Double = DEFAULT_STEP, + decimals: Int = 0, + buttonsType: ButtonsType = ButtonsType.VERTICAL, + forceType: ForceType = ForceType.NONE, + buttonStyle: ButtonStyle? = null, + label: String? = null, + rich: Boolean = false, + init: (Spinner.() -> Unit)? = null +): Spinner { + val spinner = + Spinner(value, name, min, max, step, decimals, buttonsType, forceType, buttonStyle, label, rich).apply { + init?.invoke( + this + ) } - } + this.add(spinner) + return spinner } diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt index c75bbfc4..c68df816 100644 --- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt +++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt @@ -313,28 +313,25 @@ open class SpinnerInput( override fun blur() { getElementJQuery()?.blur() } +} - companion object { - - /** - * DSL builder extension function. - * - * It takes the same parameters as the constructor of the built component. - */ - fun Container.spinnerInput( - value: Number? = null, min: Int? = null, max: Int? = null, step: Double = DEFAULT_STEP, - decimals: Int = 0, buttonsType: ButtonsType = ButtonsType.VERTICAL, - forceType: ForceType = ForceType.NONE, buttonStyle: ButtonStyle? = null, classes: Set<String> = setOf(), - init: (SpinnerInput.() -> Unit)? = null - ): SpinnerInput { - val spinnerInput = - SpinnerInput(value, min, max, step, decimals, buttonsType, forceType, buttonStyle, classes).apply { - init?.invoke( - this - ) - } - this.add(spinnerInput) - return spinnerInput +/** + * DSL builder extension function. + * + * It takes the same parameters as the constructor of the built component. + */ +fun Container.spinnerInput( + value: Number? = null, min: Int? = null, max: Int? = null, step: Double = DEFAULT_STEP, + decimals: Int = 0, buttonsType: ButtonsType = ButtonsType.VERTICAL, + forceType: ForceType = ForceType.NONE, buttonStyle: ButtonStyle? = null, classes: Set<String> = setOf(), + init: (SpinnerInput.() -> Unit)? = null +): SpinnerInput { + val spinnerInput = + SpinnerInput(value, min, max, step, decimals, buttonsType, forceType, buttonStyle, classes).apply { + init?.invoke( + this + ) } - } + this.add(spinnerInput) + return spinnerInput } |