From 7dccc0a8309bd70ba41cc949a6ba3813d1a3aad8 Mon Sep 17 00:00:00 2001 From: Jesse Woo Date: Thu, 15 Aug 2024 11:35:29 -0700 Subject: [PATCH] like click event --- .../com_forum/site/assets/css/like.css | 4 ++++ .../com_forum/site/assets/js/like.js | 19 ++++++++++++++++++- .../site/views/threads/tmpl/_comment.php | 7 ++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/components/com_forum/site/assets/css/like.css b/core/components/com_forum/site/assets/css/like.css index 7ec5b1fc98..9ea4ebbb66 100644 --- a/core/components/com_forum/site/assets/css/like.css +++ b/core/components/com_forum/site/assets/css/like.css @@ -1,4 +1,8 @@ /* Should put this in the comments.less file */ ol.comments .comment-options a.like { float: right; +} + +ol.comments .comment-options a.userLiked { + color: red; } \ No newline at end of file diff --git a/core/components/com_forum/site/assets/js/like.js b/core/components/com_forum/site/assets/js/like.js index 268238ce50..1a86ea0c96 100644 --- a/core/components/com_forum/site/assets/js/like.js +++ b/core/components/com_forum/site/assets/js/like.js @@ -1 +1,18 @@ -console.log("like on site forum"); \ No newline at end of file +console.log("like on site forum"); + +window.addEventListener('DOMContentLoaded', (domEvent) => { + // Find all the "like" button + const likeButton = document.querySelectorAll('.comment-options .like') + if (likeButton.length) { + for(let i = 0; i < likeButton.length;i++) { + likeButton[i].onclick = (e) => { + e.preventDefault(); + + const dataId = likeButton[i].dataset.id + console.log("data id: " + dataId); + + return false; + }; + } + } +}); \ No newline at end of file diff --git a/core/components/com_forum/site/views/threads/tmpl/_comment.php b/core/components/com_forum/site/views/threads/tmpl/_comment.php index e68e6649de..63b549da72 100644 --- a/core/components/com_forum/site/views/threads/tmpl/_comment.php +++ b/core/components/com_forum/site/views/threads/tmpl/_comment.php @@ -125,9 +125,10 @@ ) ) { ?>

- - comment->get('parent') && $this->config->get('access-delete-thread')) || ($this->comment->get('parent') && $this->config->get('access-delete-post'))) { ?>