Style changes

This commit is contained in:
2017-06-26 19:03:48 +02:00
parent 8a080f1156
commit 3d62ab8305
4 changed files with 47 additions and 31 deletions

View File

@ -1,6 +1,6 @@
import { Application } from "./Application"
import { Diff } from "./Diff"
import { findAll } from "./utils"
import { findAll, delay } from "./utils"
import * as actions from "./actions"
export class AnimeNotifier {
@ -153,6 +153,34 @@ export class AnimeNotifier {
}
}
diffURL(url: string) {
let request = fetch("/_" + url).then(response => response.text())
history.pushState(url, null, url)
this.app.currentPath = url
this.app.markActiveLinks()
this.loading(true)
this.unmountMountables()
// for(let element of findAll("mountable")) {
// element.classList.remove("mountable")
// }
delay(300).then(() => {
request
.then(html => this.app.setContent(html, true))
.then(() => this.app.markActiveLinks())
// .then(() => {
// for(let element of findAll("mountable")) {
// element.classList.remove("mountable")
// }
// })
.then(() => this.app.emit("DOMContentLoaded"))
.then(() => this.loading(false))
.catch(console.error)
})
}
onPopState(e: PopStateEvent) {
if(e.state) {
this.app.load(e.state, {

View File

@ -1,7 +1,6 @@
import { Application } from "./Application"
import { AnimeNotifier } from "./AnimeNotifier"
import { Diff } from "./Diff"
import { delay, findAll } from "./utils"
// Save new data from an input field
export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaElement) {
@ -61,31 +60,15 @@ export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaE
// Diff
export function diff(arn: AnimeNotifier, element: HTMLElement) {
let url = element.dataset.url || (element as HTMLAnchorElement).getAttribute("href")
let request = fetch("/_" + url).then(response => response.text())
arn.diffURL(url)
}
history.pushState(url, null, url)
arn.app.currentPath = url
arn.app.markActiveLinks()
arn.loading(true)
arn.unmountMountables()
// Forum reply
export function forumReply(arn: AnimeNotifier) {
let textarea = arn.app.find("new-reply") as HTMLTextAreaElement
// for(let element of findAll("mountable")) {
// element.classList.remove("mountable")
// }
delay(300).then(() => {
request
.then(html => arn.app.setContent(html, true))
.then(() => arn.app.markActiveLinks())
// .then(() => {
// for(let element of findAll("mountable")) {
// element.classList.remove("mountable")
// }
// })
.then(() => arn.app.emit("DOMContentLoaded"))
.then(() => arn.loading(false))
.catch(console.error)
})
console.log(textarea.value)
arn.diffURL(arn.app.currentPath)
}
// Search