Update kotlin and komp versions, cleanup
This commit is contained in:
17
.idea/gradle.xml
generated
Normal file
17
.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/hotswap_agent.xml
generated
Normal file
6
.idea/hotswap_agent.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="HotSwapAgentPluginSettingsProvider">
|
||||
<option name="agentPath" value="$APPLICATION_PLUGINS_DIR$/hotswap-agent-intellij-plugin/lib/agent/hotswap-agent-1.0.jar" />
|
||||
</component>
|
||||
</project>
|
||||
7
.idea/kotlinc.xml
generated
Normal file
7
.idea/kotlinc.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Kotlin2JsCompilerArguments">
|
||||
<option name="sourceMapEmbedSources" />
|
||||
<option name="sourceMapPrefix" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,9 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: nl.astraeus:komp:0.0.5-SNAPSHOT" type="kotlin.js">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/nl.astraeus/komp/0.0.5-SNAPSHOT/f8a9999971b427dd21fb9bf55333d9b39a905b6d/komp-0.0.5-SNAPSHOT.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
9
.idea/libraries/Gradle__nl_astraeus_komp_0_0_8_SNAPSHOT.xml
generated
Normal file
9
.idea/libraries/Gradle__nl_astraeus_komp_0_0_8_SNAPSHOT.xml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: nl.astraeus:komp:0.0.8-SNAPSHOT" type="kotlin.js">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/nl.astraeus/komp/0.0.8-SNAPSHOT/9be02d3e617700ccd8dc6777497df76832c4e916/komp-0.0.8-SNAPSHOT.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
11
.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_1_4.xml
generated
Normal file
11
.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_1_4.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.1.4" type="kotlin.common">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.1.4/dc47c809e549ff5e48be235b682e2d6eaf9b1d9e/kotlin-stdlib-common-1.1.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.1.4/ee299091d089dbc770eac2d3b59383917dc14cc2/kotlin-stdlib-common-1.1.4-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
11
.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_2_21.xml
generated
Normal file
11
.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_js_1_2_21.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-js:1.2.21" type="kotlin.js">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-js/1.2.21/ff3f8ae5d1bd662bbb89dfc7a4ca70a8d663733/kotlin-stdlib-js-1.2.21.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-js/1.2.21/16a3f8f3704502ea2fd666e8aaffb3a33a095c2d/kotlin-stdlib-js-1.2.21-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
11
.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_common_0_6_4.xml
generated
Normal file
11
.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_common_0_6_4.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: org.jetbrains.kotlinx:kotlinx-html-common:0.6.4" type="kotlin.common">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-html-common/0.6.4/4ebf5aad41e363f63d196c4bbbee3662840288ca/kotlinx-html-common-0.6.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-html-common/0.6.4/ea347822bde2249e8e6fd8361c9596f36d69f7f1/kotlinx-html-common-0.6.4-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
11
.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_js_0_6_4.xml
generated
Normal file
11
.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_html_js_0_6_4.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Gradle: org.jetbrains.kotlinx:kotlinx-html-js:0.6.4" type="kotlin.js">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-html-js/0.6.4/a5a4863f2c5fd25f8bb9a1ddb55bb7def89ea5ed/kotlinx-html-js-0.6.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-html-js/0.6.4/5286978d3b689a42a353237f05161288f0e426ac/kotlinx-html-js-0.6.4-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/komp-todo.iml" filepath="$PROJECT_DIR$/komp-todo.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
53
build.gradle
53
build.gradle
@@ -1,8 +1,5 @@
|
||||
group 'nl.astraeus'
|
||||
version '0.0.1-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1.4-2'
|
||||
ext.kotlin_version = '1.2.21'
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
@@ -15,19 +12,27 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "com.eriwen:gradle-js-plugin:1.12.1"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
allprojects {
|
||||
ext {
|
||||
kotlin_version = '1.1.4-2'
|
||||
}
|
||||
plugins {
|
||||
id "com.eriwen.gradle.js" version "2.14.1"
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin2js'
|
||||
apply plugin: 'kotlin-dce-js'
|
||||
|
||||
group 'nl.astraeus'
|
||||
version '0.0.1-SNAPSHOT'
|
||||
|
||||
allprojects {
|
||||
ext {
|
||||
kotlin_version = '1.2.21'
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "http://nexus.astraeus.nl/nexus/content/groups/public"
|
||||
@@ -37,7 +42,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
compile "nl.astraeus:komp:0.0.6-SNAPSHOT"
|
||||
compile "nl.astraeus:komp:0.0.8-SNAPSHOT"
|
||||
}
|
||||
|
||||
compileKotlin2Js {
|
||||
@@ -45,7 +50,35 @@ compileKotlin2Js {
|
||||
|
||||
kotlinOptions.sourceMap = true
|
||||
kotlinOptions.sourceMapEmbedSources = "always"
|
||||
kotlinOptions.outputFile = "${projectDir}/web/js/kotlin/komp-todo.js"
|
||||
kotlinOptions.suppressWarnings = true
|
||||
kotlinOptions.verbose = true
|
||||
}
|
||||
|
||||
runDceKotlinJs.doLast {
|
||||
copy {
|
||||
from("build/kotlin-js-min/main")
|
||||
|
||||
into("web/js/generated")
|
||||
}
|
||||
}
|
||||
|
||||
// Create new CombineJsTasks if you have multiple sets of JS files
|
||||
task combineKotlinJs(type: com.eriwen.gradle.js.tasks.CombineJsTask) {
|
||||
dependsOn runDceKotlinJs
|
||||
source = [
|
||||
"${projectDir}/web/js/generated/kotlin.js",
|
||||
"${projectDir}/web/js/generated/min/kotlinx-html-js.js",
|
||||
"${projectDir}/web/js/generated/min/komp.js",
|
||||
"${projectDir}/web/js/generated/min/komp-todo.js"
|
||||
]
|
||||
dest = file("${projectDir}/web/js/generated/todo.all.js")
|
||||
}
|
||||
|
||||
minifyJs {
|
||||
source = combineKotlinJs
|
||||
dest = file("${projectDir}/web/js/generated/todo.all.min.js")
|
||||
closure {
|
||||
warningLevel = 'QUIET'
|
||||
compilerOptions.languageIn = "ECMASCRIPT5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,26 +3,26 @@
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="3" platform="JavaScript " useProjectSettings="false">
|
||||
<testOutputPath>$MODULE_DIR$/build/classes/test/komp-todo_test.js</testOutputPath>
|
||||
<compilerSettings>
|
||||
<option name="additionalArguments" value="-verbose" />
|
||||
</compilerSettings>
|
||||
<compilerArguments>
|
||||
<option name="outputFile" value="$MODULE_DIR$/web/js/kotlin/komp-todo.js" />
|
||||
<option name="outputFile" value="$MODULE_DIR$/build/classes/main/komp-todo.js" />
|
||||
<option name="noStdlib" value="true" />
|
||||
<option name="sourceMap" value="true" />
|
||||
<option name="sourceMapEmbedSources" value="inlining" />
|
||||
<option name="sourceMapEmbedSources" value="always" />
|
||||
<option name="metaInfo" value="true" />
|
||||
<option name="target" value="v5" />
|
||||
<option name="main" value="call" />
|
||||
<option name="languageVersion" value="1.1" />
|
||||
<option name="apiVersion" value="1.1" />
|
||||
<option name="languageVersion" value="1.2" />
|
||||
<option name="apiVersion" value="1.2" />
|
||||
<option name="pluginOptions">
|
||||
<array />
|
||||
</option>
|
||||
<option name="pluginClasspaths">
|
||||
<array />
|
||||
</option>
|
||||
<option name="verbose" value="true" />
|
||||
<option name="suppressWarnings" value="true" />
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
@@ -33,9 +33,7 @@
|
||||
<output-test url="file://$MODULE_DIR$/out/test/classes" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
@@ -45,20 +43,20 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-js:1.1.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: nl.astraeus:komp:0.0.6-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-js:0.6.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-common:0.6.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-js:1.1.4" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: nl.astraeus:komp:0.0.6-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-js:0.6.2" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-common:0.6.2" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-js:1.1.4" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: nl.astraeus:komp:0.0.6-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-js:0.6.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-common:0.6.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-js:1.2.21" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: nl.astraeus:komp:0.0.8-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-js:0.6.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-common:0.6.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.1.4" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-js:1.2.21" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: nl.astraeus:komp:0.0.8-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-js:0.6.4" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-common:0.6.4" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.1.4" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-js:1.2.21" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: nl.astraeus:komp:0.0.8-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-js:0.6.4" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlinx:kotlinx-html-common:0.6.4" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.1.4" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,32 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.eriwen:gradle-js-plugin:1.12.1"
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "com.eriwen.gradle.js" version "2.14.1"
|
||||
}
|
||||
|
||||
// Create new CombineJsTasks if you have multiple sets of JS files
|
||||
task combineKotlinJs(type: com.eriwen.gradle.js.tasks.CombineJsTask) {
|
||||
source = [
|
||||
"${projectDir}/web/js/kotlin/min/kotlin.js",
|
||||
"${projectDir}/web/js/kotlin/min/kotlinx-html-js.js",
|
||||
"${projectDir}/web/js/kotlin/min/komp.js",
|
||||
"${projectDir}/web/js/kotlin/min/komp-todo.js"
|
||||
]
|
||||
dest = file("${projectDir}/web/js/generated/todo.all.js")
|
||||
}
|
||||
|
||||
minifyJs {
|
||||
source = combineKotlinJs
|
||||
dest = file("${projectDir}/web/js/generated/todo.all.min.js")
|
||||
closure {
|
||||
warningLevel = 'QUIET'
|
||||
compilerOptions.languageIn = "ECMASCRIPT5"
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,30 @@
|
||||
package nl.astraeus.komp.todo
|
||||
|
||||
import kotlinx.html.*
|
||||
import kotlinx.html.InputType
|
||||
import kotlinx.html.TagConsumer
|
||||
import kotlinx.html.a
|
||||
import kotlinx.html.button
|
||||
import kotlinx.html.classes
|
||||
import kotlinx.html.div
|
||||
import kotlinx.html.dom.create
|
||||
import kotlinx.html.js.*
|
||||
import nl.astraeus.komp.Komponent
|
||||
import kotlinx.html.footer
|
||||
import kotlinx.html.h1
|
||||
import kotlinx.html.header
|
||||
import kotlinx.html.id
|
||||
import kotlinx.html.input
|
||||
import kotlinx.html.js.div
|
||||
import kotlinx.html.js.onClickFunction
|
||||
import kotlinx.html.js.onDoubleClickFunction
|
||||
import kotlinx.html.js.onKeyPressFunction
|
||||
import kotlinx.html.js.section
|
||||
import kotlinx.html.label
|
||||
import kotlinx.html.li
|
||||
import kotlinx.html.section
|
||||
import kotlinx.html.span
|
||||
import kotlinx.html.strong
|
||||
import kotlinx.html.ul
|
||||
import nl.astraeus.komp.DomDiffer
|
||||
import nl.astraeus.komp.Komponent
|
||||
import org.w3c.dom.HTMLElement
|
||||
import org.w3c.dom.HTMLInputElement
|
||||
import org.w3c.dom.events.Event
|
||||
@@ -17,242 +37,244 @@ import kotlin.js.Date
|
||||
*/
|
||||
|
||||
class Todo(
|
||||
val dataId: String,
|
||||
var title: String,
|
||||
var completed: Boolean = false,
|
||||
var editing: Boolean = false
|
||||
val dataId: String,
|
||||
var title: String,
|
||||
var completed: Boolean = false,
|
||||
var editing: Boolean = false
|
||||
)
|
||||
|
||||
enum class Selection(val title: String) {
|
||||
ALL("All"),
|
||||
ACTIVE("Active"),
|
||||
COMPLETED("Completed")
|
||||
ALL("All"),
|
||||
ACTIVE("Active"),
|
||||
COMPLETED("Completed")
|
||||
}
|
||||
|
||||
class TodoApp: Komponent() {
|
||||
val todoList: MutableList<Todo> = ArrayList()
|
||||
var selected: Selection = Selection.ALL
|
||||
class TodoApp : Komponent() {
|
||||
val todoList: MutableList<Todo> = ArrayList()
|
||||
var selected: Selection = Selection.ALL
|
||||
|
||||
fun addTodo(e: Event) {
|
||||
val target = e.target
|
||||
fun addTodo(e: Event) {
|
||||
val target = e.target
|
||||
|
||||
if (target is HTMLInputElement) {
|
||||
todoList.add(Todo("${Date().getTime()}", target.value))
|
||||
if (target is HTMLInputElement) {
|
||||
todoList.add(Todo("${Date().getTime()}", target.value))
|
||||
|
||||
refresh()
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
fun editTodo(e: Event, todo: Todo) {
|
||||
val target = e.target
|
||||
|
||||
if (target is HTMLInputElement) {
|
||||
todo.title = target.value
|
||||
todo.editing = false
|
||||
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun editTodo(e: Event, todo: Todo) {
|
||||
val target = e.target
|
||||
}
|
||||
|
||||
if (target is HTMLInputElement) {
|
||||
todo.title = target.value
|
||||
todo.editing = false
|
||||
fun destroyTodo(todo: Todo) {
|
||||
todoList.remove(todo)
|
||||
|
||||
refresh()
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
|
||||
}
|
||||
fun selectSelection(selection: Selection) {
|
||||
selected = selection
|
||||
|
||||
fun destroyTodo(todo: Todo) {
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun clearCompleted() {
|
||||
for (todo in ArrayList(todoList)) {
|
||||
if (todo.completed) {
|
||||
todoList.remove(todo)
|
||||
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
fun selectSelection(selection: Selection) {
|
||||
selected = selection
|
||||
refresh()
|
||||
}
|
||||
|
||||
refresh()
|
||||
fun todoClicked(todo: Todo) {
|
||||
todo.completed = !todo.completed
|
||||
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun getItemsLeft(): Int {
|
||||
var result = 0
|
||||
for (todo in todoList) {
|
||||
if (!todo.completed) {
|
||||
result++
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun setEditing(editTodo: Todo) {
|
||||
for (todo in todoList) {
|
||||
todo.editing = todo == editTodo
|
||||
}
|
||||
|
||||
fun clearCompleted() {
|
||||
for (todo in ArrayList(todoList)) {
|
||||
if (todo.completed) {
|
||||
todoList.remove(todo)
|
||||
refresh()
|
||||
}
|
||||
|
||||
override fun refresh() {
|
||||
super.refresh()
|
||||
|
||||
val inputBox = document.getElementById("todo_input")
|
||||
|
||||
if (inputBox is HTMLInputElement) {
|
||||
inputBox.focus()
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(consumer: TagConsumer<HTMLElement>) = consumer.section(classes = "todoapp") {
|
||||
header(classes = "header") {
|
||||
h1 { +"todos" }
|
||||
input(classes = "new-todo") {
|
||||
id = "todo_input"
|
||||
placeholder = "What needs to be done?"
|
||||
autoFocus = true
|
||||
onKeyPressFunction = { e ->
|
||||
if (e is KeyboardEvent && e.keyCode == 13) {
|
||||
addTodo(e)
|
||||
|
||||
val target = e.target
|
||||
|
||||
if (target is HTMLInputElement) {
|
||||
target.value = ""
|
||||
target.defaultValue = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
fun todoClicked(todo: Todo) {
|
||||
todo.completed = !todo.completed
|
||||
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun getItemsLeft(): Int {
|
||||
var result = 0
|
||||
section(classes = "main") {
|
||||
input(classes = "toggle-all") {
|
||||
type = InputType.checkBox
|
||||
}
|
||||
label {
|
||||
for_ = "toggle-all"
|
||||
+"Mark all as complete"
|
||||
}
|
||||
ul(classes = "todo-list") {
|
||||
for (todo in todoList) {
|
||||
if (!todo.completed) {
|
||||
result++
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun setEditing(editTodo: Todo) {
|
||||
for (todo in todoList) {
|
||||
todo.editing = todo == editTodo
|
||||
}
|
||||
|
||||
refresh()
|
||||
}
|
||||
|
||||
override fun refresh() {
|
||||
super.refresh()
|
||||
|
||||
val inputBox = document.getElementById("todo_input")
|
||||
|
||||
if (inputBox is HTMLInputElement) {
|
||||
inputBox.focus()
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(consumer: TagConsumer<HTMLElement>) = consumer.section(classes = "todoapp") {
|
||||
header(classes = "header") {
|
||||
h1 { + "todos" }
|
||||
input(classes = "new-todo") {
|
||||
id = "todo_input"
|
||||
placeholder = "What needs to be done?"
|
||||
autoFocus = true
|
||||
onKeyPressFunction = { e ->
|
||||
if (selected == Selection.ALL ||
|
||||
(todo.completed && selected == Selection.COMPLETED) ||
|
||||
(!todo.completed && selected == Selection.ACTIVE)) {
|
||||
li {
|
||||
if (todo.editing) {
|
||||
classes += "editing"
|
||||
input(classes = "edit") {
|
||||
value = todo.title
|
||||
onKeyPressFunction = { e ->
|
||||
if (e is KeyboardEvent && e.keyCode == 13) {
|
||||
addTodo(e)
|
||||
|
||||
val target = e.target
|
||||
|
||||
if (target is HTMLInputElement) {
|
||||
target.value = ""
|
||||
target.defaultValue = ""
|
||||
}
|
||||
editTodo(e, todo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
section(classes = "main") {
|
||||
input(classes = "toggle-all") {
|
||||
type = InputType.checkBox
|
||||
}
|
||||
label {
|
||||
for_ = "toggle-all"
|
||||
+ "Mark all as complete"
|
||||
}
|
||||
ul(classes = "todo-list") {
|
||||
for (todo in todoList) {
|
||||
if (selected == Selection.ALL ||
|
||||
(todo.completed && selected == Selection.COMPLETED) ||
|
||||
(!todo.completed && selected == Selection.ACTIVE)) {
|
||||
li {
|
||||
if (todo.editing) {
|
||||
classes += "editing"
|
||||
input(classes = "edit") {
|
||||
value = todo.title
|
||||
onKeyPressFunction = { e ->
|
||||
if (e is KeyboardEvent && e.keyCode == 13) {
|
||||
editTodo(e, todo)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (todo.completed) {
|
||||
classes += "completed"
|
||||
}
|
||||
attributes["data-id"] = todo.dataId
|
||||
div(classes = "view") {
|
||||
input(classes = "toggle") {
|
||||
type = InputType.checkBox
|
||||
checked = todo.completed
|
||||
onClickFunction = {
|
||||
todoClicked(todo)
|
||||
}
|
||||
}
|
||||
label(classes = "todo-content") {
|
||||
+todo.title
|
||||
|
||||
onDoubleClickFunction = {
|
||||
setEditing(todo)
|
||||
}
|
||||
}
|
||||
button(classes = "destroy") {
|
||||
onClickFunction = {
|
||||
destroyTodo(todo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (todo.completed) {
|
||||
classes += "completed"
|
||||
}
|
||||
attributes["data-id"] = todo.dataId
|
||||
div(classes = "view") {
|
||||
input(classes = "toggle") {
|
||||
type = InputType.checkBox
|
||||
checked = todo.completed
|
||||
onClickFunction = {
|
||||
todoClicked(todo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
label(classes = "todo-content") {
|
||||
+todo.title
|
||||
|
||||
footer(classes = "footer") {
|
||||
span(classes = "todo-count") {
|
||||
strong { + "${getItemsLeft()}" }
|
||||
+ " item left"
|
||||
}
|
||||
ul(classes = "filters") {
|
||||
for (selection in Selection.values())
|
||||
li {
|
||||
a {
|
||||
if (selection == selected) { classes += "selected" }
|
||||
href = "#"
|
||||
+ selection.title
|
||||
onClickFunction = {
|
||||
selectSelection(selection)
|
||||
}
|
||||
onDoubleClickFunction = {
|
||||
setEditing(todo)
|
||||
}
|
||||
}
|
||||
button(classes = "destroy") {
|
||||
onClickFunction = {
|
||||
destroyTodo(todo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
button(classes = "clear-completed") {
|
||||
+ "Clear completed"
|
||||
onClickFunction = {
|
||||
clearCompleted()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer(classes = "footer") {
|
||||
span(classes = "todo-count") {
|
||||
strong { +"${getItemsLeft()}" }
|
||||
+" item left"
|
||||
}
|
||||
ul(classes = "filters") {
|
||||
for (selection in Selection.values())
|
||||
li {
|
||||
a {
|
||||
if (selection == selected) {
|
||||
classes += "selected"
|
||||
}
|
||||
href = "#"
|
||||
+selection.title
|
||||
onClickFunction = {
|
||||
selectSelection(selection)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
button(classes = "clear-completed") {
|
||||
+"Clear completed"
|
||||
onClickFunction = {
|
||||
clearCompleted()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
Komponent.create(document.body!!, TodoApp(), true)
|
||||
Komponent.create(document.body!!, TodoApp(), true)
|
||||
|
||||
val el1 = document.create.div {
|
||||
div {
|
||||
div {
|
||||
id = "id1"
|
||||
span {
|
||||
+"Test"
|
||||
}
|
||||
}
|
||||
val el1 = document.create.div {
|
||||
div {
|
||||
div {
|
||||
id = "id1"
|
||||
span {
|
||||
+"Test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val el2 = document.create.div {
|
||||
div {
|
||||
id = "id1"
|
||||
span {
|
||||
+"Test"
|
||||
}
|
||||
input {
|
||||
name = "bla"
|
||||
}
|
||||
}
|
||||
val el2 = document.create.div {
|
||||
div {
|
||||
id = "id1"
|
||||
span {
|
||||
+"Test"
|
||||
}
|
||||
input {
|
||||
name = "bla"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// println("equals ${DomDiffer.match(el1, el2)}")
|
||||
// println("equals ${DomDiffer.match(el1, el2)}")
|
||||
|
||||
console.log("OLD", el1)
|
||||
console.log("NEW", el2)
|
||||
console.log("OLD", el1)
|
||||
console.log("NEW", el2)
|
||||
|
||||
DomDiffer.replaceDiff(el2, el1)
|
||||
DomDiffer.replaceDiff(el2, el1)
|
||||
|
||||
console.log("OLD", el1)
|
||||
console.log("NEW", el2)
|
||||
console.log("OLD", el1)
|
||||
console.log("NEW", el2)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
<p>Compare other javascript MVC* frameworks with <a href="http://todomvc.com">TodoMVC</a></p>
|
||||
</footer>
|
||||
|
||||
<script src="js/kotlin/dependencies/kotlin.js" ></script>
|
||||
<script src="js/kotlin/dependencies/kotlinx-html-js.js" ></script>
|
||||
<script src="js/kotlin/dependencies/komp.js" ></script>
|
||||
<script src="js/kotlin/komp-todo.js" ></script>
|
||||
<script src="js/generated/kotlin.js" ></script>
|
||||
<script src="js/generated/kotlinx-html-js.js" ></script>
|
||||
<script src="js/generated/komp.js" ></script>
|
||||
<script src="js/generated/komp-todo.js" ></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,439 +0,0 @@
|
||||
if (typeof kotlin === 'undefined') {
|
||||
throw new Error("Error loading module 'komp-todo'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'komp-todo'.");
|
||||
}
|
||||
if (typeof komp === 'undefined') {
|
||||
throw new Error("Error loading module 'komp-todo'. Its dependency 'komp' was not found. Please, check whether 'komp' is loaded prior to 'komp-todo'.");
|
||||
}
|
||||
if (typeof this['kotlinx-html-js'] === 'undefined') {
|
||||
throw new Error("Error loading module 'komp-todo'. Its dependency 'kotlinx-html-js' was not found. Please, check whether 'kotlinx-html-js' is loaded prior to 'komp-todo'.");
|
||||
}
|
||||
this['komp-todo'] = function (_, Kotlin, $module$komp, $module$kotlinx_html_js) {
|
||||
'use strict';
|
||||
var Enum = Kotlin.kotlin.Enum;
|
||||
var ArrayList_init = Kotlin.kotlin.collections.ArrayList_init_mqih57$;
|
||||
var Komponent = $module$komp.nl.astraeus.komp.Komponent;
|
||||
var h1 = $module$kotlinx_html_js.kotlinx.html.h1_vmej1w$;
|
||||
var set_id = $module$kotlinx_html_js.kotlinx.html.set_id_ueiko3$;
|
||||
var set_onKeyPressFunction = $module$kotlinx_html_js.kotlinx.html.js.set_onKeyPressFunction_pszlq2$;
|
||||
var input = $module$kotlinx_html_js.kotlinx.html.input_e1g74z$;
|
||||
var header = $module$kotlinx_html_js.kotlinx.html.header_8btlf7$;
|
||||
var InputType = $module$kotlinx_html_js.kotlinx.html.InputType;
|
||||
var label = $module$kotlinx_html_js.kotlinx.html.label_yd75js$;
|
||||
var get_classes = $module$kotlinx_html_js.kotlinx.html.get_classes_fxodxh$;
|
||||
var plus = Kotlin.kotlin.collections.plus_xfiyik$;
|
||||
var set_classes = $module$kotlinx_html_js.kotlinx.html.set_classes_njy09m$;
|
||||
var set_onClickFunction = $module$kotlinx_html_js.kotlinx.html.js.set_onClickFunction_pszlq2$;
|
||||
var set_onDoubleClickFunction = $module$kotlinx_html_js.kotlinx.html.js.set_onDoubleClickFunction_pszlq2$;
|
||||
var button = $module$kotlinx_html_js.kotlinx.html.button_whohl6$;
|
||||
var div = $module$kotlinx_html_js.kotlinx.html.div_ri36nr$;
|
||||
var li = $module$kotlinx_html_js.kotlinx.html.li_yzv5uh$;
|
||||
var ul = $module$kotlinx_html_js.kotlinx.html.ul_pzlyaf$;
|
||||
var section = $module$kotlinx_html_js.kotlinx.html.section_ac1jhf$;
|
||||
var strong = $module$kotlinx_html_js.kotlinx.html.strong_okpg28$;
|
||||
var span = $module$kotlinx_html_js.kotlinx.html.span_6djfml$;
|
||||
var a = $module$kotlinx_html_js.kotlinx.html.a_gu26kr$;
|
||||
var footer = $module$kotlinx_html_js.kotlinx.html.footer_780ap1$;
|
||||
var section_0 = $module$kotlinx_html_js.kotlinx.html.js.section_ceckl$;
|
||||
var ArrayList_init_0 = Kotlin.kotlin.collections.ArrayList_init_ww73n8$;
|
||||
var get_create = $module$kotlinx_html_js.kotlinx.html.dom.get_create_4wc2mh$;
|
||||
var div_0 = $module$kotlinx_html_js.kotlinx.html.js.div_wkomt5$;
|
||||
var komp = $module$komp.nl.astraeus.komp;
|
||||
Selection.prototype = Object.create(Enum.prototype);
|
||||
Selection.prototype.constructor = Selection;
|
||||
TodoApp.prototype = Object.create(Komponent.prototype);
|
||||
TodoApp.prototype.constructor = TodoApp;
|
||||
function Todo(dataId, title, completed, editing) {
|
||||
if (completed === void 0)
|
||||
completed = false;
|
||||
if (editing === void 0)
|
||||
editing = false;
|
||||
this.dataId = dataId;
|
||||
this.title = title;
|
||||
this.completed = completed;
|
||||
this.editing = editing;
|
||||
}
|
||||
Todo.$metadata$ = {
|
||||
kind: Kotlin.Kind.CLASS,
|
||||
simpleName: 'Todo',
|
||||
interfaces: []
|
||||
};
|
||||
function Selection(name, ordinal, title) {
|
||||
Enum.call(this);
|
||||
this.title = title;
|
||||
this.name$ = name;
|
||||
this.ordinal$ = ordinal;
|
||||
}
|
||||
function Selection_initFields() {
|
||||
Selection_initFields = function () {
|
||||
};
|
||||
Selection$ALL_instance = new Selection('ALL', 0, 'All');
|
||||
Selection$ACTIVE_instance = new Selection('ACTIVE', 1, 'Active');
|
||||
Selection$COMPLETED_instance = new Selection('COMPLETED', 2, 'Completed');
|
||||
}
|
||||
var Selection$ALL_instance;
|
||||
function Selection$ALL_getInstance() {
|
||||
Selection_initFields();
|
||||
return Selection$ALL_instance;
|
||||
}
|
||||
var Selection$ACTIVE_instance;
|
||||
function Selection$ACTIVE_getInstance() {
|
||||
Selection_initFields();
|
||||
return Selection$ACTIVE_instance;
|
||||
}
|
||||
var Selection$COMPLETED_instance;
|
||||
function Selection$COMPLETED_getInstance() {
|
||||
Selection_initFields();
|
||||
return Selection$COMPLETED_instance;
|
||||
}
|
||||
Selection.$metadata$ = {
|
||||
kind: Kotlin.Kind.CLASS,
|
||||
simpleName: 'Selection',
|
||||
interfaces: [Enum]
|
||||
};
|
||||
function Selection$values() {
|
||||
return [Selection$ALL_getInstance(), Selection$ACTIVE_getInstance(), Selection$COMPLETED_getInstance()];
|
||||
}
|
||||
Selection.values = Selection$values;
|
||||
function Selection$valueOf(name) {
|
||||
switch (name) {
|
||||
case 'ALL':
|
||||
return Selection$ALL_getInstance();
|
||||
case 'ACTIVE':
|
||||
return Selection$ACTIVE_getInstance();
|
||||
case 'COMPLETED':
|
||||
return Selection$COMPLETED_getInstance();
|
||||
default:Kotlin.throwISE('No enum constant nl.astraeus.komp.todo.Selection.' + name);
|
||||
}
|
||||
}
|
||||
Selection.valueOf_61zpoe$ = Selection$valueOf;
|
||||
function TodoApp() {
|
||||
Komponent.call(this);
|
||||
this.todoList = ArrayList_init_0();
|
||||
this.selected = Selection$ALL_getInstance();
|
||||
}
|
||||
TodoApp.prototype.addTodo_9ojx7i$ = function (e) {
|
||||
var target = e.target;
|
||||
if (Kotlin.isType(target, HTMLInputElement)) {
|
||||
this.todoList.add_11rb$(new Todo((new Date()).getTime().toString(), target.value));
|
||||
this.refresh();
|
||||
}
|
||||
};
|
||||
TodoApp.prototype.editTodo_y98rgd$ = function (e, todo) {
|
||||
var target = e.target;
|
||||
if (Kotlin.isType(target, HTMLInputElement)) {
|
||||
todo.title = target.value;
|
||||
todo.editing = false;
|
||||
this.refresh();
|
||||
}
|
||||
};
|
||||
TodoApp.prototype.destroyTodo_bcvlxp$ = function (todo) {
|
||||
this.todoList.remove_11rb$(todo);
|
||||
this.refresh();
|
||||
};
|
||||
TodoApp.prototype.selectSelection_uh5ef5$ = function (selection) {
|
||||
this.selected = selection;
|
||||
this.refresh();
|
||||
};
|
||||
TodoApp.prototype.clearCompleted = function () {
|
||||
var tmp$;
|
||||
tmp$ = ArrayList_init(this.todoList).iterator();
|
||||
while (tmp$.hasNext()) {
|
||||
var todo = tmp$.next();
|
||||
if (todo.completed) {
|
||||
this.todoList.remove_11rb$(todo);
|
||||
}
|
||||
}
|
||||
this.refresh();
|
||||
};
|
||||
TodoApp.prototype.todoClicked_bcvlxp$ = function (todo) {
|
||||
todo.completed = !todo.completed;
|
||||
this.refresh();
|
||||
};
|
||||
TodoApp.prototype.getItemsLeft = function () {
|
||||
var tmp$;
|
||||
var result = 0;
|
||||
tmp$ = this.todoList.iterator();
|
||||
while (tmp$.hasNext()) {
|
||||
var todo = tmp$.next();
|
||||
if (!todo.completed) {
|
||||
result = result + 1 | 0;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
TodoApp.prototype.setEditing_bcvlxp$ = function (editTodo) {
|
||||
var tmp$;
|
||||
tmp$ = this.todoList.iterator();
|
||||
while (tmp$.hasNext()) {
|
||||
var todo = tmp$.next();
|
||||
todo.editing = Kotlin.equals(todo, editTodo);
|
||||
}
|
||||
this.refresh();
|
||||
};
|
||||
TodoApp.prototype.refresh = function () {
|
||||
Komponent.prototype.refresh.call(this);
|
||||
var inputBox = document.getElementById('todo_input');
|
||||
if (Kotlin.isType(inputBox, HTMLInputElement)) {
|
||||
inputBox.focus();
|
||||
}
|
||||
};
|
||||
function TodoApp$render$lambda$lambda$lambda($receiver) {
|
||||
$receiver.unaryPlus_pdl1vz$('todos');
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda(this$TodoApp) {
|
||||
return function (e) {
|
||||
if (Kotlin.isType(e, KeyboardEvent) && e.keyCode === 13) {
|
||||
this$TodoApp.addTodo_9ojx7i$(e);
|
||||
var target = e.target;
|
||||
if (Kotlin.isType(target, HTMLInputElement)) {
|
||||
target.value = '';
|
||||
target.defaultValue = '';
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda_0(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
set_id($receiver, 'todo_input');
|
||||
$receiver.placeholder = 'What needs to be done?';
|
||||
$receiver.autoFocus = true;
|
||||
set_onKeyPressFunction($receiver, TodoApp$render$lambda$lambda$lambda$lambda(this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
h1($receiver, void 0, TodoApp$render$lambda$lambda$lambda);
|
||||
input($receiver, void 0, void 0, void 0, void 0, 'new-todo', TodoApp$render$lambda$lambda$lambda_0(this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda_1($receiver) {
|
||||
$receiver.type = InputType.checkBox;
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda_2($receiver) {
|
||||
$receiver.for_ = 'toggle-all';
|
||||
$receiver.unaryPlus_pdl1vz$('Mark all as complete');
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda(closure$todo, this$TodoApp) {
|
||||
return function (e) {
|
||||
if (Kotlin.isType(e, KeyboardEvent) && e.keyCode === 13) {
|
||||
this$TodoApp.editTodo_y98rgd$(e, closure$todo);
|
||||
}
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda(closure$todo, this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
$receiver.value = closure$todo.title;
|
||||
set_onKeyPressFunction($receiver, TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda(closure$todo, this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda$lambda(closure$todo, this$TodoApp) {
|
||||
return function (it) {
|
||||
this$TodoApp.todoClicked_bcvlxp$(closure$todo);
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda_0(closure$todo, this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
$receiver.type = InputType.checkBox;
|
||||
$receiver.checked = closure$todo.completed;
|
||||
set_onClickFunction($receiver, TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda$lambda(closure$todo, this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda$lambda_0(closure$todo, this$TodoApp) {
|
||||
return function (it) {
|
||||
this$TodoApp.setEditing_bcvlxp$(closure$todo);
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda_1(closure$todo, this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
$receiver.unaryPlus_pdl1vz$(closure$todo.title);
|
||||
set_onDoubleClickFunction($receiver, TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda$lambda_0(closure$todo, this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda$lambda_1(closure$todo, this$TodoApp) {
|
||||
return function (it) {
|
||||
this$TodoApp.destroyTodo_bcvlxp$(closure$todo);
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda_2(closure$todo, this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
set_onClickFunction($receiver, TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda$lambda_1(closure$todo, this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda_0(closure$todo, this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
input($receiver, void 0, void 0, void 0, void 0, 'toggle', TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda_0(closure$todo, this$TodoApp));
|
||||
label($receiver, 'todo-content', TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda_1(closure$todo, this$TodoApp));
|
||||
button($receiver, void 0, void 0, void 0, 'destroy', TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda_2(closure$todo, this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda_0(closure$todo, this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
if (closure$todo.editing) {
|
||||
set_classes($receiver, plus(get_classes($receiver), 'editing'));
|
||||
input($receiver, void 0, void 0, void 0, void 0, 'edit', TodoApp$render$lambda$lambda$lambda$lambda$lambda(closure$todo, this$TodoApp));
|
||||
}
|
||||
else {
|
||||
if (closure$todo.completed) {
|
||||
set_classes($receiver, plus(get_classes($receiver), 'completed'));
|
||||
}
|
||||
var $receiver_0 = $receiver.attributes;
|
||||
var value = closure$todo.dataId;
|
||||
$receiver_0.put_xwzc9p$('data-id', value);
|
||||
div($receiver, 'view', TodoApp$render$lambda$lambda$lambda$lambda$lambda_0(closure$todo, this$TodoApp));
|
||||
}
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda_3(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
var tmp$;
|
||||
tmp$ = this$TodoApp.todoList.iterator();
|
||||
while (tmp$.hasNext()) {
|
||||
var todo = tmp$.next();
|
||||
if (this$TodoApp.selected === Selection$ALL_getInstance() || (todo.completed && this$TodoApp.selected === Selection$COMPLETED_getInstance()) || (!todo.completed && this$TodoApp.selected === Selection$ACTIVE_getInstance())) {
|
||||
li($receiver, void 0, TodoApp$render$lambda$lambda$lambda$lambda_0(todo, this$TodoApp));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda_0(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
input($receiver, void 0, void 0, void 0, void 0, 'toggle-all', TodoApp$render$lambda$lambda$lambda_1);
|
||||
label($receiver, void 0, TodoApp$render$lambda$lambda$lambda_2);
|
||||
ul($receiver, 'todo-list', TodoApp$render$lambda$lambda$lambda_3(this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda_1(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
$receiver.unaryPlus_pdl1vz$(this$TodoApp.getItemsLeft().toString());
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda_4(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
strong($receiver, void 0, TodoApp$render$lambda$lambda$lambda$lambda_1(this$TodoApp));
|
||||
$receiver.unaryPlus_pdl1vz$(' item left');
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda_3(closure$selection, this$TodoApp) {
|
||||
return function (it) {
|
||||
this$TodoApp.selectSelection_uh5ef5$(closure$selection);
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda$lambda_1(closure$selection, this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
if (closure$selection === this$TodoApp.selected) {
|
||||
set_classes($receiver, plus(get_classes($receiver), 'selected'));
|
||||
}
|
||||
$receiver.href = '#';
|
||||
$receiver.unaryPlus_pdl1vz$(closure$selection.title);
|
||||
set_onClickFunction($receiver, TodoApp$render$lambda$lambda$lambda$lambda$lambda$lambda_3(closure$selection, this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda_2(closure$selection, this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
a($receiver, void 0, void 0, void 0, TodoApp$render$lambda$lambda$lambda$lambda$lambda_1(closure$selection, this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda_5(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
var tmp$, tmp$_0;
|
||||
tmp$ = Selection$values();
|
||||
for (tmp$_0 = 0; tmp$_0 !== tmp$.length; ++tmp$_0) {
|
||||
var selection = tmp$[tmp$_0];
|
||||
li($receiver, void 0, TodoApp$render$lambda$lambda$lambda$lambda_2(selection, this$TodoApp));
|
||||
}
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda$lambda_3(this$TodoApp) {
|
||||
return function (it) {
|
||||
this$TodoApp.clearCompleted();
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda$lambda_6(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
$receiver.unaryPlus_pdl1vz$('Clear completed');
|
||||
set_onClickFunction($receiver, TodoApp$render$lambda$lambda$lambda$lambda_3(this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda$lambda_1(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
span($receiver, 'todo-count', TodoApp$render$lambda$lambda$lambda_4(this$TodoApp));
|
||||
ul($receiver, 'filters', TodoApp$render$lambda$lambda$lambda_5(this$TodoApp));
|
||||
button($receiver, void 0, void 0, void 0, 'clear-completed', TodoApp$render$lambda$lambda$lambda_6(this$TodoApp));
|
||||
};
|
||||
}
|
||||
function TodoApp$render$lambda(this$TodoApp) {
|
||||
return function ($receiver) {
|
||||
header($receiver, 'header', TodoApp$render$lambda$lambda(this$TodoApp));
|
||||
section($receiver, 'main', TodoApp$render$lambda$lambda_0(this$TodoApp));
|
||||
footer($receiver, 'footer', TodoApp$render$lambda$lambda_1(this$TodoApp));
|
||||
};
|
||||
}
|
||||
TodoApp.prototype.render_q0cphf$ = function (consumer) {
|
||||
return section_0(consumer, 'todoapp', TodoApp$render$lambda(this));
|
||||
};
|
||||
TodoApp.$metadata$ = {
|
||||
kind: Kotlin.Kind.CLASS,
|
||||
simpleName: 'TodoApp',
|
||||
interfaces: [Komponent]
|
||||
};
|
||||
function main$lambda$lambda$lambda$lambda($receiver) {
|
||||
$receiver.unaryPlus_pdl1vz$('Test');
|
||||
}
|
||||
function main$lambda$lambda$lambda($receiver) {
|
||||
set_id($receiver, 'id1');
|
||||
span($receiver, void 0, main$lambda$lambda$lambda$lambda);
|
||||
}
|
||||
function main$lambda$lambda($receiver) {
|
||||
div($receiver, void 0, main$lambda$lambda$lambda);
|
||||
}
|
||||
function main$lambda($receiver) {
|
||||
div($receiver, void 0, main$lambda$lambda);
|
||||
}
|
||||
function main$lambda$lambda$lambda_0($receiver) {
|
||||
$receiver.unaryPlus_pdl1vz$('Test');
|
||||
}
|
||||
function main$lambda$lambda$lambda_1($receiver) {
|
||||
$receiver.name = 'bla';
|
||||
}
|
||||
function main$lambda$lambda_0($receiver) {
|
||||
set_id($receiver, 'id1');
|
||||
span($receiver, void 0, main$lambda$lambda$lambda_0);
|
||||
input($receiver, void 0, void 0, void 0, void 0, void 0, main$lambda$lambda$lambda_1);
|
||||
}
|
||||
function main$lambda_0($receiver) {
|
||||
div($receiver, void 0, main$lambda$lambda_0);
|
||||
}
|
||||
function main(args) {
|
||||
var tmp$;
|
||||
Komponent.Companion.create_nkol39$((tmp$ = document.body) != null ? tmp$ : Kotlin.throwNPE(), new TodoApp(), true);
|
||||
var el1 = div_0(get_create(document), void 0, main$lambda);
|
||||
var el2 = div_0(get_create(document), void 0, main$lambda_0);
|
||||
console.log('OLD', el1);
|
||||
console.log('NEW', el2);
|
||||
komp.DomDiffer.replaceDiff_26ucz2$(el2, el1);
|
||||
console.log('OLD', el1);
|
||||
console.log('NEW', el2);
|
||||
}
|
||||
var package$nl = _.nl || (_.nl = {});
|
||||
var package$astraeus = package$nl.astraeus || (package$nl.astraeus = {});
|
||||
var package$komp = package$astraeus.komp || (package$astraeus.komp = {});
|
||||
var package$todo = package$komp.todo || (package$komp.todo = {});
|
||||
package$todo.Todo = Todo;
|
||||
Object.defineProperty(Selection, 'ALL', {
|
||||
get: Selection$ALL_getInstance
|
||||
});
|
||||
Object.defineProperty(Selection, 'ACTIVE', {
|
||||
get: Selection$ACTIVE_getInstance
|
||||
});
|
||||
Object.defineProperty(Selection, 'COMPLETED', {
|
||||
get: Selection$COMPLETED_getInstance
|
||||
});
|
||||
package$todo.Selection = Selection;
|
||||
package$todo.TodoApp = TodoApp;
|
||||
package$todo.main_kand9s$ = main;
|
||||
main([]);
|
||||
Kotlin.defineModule('komp-todo', _);
|
||||
return _;
|
||||
}(typeof this['komp-todo'] === 'undefined' ? {} : this['komp-todo'], kotlin, komp, this['kotlinx-html-js']);
|
||||
|
||||
//# sourceMappingURL=komp-todo.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
// Kotlin.kotlin_module_metadata(65537, "komp-todo", "H4sIAAAAAAAAAIVX3VLbRhS2JVmWj4y9CAxGkCZ1yC8hcUibTnvRGUM9E6iZZgjt5FbIi5GRJXe15ucF8gC9yps0V73oRa/7Ru1ZWZZtjZCZQWe1+53/s+fIOaMGOSNnlj9r/03+8n9oOaMBZVAvfe46Hkj9wACQSA4ULUfypvxZCzFNWAXJc0GzAs4sOgpAufQHQ4NMsfjME0lwSILjBazFUsv0ZkiZM6Aet9xU+c9R/gQNluf53OKO76ViH8JSjJW7/iAVtA2VGKRwGvBU1BtYB9lnPZCv39igo5HnPhtYnk0zPBOi52KRKvobqM8bgPiuNeSUBRmyd6A6Y5B8c8EywD9CYxo022f+iDseDRLhvpv/AcBUWaoTu7A8Y07h3HFplvUiMiG8eHnBfM9Pj0wiNTfpqdmAEooJUTeGIgDiKBcXbP/3EWW3II2cVPYdqMVKdBtL1WJO4HvpFn0LG7EuUC74AJPreH1qcz8r/m/BTLKVbNQxGmQn+fu5qhMlDCq9wmwFxlqSCZ8SkQWrLFhXQRG1lwjIE0zTxNniGfOvA8pSHX2L1yyhWR4xd6Hax0BiBSqzvB5ND+QrWJmRX7z22WV2KOqgTVKZ8EnkZCpqCTuCc+7YYVfIEpjmYXDVW+jh65l6KTJ67mLyw26YdVfnSswVLM5dJfYUjBiMtYVtwLujFYoYJqpqkR3VhMsZ4BoUQnDalZrMAMdf3KOn7SYV+x5eLm5NABgI5niBYy+ufDGBEmFZ4GpYW2OOhLfJtka5fZEhaG7g9K/SB44YJQn7VJwP1MoyMa1a7WBxMOZSMWQ+xpQ7d6TiO9hMGgYWx7ifjXhmN2/B/dQrMVO/i+x8hKU5rzvVxGdY8hNNpYBiO8AJnO6NuKdzIwYK1/SslzXm5rpj5MedshORUpzBMEu2uDehOYX+yHPSxf6pwd9y2tcTTj+/60PpA41ax3Qstr3RAArc4S4F9YO4JFgjrU4H1NbB6eFvbSgd/HL8vtM+bf8EyqmQIre8W1C7FrcOu2IMod2U0y4U933fpRa6TrsOF3KKAt8aDqH0M6J8D+8iaEFoA+I1YVPHwe+V2Z4G+vGIW2cuDU+KVrcbKlV+RachT+8YZ1BoCwoVGy1gB7FNehe/h5h/G8rQhF3hqtyj/JDTQdCh5xzkQ+QU+WI0uMCpQ70uZaC/Oz3utF06CK2eTNtk2vRTq3cwOauOfZtGuRTESwgob0dx0YXnB65jX6KJysASebBYD71oMWbdGv/m06sdVE0mSj2HpwVcF4iKa0G1kCqkFFGIqB5SmZQj3FJESbRvhFQiK3WhrUDwQ1ojZD1CbYSaNvFkhWzhc5Xcw2eNfIWna+R+hNoOaY08CdHPEGGS57izSXYixF49Z26Z66RpSk1jr0xem5qhGFKz2Lz3RcvhBW7saZ/ydWVvvK001X3QJEMlRWQonkS0L2kl/Af815GtsaT9k69re4jflzRp/Fqaf4X49WNdx3V5fxulVoS0iXRDQ/eruFoKV8tidVIa73z8VDmJ4Li1PNkqjTlxKcz4K1+voOjqfu6oQuqhhyoxka4fqeSBeMf9r6N9Gal+tEYas7h4XyUPkdaPNPJInL9bQ+RjXG1gzJ5GMdtobuF+hbyIJOwiVfD9ZfTeCCVVyKtZjWjyqsAJ68ukFonSm8tfxJSS8MfaD/gbInGzivghG2C1Lmq9ZtRKzLDTmNXofuyK67HbD/4HjWl22g0OAAA=");
|
||||
Reference in New Issue
Block a user