-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (23 loc) · 657 Bytes
/
app.js
File metadata and controls
30 lines (23 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var domready = require('domready')
, CustomerList = require('./customers/index')
, CustomerView = require('./customers/view')
, routing = require('./navigation')
, container = null
, currentPage = null
function run(){
container = document.getElementById('container')
routing.route(/^customer\/(.+)/, function(path) {
switchTo(CustomerView, { name: path.split('/')[1] })
})
routing.route(/^$/, function() {
switchTo(CustomerList)
})
routing.start({
pushState: true
})
}
function switchTo(Presenter, options) {
if(currentPage) currentPage.detach()
currentPage = new Presenter(container, options)
}
domready(run)