more work on comments for events

This commit is contained in:
Kyle Drake 2014-05-01 19:20:34 -07:00
parent eba4a6e3f5
commit b96730b83f
17 changed files with 2298 additions and 43 deletions

View file

@ -0,0 +1,16 @@
var Comment = function(eventId, csrfToken) {
this.eventId = eventId
this.csrfToken = csrfToken
}
Comment.prototype.create = function(form) {
var self = this
var form = $(form)
var comment = form.find('[name="comment"]').val()
form.remove()
$.post('/event/'+this.eventId+'/comment', {csrf_token: this.csrfToken, comment: comment}, function(res) {
console.log(res)
})
}

View file

@ -5,13 +5,8 @@ var Like = function(eventId, csrfToken) {
}
Like.prototype.toggleLike = function() {
console.log('herp?')
var self = this
$.post('/event/'+this.eventId+'/toggle_like', {csrf_token: this.csrfToken}, function(res) {
console.log(res)
console.log(self.link.text('butts'))
if(res.result == 'liked')
self.link.text('Unlike ('+res.event_like_count+')')

View file

@ -0,0 +1,13 @@
var Template = {
template: function(templateString, data) {
var data = data || {}
return _.template(templateString, data, {interpolate: /\{\{(.+?)\}\}/g})
},
renderComment: function(event_id) {
var event = $('#event_'+event_id+'_actions')
var rendered = this.template($('#comment-template').html(), {event_id: event_id})
event.find('a#reply').css('display', 'none')
event.append(rendered)
}
}

File diff suppressed because one or more lines are too long