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

  events: {
    "click": "next",
    "click .page-up": "previous",
    "click .page-down": "next",
    "click .top": "stopPropagation",
  },
  
  initialize: function(opt){
    // this.gallery = new GalleryView ()
    this.project_id = this.$el.data("id")
    this.page_number = opt.page_number
    console.log("INIT", this.project_id)
    $("<div>").addClass("page-up").insertAfter( this.$(".flickity-viewport") )
    $("<div>").addClass("page-down").insertAfter( this.$(".flickity-viewport") )
  },
  
  show: function(){
    app.header.updatePageNumber( this.page_number )
    app.header.updateSlideNumber( 0 )
    app.header.updateSlideCount( 1 )
    $('body').removeClass('navopen')
    this.$el.removeClass("hidden")
    this.$el.addClass("active")
    if (this.project_id == "cover") {
      app.router.pushState("/")
    }
    else {
      app.router.pushState("/project/" + this.project_id)
    }

    this.showing = true
    addClassForPeriod( this.el, "showing", app.navigation_delay, function(){
      this.showing = false
    }.bind(this) )
  },
  
  hide: function(){
    addClassForPeriod( this.el, "hiding", app.navigation_delay, function(){
      this.$el.addClass("hidden")
      this.$el.removeClass("active")
    }.bind(this) )
  },
  
  previous: function(e){
    e.stopPropagation()
    app.nav.previous()
  },

  next: function(e){
    e.stopPropagation()
    app.nav.next()
  },

})