Skip to content

Commit

Permalink
like click event
Browse files Browse the repository at this point in the history
  • Loading branch information
jessewoo committed Aug 15, 2024
1 parent b3bfd7a commit 7dccc0a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
4 changes: 4 additions & 0 deletions core/components/com_forum/site/assets/css/like.css
Original file line number Diff line number Diff line change
@@ -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;
}
19 changes: 18 additions & 1 deletion core/components/com_forum/site/assets/js/like.js
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
console.log("like on site forum");
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;
};
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@
)
) { ?>
<p class="comment-options">
<!-- Like Comments -->
<a class="icon-like like" data-id="c<?php echo $this->comment->get('id'); ?>" href="<?php echo Route::url($this->comment->link('like')); ?>">
LIKE
<!-- Like Comments -->
<!-- If user has liked it, should be red class="userLiked", if not gray -->
<a class="icon-heart like" data-id="c<?php echo $this->comment->get('id'); ?>" href="<?php echo Route::url($this->comment->link('like')); ?>">
Like
</a>
<?php if ((!$this->comment->get('parent') && $this->config->get('access-delete-thread')) || ($this->comment->get('parent') && $this->config->get('access-delete-post'))) { ?>
<a class="icon-delete delete" data-txt-confirm="<?php echo Lang::txt('COM_FORUM_CONFIRM_DELETE'); ?>" data-id="c<?php echo $this->comment->get('id'); ?>" href="<?php echo Route::url($this->comment->link('delete')); ?>"><!--
Expand Down

0 comments on commit 7dccc0a

Please sign in to comment.