blob: db08ef1fd3d140bbce9db819a176dc772bf36d72 (
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
|
var CommentForm = FormView.extend({
el: "#comment_form",
events: {
"focus textarea": 'focus',
"mouseup input[type=file]": 'focus',
},
action: "",
initialize: function(){
this.__super__.initialize.call(this)
this.template = this.$(".template").html()
this.$comment = this.$("[name=comment]")
},
load: function(thread){
this.action = "/api/thread/" + thread.id + "/comment"
if (thread.settings.noupload) {
this.$("[type=file]").hide()
}
},
focus: function(){
this.$el.addClass('focused')
$("[name=comment]").prop("required", false)
},
validate: function(){
var errors = []
var comment = $("[name=comment]").val()
var files = this.$("[name=files]").val()
if ((! comment || ! comment.length) && ! files) {
errors.push("Please enter a comment or add some files.")
}
return errors.length ? errors : null
},
success: function(){
window.location.reload()
}
})
|