summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/details/comments.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-09-07 01:08:00 -0400
committerJules Laplace <jules@okfoc.us>2015-09-07 01:08:00 -0400
commit2bb87671b1c5b59d6c770627b99a17a784f81e1d (patch)
tree18f09b11a4d78a4cbaf4ddab66b6d62e0f8e7426 /public/assets/js/lib/views/details/comments.js
parent126c462fe0c93ef55a6dca9ba693d8b43a7a8300 (diff)
stub in details page
Diffstat (limited to 'public/assets/js/lib/views/details/comments.js')
-rw-r--r--public/assets/js/lib/views/details/comments.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/details/comments.js b/public/assets/js/lib/views/details/comments.js
new file mode 100644
index 0000000..164a3b1
--- /dev/null
+++ b/public/assets/js/lib/views/details/comments.js
@@ -0,0 +1,39 @@
+var CommentsView = FormView.extend({
+
+ el: "#comments",
+
+ events: {
+ },
+
+ initialize: function(){
+ this.__super__.initialize.call(this)
+ this.template = this.$(".template").html()
+ },
+
+ load: function(comments){
+ comments.forEach(this.appendComment.bind(this))
+ },
+
+ parse: function(comment){
+ var datetime = verbose_date(comment.date)
+ var t = this.template.replace(/{{username}}/g, comment.username)
+ .replace(/{{comment}}/g, comment.comment)
+ .replace(/{{date}}/g, datetime[0])
+ .replace(/{{time}}/g, datetime[1])
+ return t
+ },
+
+ prependComment: function(comment){
+ var $el = $( this.parse(comment) )
+ this.$el.prepend($el)
+ },
+
+ appendComment: function(comment){
+ var $el = $( this.parse(comment) )
+ this.$el.append($el)
+ },
+
+ success: function(){
+ this.prependComment(comment)
+ }
+}) \ No newline at end of file