diff options
| author | julian laplace <julescarbon@gmail.com> | 2022-10-27 22:45:12 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2022-10-27 22:45:12 +0200 |
| commit | eb0b4dc9cc68b92ee27b1da1f02d7296d756d262 (patch) | |
| tree | 13f5cc180716650b537202233ac74c9692c2d7ea /public/assets/js/lib/views | |
| parent | 61b119ecbddf2275f39a91fa252e071c4767d863 (diff) | |
expand link
Diffstat (limited to 'public/assets/js/lib/views')
| -rw-r--r-- | public/assets/js/lib/views/stream/hootstream.js | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/public/assets/js/lib/views/stream/hootstream.js b/public/assets/js/lib/views/stream/hootstream.js index 94d1cb3..47a3bd7 100644 --- a/public/assets/js/lib/views/stream/hootstream.js +++ b/public/assets/js/lib/views/stream/hootstream.js @@ -65,18 +65,18 @@ var HootStream = View.extend({ console.log(action, thread); switch (action) { case "play": - this.onPlay(thread); + this.onPlay(event, thread); break; case "expand": - this.onExpand(thread); + this.onExpand(event, thread); break; case "post": - this.onShowForm(thread); + this.onShowForm(event, thread); break; } }, - onPlay: function (thread) { + onPlay: function (event, thread) { // $.get(`/api/stream?thread=${thread}`).then((response) => { console.log(response); @@ -90,8 +90,27 @@ var HootStream = View.extend({ }); }, - onExpand: function (thread) { - // + onExpand: function (event, thread) { + $(event.target).hide(); + $(event.target).prev("div").hide(); + $.get(`/api/stream?thread=${thread}`).then( + function (response) { + console.log(response); + const $thread = this.renderThread({ + query: response.query, + thread: response.threads, + images: response.files.filter((file) => + file.filename.match(IMAGE_REGEXP) + ), + files: response.files.filter( + (file) => !file.filename.match(IMAGE_REGEXP) + ), + comments: response.comments, + }); + console.log($thread); + $(event.target).closest(".thread").replaceWith($thread); + }.bind(this) + ); }, onPost: function (thread) { @@ -323,7 +342,7 @@ var HootStream = View.extend({ const actions = [ hasAudio && { action: "play", label: "Play music" }, - { action: "expand", label: "Expand" }, + !isViewingThread && { action: "expand", label: "Expand" }, { action: "post", label: "Post" }, ] .filter((action) => !!action) |
