From e51fb2c8cc81c7af59f9be2454f81da3825da60a Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 21 Jan 2018 20:31:15 +0100 Subject: Examples refactoring --- src/main/assets/css/style.css | 116 --- src/main/assets/js/bootstrap-select-i18n.min.js | 1 - src/main/kotlin/pl/treksoft/kvision/Main.kt | 37 - src/main/kotlin/pl/treksoft/kvision/Showcase.kt | 823 --------------------- src/main/kotlin/pl/treksoft/kvision/core/Css.kt | 2 + src/main/kotlin/pl/treksoft/kvision/core/Img.kt | 10 - .../kotlin/pl/treksoft/kvision/core/KVManager.kt | 4 +- src/main/resources/css/style.css | 116 +++ src/main/resources/js/bootstrap-select-i18n.min.js | 1 + src/main/web/index.html | 3 +- 10 files changed, 122 insertions(+), 991 deletions(-) delete mode 100644 src/main/assets/css/style.css delete mode 100644 src/main/assets/js/bootstrap-select-i18n.min.js delete mode 100644 src/main/kotlin/pl/treksoft/kvision/Main.kt delete mode 100644 src/main/kotlin/pl/treksoft/kvision/Showcase.kt delete mode 100644 src/main/kotlin/pl/treksoft/kvision/core/Img.kt create mode 100644 src/main/resources/css/style.css create mode 100644 src/main/resources/js/bootstrap-select-i18n.min.js (limited to 'src/main') diff --git a/src/main/assets/css/style.css b/src/main/assets/css/style.css deleted file mode 100644 index 3e7ee728..00000000 --- a/src/main/assets/css/style.css +++ /dev/null @@ -1,116 +0,0 @@ -.splitpanel-vertical { - display: flex; - flex-direction: row; - overflow: auto; -} - -.splitpanel-vertical > *:first-child { - max-width: calc(100% - 9px); -} - -.splitpanel-vertical > * { - flex: 0 0 auto; - overflow: auto; -} - -.splitpanel-vertical > *:last-child { - flex: 1 1 auto; - overflow: auto; -} - -.splitpanel-horizontal { - display: flex; - flex-direction: column; - overflow: auto; -} - -.splitpanel-horizontal > *:first-child { - max-height: calc(100% - 9px); -} - -.splitpanel-horizontal > * { - flex: 0 0 auto; - overflow: auto; -} - -.splitpanel-horizontal > *:last-child { - flex: 1 1 auto; - overflow: auto; -} - - -.splitter-vertical { - flex: 0 0 auto; - width: 9px; - background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAhCAQAAABOpSL+AAAAIklEQVR4AWMwbb/PdR+JZDD9f1/oPhI5sgVGBSruc9xHIgGdSQqqQJGkRgAAAABJRU5ErkJggg==') center center no-repeat #cecece; - cursor: col-resize; -} - -.splitter-horizontal { - flex: 0 0 auto; - height: 9px; - background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAICAQAAADdTl4aAAAAIElEQVQoz2MwrTD9TxFsZ7jPcV+IIsjFQAUw6hFqegQA+xzRHT2p7pEAAAAASUVORK5CYII=') center center no-repeat #cecece; - cursor: row-resize; -} - -.trix-control { - overflow-y: auto; -} - -trix-toolbar .trix-button-group { - margin-bottom: 3px; -} - -.form-inline .form-group { - margin-right:6px; -} - -.form-inline .checkbox, .form-inline .radio { - margin-right:6px; -} - -.form-inline .form-group .form-control { - margin-left:6px; -} - -.form-horizontal .checkbox, .form-horizontal .radio { - padding-left: 25px; -} - -.form-inline .form-group trix-editor.form-control { - margin-left: 0px; - width: 100%; -} - -.form-inline .form-group, .form-inline .control-label { - vertical-align: top; -} - -.bootstrap-touchspin .input-group-btn-vertical> .input-sm { - padding: 7px 10px; - height: 6px; -} - -.bootstrap-touchspin .input-group-btn-vertical> .input-lg { - height: 24px; -} - -.kv-spinner-btn-none .input-group-btn-vertical { - display: none; -} - -.kv-spinner-btn-none .form-control { - border-radius: 4px !important; -} - -.kv-spinner-btn-vertical .form-control { - border-radius: 4px 0px 0px 4px !important; -} - -.kv-radiogroup .radio { - margin-top: -5px; -} - -.kv-radiogroup-inline label { - margin-right: 10px; -} diff --git a/src/main/assets/js/bootstrap-select-i18n.min.js b/src/main/assets/js/bootstrap-select-i18n.min.js deleted file mode 100644 index 4428d3c0..00000000 --- a/src/main/assets/js/bootstrap-select-i18n.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof module&&module.exports?module.exports=b(require("jquery")):b(a.jQuery)}(this,function(a){!function(a){a.fn.selectpicker.defaults={noneSelectedText:"",noneResultsText:"",countSelectedText:function(a,b){return 1==a?"... ({n})":"... ({n})"},maxOptionsText:function(a,b){return[1==a?"🛇":"🛇",1==b?"🛇":"🛇"]},selectAllText:"++",deselectAllText:"--",multipleSeparator:", "}}(a)}); \ No newline at end of file diff --git a/src/main/kotlin/pl/treksoft/kvision/Main.kt b/src/main/kotlin/pl/treksoft/kvision/Main.kt deleted file mode 100644 index e4816888..00000000 --- a/src/main/kotlin/pl/treksoft/kvision/Main.kt +++ /dev/null @@ -1,37 +0,0 @@ -package pl.treksoft.kvision - -import pl.treksoft.kvision.core.KVManager -import kotlin.browser.document - -fun main(args: Array) { - var application: ApplicationBase? = null - - val state: dynamic = module.hot?.let { hot -> - hot.accept() - - hot.dispose { data -> - data.appState = application?.dispose() - KVManager.shutdown() - application = null - } - - hot.data - } - - if (document.body != null) { - application = start(state) - } else { - KVManager.init() - application = null - document.addEventListener("DOMContentLoaded", { application = start(state) }) - } -} - -fun start(state: dynamic): ApplicationBase? { - if (document.getElementById("showcase") == null) return null - val application = Showcase() - @Suppress("UnsafeCastFromDynamic") - application.start(state?.appState ?: emptyMap()) - return application -} - diff --git a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt b/src/main/kotlin/pl/treksoft/kvision/Showcase.kt deleted file mode 100644 index 51f0213b..00000000 --- a/src/main/kotlin/pl/treksoft/kvision/Showcase.kt +++ /dev/null @@ -1,823 +0,0 @@ -package pl.treksoft.kvision - -import com.lightningkite.kotlin.observable.list.observableListOf -import pl.treksoft.kvision.basic.Label -import pl.treksoft.kvision.core.* -import pl.treksoft.kvision.data.DataComponent -import pl.treksoft.kvision.data.DataContainer -import pl.treksoft.kvision.dropdown.DD.* -import pl.treksoft.kvision.dropdown.DropDown -import pl.treksoft.kvision.form.Form -import pl.treksoft.kvision.form.FormPanel -import pl.treksoft.kvision.form.INPUTSIZE -import pl.treksoft.kvision.form.bool -import pl.treksoft.kvision.form.check.CheckBox -import pl.treksoft.kvision.form.check.Radio -import pl.treksoft.kvision.form.check.RadioGroup -import pl.treksoft.kvision.form.date -import pl.treksoft.kvision.form.select.AjaxOptions -import pl.treksoft.kvision.form.select.SELECTWIDTHTYPE -import pl.treksoft.kvision.form.select.Select -import pl.treksoft.kvision.form.select.SelectInput -import pl.treksoft.kvision.form.select.SelectOptGroup -import pl.treksoft.kvision.form.select.SelectOption -import pl.treksoft.kvision.form.spinner.FORCETYPE -import pl.treksoft.kvision.form.spinner.Spinner -import pl.treksoft.kvision.form.spinner.SpinnerInput -import pl.treksoft.kvision.form.string -import pl.treksoft.kvision.form.text.Password -import pl.treksoft.kvision.form.text.RichText -import pl.treksoft.kvision.form.text.TEXTINPUTTYPE -import pl.treksoft.kvision.form.text.Text -import pl.treksoft.kvision.form.text.TextArea -import pl.treksoft.kvision.form.text.TextAreaInput -import pl.treksoft.kvision.form.text.TextInput -import pl.treksoft.kvision.form.time.DateTime -import pl.treksoft.kvision.form.time.DateTimeInput -import pl.treksoft.kvision.html.* -import pl.treksoft.kvision.html.TAG.DIV -import pl.treksoft.kvision.html.TAG.H1 -import pl.treksoft.kvision.modal.Alert -import pl.treksoft.kvision.modal.Confirm -import pl.treksoft.kvision.modal.Modal -import pl.treksoft.kvision.panel.* -import pl.treksoft.kvision.routing.routing -import pl.treksoft.kvision.snabbdom.obj -import pl.treksoft.kvision.utils.perc -import pl.treksoft.kvision.utils.px -import pl.treksoft.kvision.utils.toDateF -import kotlin.js.Date - -class Showcase : ApplicationBase() { - - override fun start(state: Map) { - data class DataForm(val a: String?, val b: Boolean?, val c: Date?) - - val f = DataForm("ala", true, Date()) - val form = Form { - DataForm(it.string("a"), it.bool("b"), it.date("c")) - } - form.add("a", Text()) - form.add("b", CheckBox()) - form.add("c", DateTime()) - form.setData(f) - val ret = form.getData() - console.log(ret) - - class DataFormMap(map: Map) { - val name: String by map - val age: Date by map - } - - val fm = DataFormMap(mapOf("name" to "Ala", "age" to Date())) - val formm = Form { - DataFormMap(it) - } - formm.add("name", Text()) - formm.add("age", DateTime()) - formm.setData(fm) - val retm = formm.getData() - console.log(retm.name) - console.log(retm.age) - - val root = Root("showcase") - - class Model(p: Boolean, t: String) : DataComponent() { - var p: Boolean by obs(p) - var t: String by obs(t) - } - - val model = observableListOf(Model(true, "Pierwszy"), Model(false, "Drugi"), Model(false, "Trzeci")) - val datac = DataContainer(model, { element, index -> - CheckBox( - value = element.p, - label = if (element.p) "" + (index + 1) + " " + element.t + "" else element.t, - rich = true - ).setEventListener({ - click = { - element.p = self.value - } - }) - }) - root.add(datac) - - val mbutton = Button("Pokaż wartości").setEventListener