summaryrefslogtreecommitdiff
path: root/public/assets
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets')
-rw-r--r--public/assets/css/hootstream.css22
-rw-r--r--public/assets/js/lib/views/stream/hootcomment.js60
-rw-r--r--public/assets/js/lib/views/stream/hootstream.js31
3 files changed, 101 insertions, 12 deletions
diff --git a/public/assets/css/hootstream.css b/public/assets/css/hootstream.css
index c06ec13..adfd19e 100644
--- a/public/assets/css/hootstream.css
+++ b/public/assets/css/hootstream.css
@@ -362,6 +362,7 @@
padding: 0.25rem;
margin-bottom: 0;
}
+#hootstream form button,
#hootform form button {
margin: 0;
padding: 0.25rem;
@@ -392,7 +393,7 @@
}
#hootform input[type="text"]:focus {
border-bottom: 1px solid rgba(40, 20, 20, 0.2);
- border-radius: 2px 2px 0 0;
+ border-radius: 2px;
/*color: #211;*/
}
#hootform input[type="text"]:focus {
@@ -405,6 +406,25 @@
caret-color: #888;
}
+/** POST FORM */
+
+form.streamForm {
+ width: 100%;
+ max-width: 720px;
+ padding-left: 4rem;
+}
+form.streamForm textarea {
+ width: 100%;
+ height: 5vmin;
+ font-family: "Trebuchet MS", sans-serif;
+ font-size: 1rem;
+ padding: 0.5rem;
+ border: 2px solid #211;
+ outline: 0;
+ background: rgba(127, 127, 127, 0.2);
+ color: #fff;
+}
+
/** HOOT FILTERS */
#hootfilters {
diff --git a/public/assets/js/lib/views/stream/hootcomment.js b/public/assets/js/lib/views/stream/hootcomment.js
new file mode 100644
index 0000000..93c57e4
--- /dev/null
+++ b/public/assets/js/lib/views/stream/hootcomment.js
@@ -0,0 +1,60 @@
+var HootCommentForm = FormView.extend({
+ events: {
+ "focus textarea": "focus",
+ "mouseup input[type=file]": "focus",
+ "keydown textarea": "keydown",
+ },
+
+ action: "",
+
+ initialize: function (opt) {
+ this.__super__.initialize.call(this, opt);
+ this.template = this.$(".template").html();
+ this.$comment = this.$("[name=comment]");
+ },
+
+ load: function (thread) {
+ this.action = "/api/thread/" + thread.id + "/comment";
+ this.$comment.addClass("empty");
+ if (thread.settings.noupload) {
+ this.$("[type=file]").hide();
+ }
+ },
+
+ keydown: function (e) {
+ if ((e.ctrlKey || e.metaKey || e.altKey) && e.keyCode == 83) {
+ // "s" key
+ e.preventDefault();
+ e.stopPropagation();
+ this.save();
+ }
+ },
+
+ focus: function () {
+ this.$el.addClass("focused");
+ this.$comment.removeClass("empty");
+ $("[name=comment]").prop("required", false);
+ },
+
+ validate: function () {
+ var errors = [];
+ var comment = $("[name=comment]").val();
+ var files = this.$("[name=files]").val();
+ if ((!comment || !comment.length) && !files) {
+ errors.push("Please enter a comment or add some files.");
+ }
+ return errors.length ? errors : null;
+ },
+
+ success: function (data) {
+ $("[name=comment").val("");
+ $("[name=files").val("");
+ // window.location.reload()
+ console.log(this);
+ console.log(this.parent);
+ console.log(data);
+ data.comment && this.parent.comments.load([data.comment]);
+ data.files && this.parent.files.add(data.files);
+ data.files && this.parent.gallery.add(data.files);
+ },
+});
diff --git a/public/assets/js/lib/views/stream/hootstream.js b/public/assets/js/lib/views/stream/hootstream.js
index 37cd4f8..dcac22c 100644
--- a/public/assets/js/lib/views/stream/hootstream.js
+++ b/public/assets/js/lib/views/stream/hootstream.js
@@ -5,6 +5,7 @@ var HootStream = View.extend({
"click a": "onClickLink",
"click .filename": "onClickFilename",
"click .action": "onClickAction",
+ "submit .streamForm form": "onSubmitComment",
},
initialize: function ({ parent }) {
@@ -15,6 +16,8 @@ var HootStream = View.extend({
this.lastlogTemplate = this.$(".lastlogTemplate").html();
this.fileTemplate = this.$(".fileTemplate").html();
this.imageTemplate = this.$(".imageTemplate").html();
+ this.threadFormTemplate = this.$(".threadFormTemplate").html();
+ this.commentFormTemplate = this.$(".commentFormTemplate").html();
this.onClickLink = this.onClickLink.bind(this);
this.onClickFilename = this.onClickFilename.bind(this);
},
@@ -71,7 +74,7 @@ var HootStream = View.extend({
this.onExpand(event, thread);
break;
case "post":
- this.onShowForm(event, thread);
+ this.onShowCommentForm(event, thread);
break;
}
},
@@ -80,15 +83,13 @@ var HootStream = View.extend({
//
$.get(`/api/stream?thread=${thread}`).then((response) => {
console.log(response);
- let sort;
+ let settings;
try {
- const settings = JSON.parse(response.threads[0].settings);
- sort = settings.sort;
- } catch (error) {
- // console.error(error);
- sort = null;
- }
- audio.index(this.sortFiles(response.files, sort));
+ settings = JSON.parse(response.threads[0].settings);
+ } catch (error) {}
+ audio.index(
+ this.sortFiles(response.files, settings ? settings.sort : null)
+ );
audio.play(0);
});
},
@@ -116,8 +117,16 @@ var HootStream = View.extend({
);
},
- onPost: function (thread) {
- //
+ onShowCommentForm: function (event, thread) {
+ const $threadTitle = $(event.target).closest(".threadTitle");
+ const $form = $(this.commentFormTemplate);
+ $form.data("thread", thread);
+ $form.insertAfter($threadTitle);
+ $form.find("textarea").focus();
+ },
+
+ onSubmitComment: function (event) {
+ event.preventDefault();
},
load: function (data, filters) {