Improved architecture

This commit is contained in:
Eduard Urbach 2017-06-19 16:49:24 +02:00
parent be11e469b1
commit 10edd306f1
3 changed files with 25 additions and 14 deletions

15
scripts/AnimeNotifier.ts Normal file
View File

@ -0,0 +1,15 @@
import { Application } from "./Application"
export class AnimeNotifier {
app: Application
constructor(app: Application) {
this.app = app
}
run() {
this.app.content = this.app.find("content")
this.app.loading = this.app.find("loading")
this.app.run()
}
}

View File

@ -1,4 +1,4 @@
class Aero {
export class Application {
ajaxClass: string
fadeOutClass: string
activeLinkClass: string
@ -124,6 +124,8 @@ class Aero {
let link = links[i] as HTMLElement
link.classList.remove(this.ajaxClass)
let self = this
link.onclick = function(e) {
// Middle mouse button should have standard behaviour
if(e.which === 2)
@ -138,7 +140,7 @@ class Aero {
return
// Load requested page
aero.load(url, true)
self.load(url, true)
}
}
}
@ -156,6 +158,4 @@ class Aero {
parent.scrollTop = 0
}
}
}
export var aero = new Aero()
}

View File

@ -1,16 +1,12 @@
import { aero as app } from "./Aero/Aero"
import { Application } from "./Application"
import { AnimeNotifier } from "./AnimeNotifier"
class AnimeNotifier {
constructor() {
app.content = app.find("content")
app.loading = app.find("loading")
app.run()
}
}
let app = new Application()
let arn = new AnimeNotifier(app)
document.onreadystatechange = function() {
if(document.readyState === "interactive") {
let arn = new AnimeNotifier()
arn.run()
}
}