summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/lib/ConfirmModal.js
blob: 7d9da67c214600e51f17f6da745af4f68f7a00d8 (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
var ConfirmModal = new( ModalFormView.extend({
  el: ".mediaDrawer.confirm",

  events: {
    "click .yes": "agree",
    "click .no": "cancel",
  },
  
  confirm: function(question, agreeCallback, cancelCallback){
    this.$(".question").empty().append(question)
    this.agreeCallback = agreeCallback
    this.cancelCallback = cancelCallback
    this.show()
  },
  
  agree: function(e){
    e && e.preventDefault()
    this.hide()
    this.agreeCallback && this.agreeCallback()
    this.agreeCallback = null
    this.cancelCallback = null
  },

  cancel: function(e){
    e && e.preventDefault()
    this.hide()
    this.cancelCallback && this.cancelCallback()
    this.agreeCallback = null
    this.cancelCallback = null
  }

}) )