From ce691e9b1409324af359afc721b8561c298d7b71 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 8 Oct 2017 00:16:18 +0200 Subject: Refactoring --- src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt | 1 - .../kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt | 10 +++++----- src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt | 6 ++++-- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/main/kotlin/pl/treksoft/kvision/panel') diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt index 781f8dcd..10483a8d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt @@ -124,7 +124,6 @@ open class FlexPanel(direction: FLEXDIR? = null, wrap: FLEXWRAP? = null, justify alignContent?.let { snstyle.add("align-content" to it.alignContent) } - println("abc") return snstyle } } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt index af4dd53f..17b3803f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt @@ -19,7 +19,7 @@ const val MAX_COLUMNS = 12 internal data class WidgetParam(val widget: Widget, val size: Int, val offset: Int) open class ResponsiveGridPanel(private val gridsize: GRIDSIZE = GRIDSIZE.MD, - private var rows: Int = 0, private var cols: Int = 0, align: ALIGN = ALIGN.NONE, + private var rows: Int = 0, private var cols: Int = 0, align: ALIGN? = null, classes: Set = setOf()) : Container(classes) { protected var align = align set(value) { @@ -87,8 +87,8 @@ open class ResponsiveGridPanel(private val gridsize: GRIDSIZE = GRIDSIZE.MD, val widget = wp?.widget?.let { WidgetWrapper(it, setOf("col-" + gridsize.size + "-" + num)) } ?: Tag(TAG.DIV, classes = setOf("col-" + gridsize.size + "-" + num)) - if (align != ALIGN.NONE) { - widget.addCssClass(align.className) + align?.let { + widget.addCssClass(it.className) } rowContainer.add(widget) } else { @@ -98,8 +98,8 @@ open class ResponsiveGridPanel(private val gridsize: GRIDSIZE = GRIDSIZE.MD, if (wp.offset > 0) { widget.addCssClass("col-" + gridsize.size + "-offset-" + wp.offset) } - if (align != ALIGN.NONE) { - widget.addCssClass(align.className) + align?.let { + widget.addCssClass(it.className) } rowContainer.add(widget) } diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt index 569a5b85..06f9be59 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt @@ -4,6 +4,7 @@ import com.github.snabbdom.VNode import pl.treksoft.jquery.JQuery import pl.treksoft.jquery.JQueryEventObject import pl.treksoft.kvision.core.Container +import pl.treksoft.kvision.core.UNIT import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag import pl.treksoft.kvision.snabbdom.obj @@ -23,6 +24,7 @@ open class SplitPanel(private val direction: DIRECTION = DIRECTION.VERTICAL, internal fun afterInsertSplitter() { if (children.size == 2) { val horizontal = direction == DIRECTION.HORIZONTAL + val px = UNIT.px val self = this children[0].getElementJQueryD().resizable(obj { handleSelector = "#" + splitter.id @@ -36,9 +38,9 @@ open class SplitPanel(private val direction: DIRECTION = DIRECTION.VERTICAL, } onDragEnd = { e: JQueryEventObject, el: JQuery, _: dynamic -> if (horizontal) { - children[0].height = el.height().toInt() + children[0].height = el.height().toInt() to px } else { - children[0].width = el.width().toInt() + children[0].width = el.width().toInt() to px } self.dispatchEvent("dragEndSplitPanel", obj({ detail = e })) } -- cgit