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
|
var ProfileView = View.extend({
el: ".profilepage",
events: {
"change #profile_avatar": "uploadAvatar",
},
initialize: function() {
},
load: function() {
var classes = ['one', 'two', 'three', 'four',
'five', 'six', 'seven', 'eight',
'nine', 'ten', 'eleven', 'twelve',
'thirteen'];
$(".bio").addClass(choice(classes));
this.projectList = new ProjectList ()
},
uploadAvatar: function(){
var fd = new FormData(), hasCSRF = false
var files = this.$("#profile_avatar")[0].files
if (! files.length) return
fd.append("avatar", files[0]);
fd.append("_csrf", $("[name=_csrf]").val())
var request = $.ajax({
url: "/api/profile",
type: "put",
data: fd,
dataType: "json",
processData: false,
contentType: false,
})
request.done($.proxy(function (response) {
window.location.href = "/profile"
}, this));
}
})
|