summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/index
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-08 01:35:26 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-08 01:35:26 +0100
commite4e0cf21a31b74d5ee1e6d45b343ea60ed44f372 (patch)
treed6e3d14c4b5ddfed5d8bd036a5eba29af505553b /public/assets/js/lib/views/index
parent3a4f027ec05aa5fdf4098ceb0dab09f69c5e0b8b (diff)
hootbox stuff
Diffstat (limited to 'public/assets/js/lib/views/index')
-rw-r--r--public/assets/js/lib/views/index/hootbox.js14
-rw-r--r--public/assets/js/lib/views/index/threadbox.js1
2 files changed, 14 insertions, 1 deletions
diff --git a/public/assets/js/lib/views/index/hootbox.js b/public/assets/js/lib/views/index/hootbox.js
index 9d1cc3d..f93a689 100644
--- a/public/assets/js/lib/views/index/hootbox.js
+++ b/public/assets/js/lib/views/index/hootbox.js
@@ -5,6 +5,17 @@ var HootBox = FormView.extend({
events: {
},
+ validate: function(){
+ var errors = []
+ var comment = $("[name=comment]").val()
+ if (! comment || ! comment.length) {
+ errors.push("Please enter a comment.")
+ }
+ return errors.length ? errors : null
+ },
+
+ action: "/api/thread/1/comment",
+
initialize: function(){
this.__super__.initialize.call(this)
this.template = this.$(".template").html()
@@ -31,7 +42,8 @@ var HootBox = FormView.extend({
this.$hoots.append($el)
},
- success: function(){
+ success: function(comment){
this.prependComment(comment)
+ this.$("[name=comment]").val("")
}
}) \ No newline at end of file
diff --git a/public/assets/js/lib/views/index/threadbox.js b/public/assets/js/lib/views/index/threadbox.js
index 0c6a4be..8d8cb02 100644
--- a/public/assets/js/lib/views/index/threadbox.js
+++ b/public/assets/js/lib/views/index/threadbox.js
@@ -35,6 +35,7 @@ var ThreadBox = View.extend({
},
parse: function(thread){
+ if (thread.comment_count === undefined) return ""
var views = hush_views(thread.viewed)
var size = hush_size(thread.size)
var comments = hush_null(thread.comment_count, "c")