From fce622b5b1959892b6f6ea94bfe3a1c4eb52d8dd Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 14 Oct 2023 11:12:05 -0400 Subject: Added comment replying --- app/assets/images/comment_add.png | Bin 0 -> 530 bytes app/assets/images/cross.png | Bin 0 -> 655 bytes app/assets/javascripts/application.js | 1 + app/assets/javascripts/main/comments.coffee | 14 ++++++++++++++ app/assets/stylesheets/main/entries.scss | 20 ++++++++++++++++++++ 5 files changed, 35 insertions(+) create mode 100644 app/assets/images/comment_add.png create mode 100644 app/assets/images/cross.png create mode 100644 app/assets/javascripts/main/comments.coffee (limited to 'app/assets') diff --git a/app/assets/images/comment_add.png b/app/assets/images/comment_add.png new file mode 100644 index 0000000..75e78de Binary files /dev/null and b/app/assets/images/comment_add.png differ diff --git a/app/assets/images/cross.png b/app/assets/images/cross.png new file mode 100644 index 0000000..1514d51 Binary files /dev/null and b/app/assets/images/cross.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index cd58a9c..d8f72b4 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,3 +17,4 @@ //= require jquery-ui //= require js-routes //= require_tree ./admin +//= require_tree ./main diff --git a/app/assets/javascripts/main/comments.coffee b/app/assets/javascripts/main/comments.coffee new file mode 100644 index 0000000..d33e200 --- /dev/null +++ b/app/assets/javascripts/main/comments.coffee @@ -0,0 +1,14 @@ +comments_ready = -> + $(".comment-reply-to").click -> + $("#comment_reply_to_id").val($(this).data("commentId")) + $("#comment-reply-msg .comment-reply-author").text($(this).data("commentAuthor")) + $("#comment-reply-msg").show() + return false + + $(".comment-reply-cancel").click -> + $("#comment_reply_to_id").val("") + $("#comment-reply-msg").hide() + return false + +$(document).ready(comments_ready) +$(document).on('turbolinks:load', comments_ready) diff --git a/app/assets/stylesheets/main/entries.scss b/app/assets/stylesheets/main/entries.scss index 8d5796f..dd6b248 100644 --- a/app/assets/stylesheets/main/entries.scss +++ b/app/assets/stylesheets/main/entries.scss @@ -251,9 +251,29 @@ float: right; margin-top: 1em; } + + .comment-reply-to { + float: right; + margin-right: 0.5em; + + img { + display: block; + } + } } #comment-form { + #comment-reply-msg { + display: none; + margin-top: 1em; + margin-bottom: 0; + margin-left: 0; + + .comment-reply-author { + font-weight: bold; + } + } + fieldset { border: 0; -- cgit 1.4.1