diff options
Diffstat (limited to 'public/assets/js/lib/views/profile/profile_edit.js')
| -rw-r--r-- | public/assets/js/lib/views/profile/profile_edit.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/profile/profile_edit.js b/public/assets/js/lib/views/profile/profile_edit.js new file mode 100644 index 0000000..a6ff211 --- /dev/null +++ b/public/assets/js/lib/views/profile/profile_edit.js @@ -0,0 +1,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 + } +})
\ No newline at end of file |
