diff options
| author | julian laplace <julescarbon@gmail.com> | 2022-10-25 23:26:31 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2022-10-25 23:26:31 +0200 |
| commit | 1cfed2612fd1042a15d470a44ec87588c966dc12 (patch) | |
| tree | ba850f589194a21fd1587dd71dfcd056a242e4ac /public/assets/js/lib/views/stream/hootform.js | |
| parent | ae311b71cccf5df9e0e19e276615cc32426d9de1 (diff) | |
hootstream... dark mode only
Diffstat (limited to 'public/assets/js/lib/views/stream/hootform.js')
| -rw-r--r-- | public/assets/js/lib/views/stream/hootform.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/public/assets/js/lib/views/stream/hootform.js b/public/assets/js/lib/views/stream/hootform.js new file mode 100644 index 0000000..368e616 --- /dev/null +++ b/public/assets/js/lib/views/stream/hootform.js @@ -0,0 +1,42 @@ +var HootForm = FormView.extend({ + el: "#hootform", + + events: {}, + + action: "/api/thread/1/comment", + + initialize: function (opt) { + this.__super__.initialize.call(this); + this.$comment = this.$("[name=comment]"); + }, + + show: function () { + this.$el.show(); + }, + + hide: function () { + this.$el.hide(); + }, + + load: function (comments) { + if (!comments || (!comments.length && !this.options.required)) { + this.$el.hide(); + return; + } + comments.forEach(this.appendComment.bind(this)); + }, + + validate: function () { + var errors = []; + var comment = $("[name=comment]").val(); + if (!comment || !comment.length) { + errors.push("Please enter a comment."); + } + return errors.length ? errors : null; + }, + + success: function (data) { + this.parent.onComment(data.comment); + this.$("[name=comment]").val(""); + }, +}); |
