summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/lib/ModalView.js
blob: e0070ce6deda525bd51a86be0fcb50c1cd02d4d6 (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
var ModalView = View.extend({
  events: {
    "click .close": 'close',
  },
  
  initialize: function(opt){
    if (opt && opt.parent) {
      this.parent = opt.parent
    }
  },
  
  usesFileUpload: false,
  
  show: function(){
    $(".mediaDrawer").removeClass("active")
    $(".fileUpload").removeClass("active")

    if (this.fixedClose) {
      $("#fixed_close").addClass("active")
      $("#fixed_close").bind("click", this.hide.bind(this))
    }
    
    this.$el.addClass("active")
    $("body").addClass("noOverflow")
  },

  hide: function(){
    // $(".mediaDrawer, .room1").removeClass("active editing");
    if (this.fixedClose) {
      $("#fixed_close").removeClass("active")
      $("#fixed_close").unbind("click", this.hide.bind(this))
    }
    this.$el.removeClass("active");
    $("body").removeClass("noOverflow");
  },
  
  hideClose: function(){
    $("#fixed_close").removeClass("active")
    $("#fixed_close").unbind("click", this.hide.bind(this))
  },
  
  close: function(){
    if (window.isModalView) {
      window.location.pathname = "/"
    }
    else {
      history.pushState(null, document.title, app.router.originalPath)
      this.hide()
    }
  }

})