summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/ProjectView.js
blob: b119b65996c70d1ec293a1e6632a084e590467b5 (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 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
    this.slide_count = this.$(".cell").length
    console.log("INIT", this.project_id)

    var $viewport = this.$(".flickity-viewport")
    if (! $viewport.length) {
      $viewport = this.$(".cell")
    }
    if ($viewport.length) {
      $("<div>").addClass("page-up").insertAfter( $viewport )
      $("<div>").addClass("page-down").insertAfter( $viewport )
    }
    else if (this.$('.top').length) {
      this.$(".top").append( $("<figure>").addClass("page-up") )
      this.$(".top").append( $("<figure>").addClass("page-down") )
    }
    else {
      this.$el.append( $("<figure>").addClass("page-up") )
      this.$el.append( $("<figure>").addClass("page-down") )
    }
  },
  
  show: function(){
    app.header.updatePageNumber( this.page_number )
    app.header.updateSlideNumber( 0 )
    app.header.updateSlideCount( this.slide_count )
    $('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)
    }
    
    app.nav.setActive( 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()
  },

})