summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/index/hootbox.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-09-06 01:31:50 -0400
committerJules Laplace <jules@okfoc.us>2015-09-06 01:31:50 -0400
commitc88806506d2f8845a9fb914c960d0b6bbc5a8e1e (patch)
treec271bb35972175d286f62ecfce76a8fce50f6aa7 /public/assets/js/lib/views/index/hootbox.js
parent0d0c04ad510264f2dbd2deb3bbf0b0d0c0605a62 (diff)
display hootbox
Diffstat (limited to 'public/assets/js/lib/views/index/hootbox.js')
-rw-r--r--public/assets/js/lib/views/index/hootbox.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/index/hootbox.js b/public/assets/js/lib/views/index/hootbox.js
new file mode 100644
index 0000000..43c4fe9
--- /dev/null
+++ b/public/assets/js/lib/views/index/hootbox.js
@@ -0,0 +1,37 @@
+var HootboxView = FormView.extend({
+
+ el: "#hootbox",
+
+ events: {
+ },
+
+ initialize: function(){
+ this.__super__.initialize.call(this)
+ this.template = this.$(".template").html()
+ this.$hoots = this.$("#hoots")
+ },
+
+ load: function(comments){
+ comments.forEach(this.prependComment.bind(this))
+ },
+
+ parse: function(comment){
+ var t = this.template.replace(/{{username}}/g, comment.username)
+ .replace(/{{comment}}/g, comment.comment)
+ return t
+ },
+
+ prependComment: function(comment){
+ var $el = $( this.parse(comment) )
+ this.$hoots.prepend($el)
+ },
+
+ appendComment: function(comment){
+ var $el = $( this.parse(comment) )
+ this.$hoots.append($el)
+ },
+
+ success: function(){
+ this.prependComment(comment)
+ }
+}) \ No newline at end of file