diff options
Diffstat (limited to 'src/main/kotlin/pl/treksoft')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/ApplicationBase.kt | 21 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/HMR.kt | 15 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/core/Component.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt | 4 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/html/Label.kt (renamed from src/main/kotlin/pl/treksoft/kvision/basic/Label.kt) | 2 | ||||
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt | 5 |
7 files changed, 41 insertions, 10 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/ApplicationBase.kt b/src/main/kotlin/pl/treksoft/kvision/ApplicationBase.kt index e9e99fc7..83ad69ca 100644 --- a/src/main/kotlin/pl/treksoft/kvision/ApplicationBase.kt +++ b/src/main/kotlin/pl/treksoft/kvision/ApplicationBase.kt @@ -1,6 +1,23 @@ +/** + * @author Robert Jaros + */ package pl.treksoft.kvision +/** + * Base class for applications. + * + * Every application class should inherit from this abstract class. +*/ abstract class ApplicationBase { - abstract fun start(state: Map<String, Any>) - abstract fun dispose(): Map<String, Any> +/** + * Starting point for an application. + * @param state Initial state between Hot Module Replacement (HMR). +*/ +abstract fun start(state: Map<String, Any>) + +/** + * Ending point for an application. + * @return final state for Hot Module Replacement (HMR). +*/ +abstract fun dispose(): Map<String, Any> } diff --git a/src/main/kotlin/pl/treksoft/kvision/HMR.kt b/src/main/kotlin/pl/treksoft/kvision/HMR.kt index e657567a..6fb9dfed 100644 --- a/src/main/kotlin/pl/treksoft/kvision/HMR.kt +++ b/src/main/kotlin/pl/treksoft/kvision/HMR.kt @@ -1,11 +1,23 @@ +/** + * @author Robert Jaros + */ package pl.treksoft.kvision +/** + * Helper variable for Hot Module Replacement (HMR). + */ external val module: Module +/** + * Helper interface for Hot Module Replacement (HMR). + */ external interface Module { val hot: Hot? } +/** + * Helper interface for Hot Module Replacement (HMR). + */ external interface Hot { val data: dynamic @@ -16,4 +28,7 @@ external interface Hot { fun dispose(callback: (data: dynamic) -> Unit) } +/** + * External function for loading CommonJS modules. + */ external fun require(name: String): dynamic diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Component.kt b/src/main/kotlin/pl/treksoft/kvision/core/Component.kt index af5ac830..bdd254ba 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Component.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Component.kt @@ -8,8 +8,6 @@ import pl.treksoft.jquery.JQuery interface Component { var parent: Component? var visible: Boolean - var width: CssSize? - var height: CssSize? fun addCssClass(css: String): Widget fun removeCssClass(css: String): Widget diff --git a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt index f4bf6e09..b2676929 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt @@ -5,7 +5,7 @@ import pl.treksoft.kvision.utils.asString abstract class StyledComponent : Component { - override var width: CssSize? = null + open var width: CssSize? = null set(value) { field = value refresh() @@ -20,7 +20,7 @@ abstract class StyledComponent : Component { field = value refresh() } - override var height: CssSize? = null + var height: CssSize? = null set(value) { field = value refresh() diff --git a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt index 6f9dfaeb..af53807c 100644 --- a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt +++ b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt @@ -58,7 +58,7 @@ class DataContainer<M : DataComponent, C : Widget>( return this.child.renderVNode() } - fun get(index: Int) = model[index] + fun get(index: Int): M = model[index] override fun update() { model.forEach { it.container = this } diff --git a/src/main/kotlin/pl/treksoft/kvision/basic/Label.kt b/src/main/kotlin/pl/treksoft/kvision/html/Label.kt index a8d8bc16..3ce23639 100644 --- a/src/main/kotlin/pl/treksoft/kvision/basic/Label.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/Label.kt @@ -1,4 +1,4 @@ -package pl.treksoft.kvision.basic +package pl.treksoft.kvision.html import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt index 4f06a38f..722f60e6 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt @@ -3,6 +3,7 @@ package pl.treksoft.kvision.panel import com.github.snabbdom.VNode import pl.treksoft.jquery.JQuery import pl.treksoft.jquery.JQueryEventObject +import pl.treksoft.kvision.core.StyledComponent import pl.treksoft.kvision.core.UNIT import pl.treksoft.kvision.html.TAG import pl.treksoft.kvision.html.Tag @@ -39,9 +40,9 @@ open class SplitPanel( } onDragEnd = { e: JQueryEventObject, el: JQuery, _: dynamic -> if (horizontal) { - children[0].height = el.height().toInt() to px + (children[0] as? StyledComponent)?.height = el.height().toInt() to px } else { - children[0].width = el.width().toInt() to px + (children[0] as? StyledComponent)?.width = el.width().toInt() to px } self.dispatchEvent("dragEndSplitPanel", obj { detail = e }) } |