summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/router.js
blob: 58625030cff766ce54af9cdf57b47ac35b562277 (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var SiteRouter = Router.extend({

	el: "body",
	
	routes: {
		"/":                  'login',
		"/index/:keyword":    'index',
		"/index":             'index',
		"/login":             'login',
		"/details/:id":       'details',
		"/post":              'post',
		"/post/:keyword":     'post',
		"/search":            'search',
		"/mail":              'mailbox',
		"/mail/:mailbox":     'mailbox',
		"/mail/compose":      'compose',
		"/message/:id":       'message',
		"/comment/:id/edit":  'editComment',
		"/profile":           'profile',
		"/profile/:username": 'profile',
	},
	
	initialize: function(){
  },
  
  index: function(keyword){
    app.view = new IndexView ()
    app.view.load(keyword)
  },
  
  login: function(){
    app.view = new LoginView ()
  },
  
  details: function(id){
    app.view = new DetailsView ()
    app.view.load(id)
  },
  
  editComment: function(id){
    app.view = new EditCommentForm ()
    app.view.load(id)
  },
  
  mailbox: function(box){
    app.view = new MailboxView ()
    app.view.load(box)
  },
  
  message: function(id){
    app.view = new MessageView ()
    app.view.load(id)
  },

  post: function(keyword){
    app.view = new ThreadForm ()
    app.view.load(keyword || "")
  },
  
  profile: function(username){
    app.view = new ProfileView ()
    app.view.load(username || auth.user.username)
  },
  
  compose: function(){
    app.view = new ComposeView ()
  },

  search: function(){
    app.view = new SearchResults ()
    app.view.load()
  },
  
})