2012-06-05 16:18:30 -07:00
|
|
|
NEWSBLUR.Models.Comment = Backbone.Model.extend({
|
|
|
|
|
2012-08-06 17:52:33 -07:00
|
|
|
urlRoot: '/social/comment',
|
|
|
|
|
2012-06-05 16:18:30 -07:00
|
|
|
initialize: function() {
|
2012-06-05 18:12:34 -07:00
|
|
|
this.bind('change:replies', this.changes_replies);
|
2012-08-06 17:52:33 -07:00
|
|
|
this.bind('change:comments', this.strip_html_in_comments);
|
2012-06-05 18:12:34 -07:00
|
|
|
this.changes_replies();
|
|
|
|
},
|
|
|
|
|
|
|
|
changes_replies: function() {
|
2012-06-05 16:18:30 -07:00
|
|
|
if (this.get('replies')) {
|
|
|
|
this.replies = new NEWSBLUR.Collections.CommentReplies(this.get('replies'));
|
|
|
|
}
|
2012-08-06 17:52:33 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
strip_html_in_comments: function() {
|
|
|
|
this.attributes['comments'] = this.get('comments').replace(/<\/?[^>]+(>|$)/g, "");
|
2012-06-05 16:18:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
NEWSBLUR.Collections.Comments = Backbone.Collection.extend({
|
|
|
|
|
2012-08-06 17:52:33 -07:00
|
|
|
url: '/social/comments',
|
|
|
|
|
2012-06-05 16:18:30 -07:00
|
|
|
model: NEWSBLUR.Models.Comment
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
NEWSBLUR.Models.CommentReply = Backbone.Model.extend({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
NEWSBLUR.Collections.CommentReplies = Backbone.Collection.extend({
|
|
|
|
|
|
|
|
model: NEWSBLUR.Models.CommentReply
|
|
|
|
|
|
|
|
});
|