Do something
This commit is contained in:
parent
6eff4b772d
commit
1b84ab88e3
11 changed files with 210 additions and 19 deletions
|
@ -11,7 +11,6 @@ import kotlin.js.Promise
|
|||
suspend fun repositoryGet(
|
||||
url: String
|
||||
): dynamic {
|
||||
console.log("GET: $url")
|
||||
val promise = Promise<dynamic> { resolve, reject ->
|
||||
val xhttp = XMLHttpRequest()
|
||||
|
||||
|
@ -48,7 +47,6 @@ suspend fun repositoryPost(
|
|||
url: String,
|
||||
data: String? = null
|
||||
): dynamic {
|
||||
console.log("POST: $url", data)
|
||||
val promise = Promise<dynamic> { resolve, reject ->
|
||||
val xhttp = XMLHttpRequest()
|
||||
|
||||
|
@ -85,7 +83,6 @@ suspend fun repositoryPost(
|
|||
suspend fun repositoryRawGet(
|
||||
url: String
|
||||
): String {
|
||||
console.log("GET: $url")
|
||||
val promise = Promise<String> { resolve, reject ->
|
||||
val xhttp = XMLHttpRequest()
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ import de.kif.frontend.iterator
|
|||
import de.kif.frontend.launch
|
||||
import de.kif.frontend.repository.ScheduleRepository
|
||||
import de.westermann.kwebview.View
|
||||
import de.westermann.kwebview.createHtmlView
|
||||
import org.w3c.dom.*
|
||||
import kotlin.browser.document
|
||||
import kotlin.browser.window
|
||||
|
||||
|
||||
class Calendar(calendar: HTMLElement) : View(calendar) {
|
||||
|
@ -15,23 +15,23 @@ class Calendar(calendar: HTMLElement) : View(calendar) {
|
|||
|
||||
val day: Int
|
||||
|
||||
val htmlTag = document.documentElement as HTMLHtmlElement
|
||||
val htmlTag = document.body as HTMLElement
|
||||
val calendarTable = calendar.getElementsByClassName("calendar-table")[0] as HTMLElement
|
||||
|
||||
fun scrollVerticalBy(pixel: Double) {
|
||||
htmlTag.scrollBy(ScrollToOptions(0.0, pixel, ScrollBehavior.SMOOTH))
|
||||
fun scrollVerticalBy(pixel: Double, scrollBehavior: ScrollBehavior = ScrollBehavior.SMOOTH) {
|
||||
htmlTag.scrollBy(ScrollToOptions(0.0, pixel, scrollBehavior))
|
||||
}
|
||||
|
||||
fun scrollHorizontalBy(pixel: Double) {
|
||||
calendarTable.scrollBy(ScrollToOptions(pixel, 0.0, ScrollBehavior.SMOOTH))
|
||||
fun scrollHorizontalBy(pixel: Double, scrollBehavior: ScrollBehavior = ScrollBehavior.SMOOTH) {
|
||||
calendarTable.scrollBy(ScrollToOptions(pixel, 0.0, scrollBehavior))
|
||||
}
|
||||
|
||||
fun scrollVerticalTo(pixel: Double) {
|
||||
htmlTag.scrollTo(ScrollToOptions(0.0, pixel, ScrollBehavior.SMOOTH))
|
||||
fun scrollVerticalTo(pixel: Double, scrollBehavior: ScrollBehavior = ScrollBehavior.SMOOTH) {
|
||||
htmlTag.scrollTo(ScrollToOptions(0.0, pixel, scrollBehavior))
|
||||
}
|
||||
|
||||
fun scrollHorizontalTo(pixel: Double) {
|
||||
calendarTable.scrollTo(ScrollToOptions(pixel, 0.0, ScrollBehavior.SMOOTH))
|
||||
fun scrollHorizontalTo(pixel: Double, scrollBehavior: ScrollBehavior = ScrollBehavior.SMOOTH) {
|
||||
calendarTable.scrollTo(ScrollToOptions(pixel, 0.0, scrollBehavior))
|
||||
}
|
||||
|
||||
init {
|
||||
|
@ -78,8 +78,7 @@ class Calendar(calendar: HTMLElement) : View(calendar) {
|
|||
}
|
||||
}
|
||||
|
||||
val view = View.wrap(document.getElementById("calendar-check-constraints") as HTMLElement)
|
||||
view.onClick {
|
||||
(document.getElementById("calendar-check-constraints") as? HTMLElement)?.let { wrap(it) }?.onClick?.addListener {
|
||||
launch {
|
||||
val errors = ScheduleRepository.checkConstraints()
|
||||
|
||||
|
@ -94,6 +93,19 @@ class Calendar(calendar: HTMLElement) : View(calendar) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
onWheel {
|
||||
val multiplier = when (it.deltaMode) {
|
||||
1 -> 16.0
|
||||
2 -> window.innerHeight.toDouble()
|
||||
else -> 1.0
|
||||
}
|
||||
|
||||
scrollHorizontalBy(it.deltaX * multiplier, ScrollBehavior.INSTANT)
|
||||
scrollVerticalBy(it.deltaY * multiplier, ScrollBehavior.INSTANT)
|
||||
|
||||
it.preventDefault()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue