blob: a6ff211ad97e103dd643ce74cba1499fc1531b5f (
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
|
var ProfileForm = FormView.extend({
el: "#profile_form",
events: {
"change #profile-pic": 'changeProfilePic',
},
action: "/api/user",
method: "POST",
initialize: function(){
this.__super__.initialize.call(this)
this.template = this.$(".template").html()
},
load: function(username){
console.log('hi')
this.action = "/api/user/" + username;
"realname location email phone website fb twitter".split(" ").forEach((field) => {
this.$('[name=' + field + ']').val( sanitize(auth.user[field]) )
})
if (! auth.user.pic) {
$("#profile-pic-embed").hide()
} else {
$("#profile-pic-embed").attr("src", sanitize(auth.user.pic))
}
$("body").removeClass('loading')
},
changeProfilePic: function(){
// $("#profile-pic-embed").show().attr("src", sanitize(auth.user.pic))
},
validate: function(){
var errors = []
var title = this.$("[name=title]").val()
if (! title || ! title.length) {
errors.push("Please title your post.")
}
return errors.length ? errors : null
},
success: function(data){
if (data.error) {
return alert(data.error)
}
window.location.href = "/details/" + data.id
}
})
|