summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/NavView.js
blob: 0ed1d4faf457120cb430032f7729587302eb3c5f (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
var NavView = View.extend({

  el: ".menu",
  
  events: {
    "click li": "click",
  },
  
  initialize: function(){
  },
  
  click: function(e){
    var id = $(e.target).data("id")
    var view = app.lookup[ id ]
    this.swap( view )
  },
  
  previous: function(){
    var index = Math.max( app.view.page_number - 1, 0 )
    var view = app.projects[ index ]
    this.swap( view )
  },
  
  next: function(){
    var index = Math.min( app.view.page_number + 1, app.projects.length - 1 )
    var view = app.projects[ index ]
    this.swap( view )
  },
  
  swap: function(view) {
    if (! view || app.view == view || app.view.showing) {
      return
    }

    console.log(view.page_number, view.project_id)

    app.view.hide()
    view.show()
    app.view = view
  },
  
})