summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/mail/compose.js
blob: 2c76b3fe445884042b3147db2f766be4e7c11b7e (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
var ComposeView = FormView.extend({
  
  el: "#compose",
  
  events: {
  },
  
  action: "",
  
  initialize: function(){
    this.__super__.initialize.call(this)
    this.template = this.$(".template").html()
  },
  
  load: function(username){
    this.$("[name=username]").val(sanitize(username))
    $("body").removeClass('loading')
  },
  
  validate: function(){
    var errors = []
    var username = $("[name=username]").val()
    var message = $("[name=message]").val()
    if (! username || ! username.length) {
      errors.push("Please enter who this message is going to.")
    }
    if (! message || ! message.length) {
      errors.push("Please enter your message.")
    }
    return errors.length ? errors : null
  },

  success: function(){
    window.location.reload()
  }
})