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 ajaxClass: string
fadeOutClass: string fadeOutClass: string
activeLinkClass: string activeLinkClass: string
@ -124,6 +124,8 @@ class Aero {
let link = links[i] as HTMLElement let link = links[i] as HTMLElement
link.classList.remove(this.ajaxClass) link.classList.remove(this.ajaxClass)
let self = this
link.onclick = function(e) { link.onclick = function(e) {
// Middle mouse button should have standard behaviour // Middle mouse button should have standard behaviour
if(e.which === 2) if(e.which === 2)
@ -138,7 +140,7 @@ class Aero {
return return
// Load requested page // Load requested page
aero.load(url, true) self.load(url, true)
} }
} }
} }
@ -157,5 +159,3 @@ class Aero {
} }
} }
} }
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 { let app = new Application()
constructor() { let arn = new AnimeNotifier(app)
app.content = app.find("content")
app.loading = app.find("loading")
app.run()
}
}
document.onreadystatechange = function() { document.onreadystatechange = function() {
if(document.readyState === "interactive") { if(document.readyState === "interactive") {
let arn = new AnimeNotifier() arn.run()
} }
} }