diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-10-28 18:06:46 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-10-28 18:06:46 -0400 |
| commit | 9e7bacd46c1e5d0e1c24433690d421ab3f3a11f2 (patch) | |
| tree | 4d0cefa2780dfa4382f1ed2ea481b6aafbdbb15e /public/assets/javascripts/ui/site/ProfileView.js | |
| parent | 50da9e3e677f121f15e501bf062da6c45db255ad (diff) | |
| parent | cce1dea756717f1308c6b72f762b5ea5f5b43958 (diff) | |
merge
Diffstat (limited to 'public/assets/javascripts/ui/site/ProfileView.js')
| -rw-r--r-- | public/assets/javascripts/ui/site/ProfileView.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/site/ProfileView.js b/public/assets/javascripts/ui/site/ProfileView.js index f3b35d9..8471abc 100644 --- a/public/assets/javascripts/ui/site/ProfileView.js +++ b/public/assets/javascripts/ui/site/ProfileView.js @@ -1,6 +1,12 @@ var ProfileView = View.extend({ + el: ".profilepage", + + events: { + "change #profile_avatar": "uploadAvatar", + }, + initialize: function() { }, @@ -12,6 +18,28 @@ var ProfileView = View.extend({ $(".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)); } }) |
