comments: add scores, rework comment menu.

* Add comment scores.
* Rework voting buttons so that you can click the upvote/downvote
  buttons to toggle votes.
* Hide the edit, delete, undelete, and report buttons behind a popup menu.
* Show the upvote/downvote/reply buttons to logged out users. Redirect
  them to the login page instead.
This commit is contained in:
evazion
2021-01-20 03:10:59 -06:00
parent ccae422961
commit 5780ed5768
15 changed files with 149 additions and 64 deletions

View File

@@ -10,8 +10,11 @@ class PopupMenuComponent {
target: "a.popup-menu-button",
placement: "bottom-start",
trigger: "click",
animation: null,
content: PopupMenuComponent.content,
});
$(document).on("click.danbooru", ".popup-menu-content", PopupMenuComponent.onMenuItemClicked);
}
static content(element) {
@@ -19,6 +22,12 @@ class PopupMenuComponent {
$content.show();
return $content.get(0);
}
// Hides the menu when a menu item is clicked.
static onMenuItemClicked(event) {
let tippy = $(event.target).parents("[data-tippy-root]").get(0)._tippy;
tippy.hide();
}
}
$(document).ready(PopupMenuComponent.initialize);

View File

@@ -1,4 +1,6 @@
div.popup-menu {
display: inline-block;
a.popup-menu-button {
display: flex;
align-items: center;
@@ -8,7 +10,8 @@ div.popup-menu {
border-radius: 50%;
color: var(--muted-text-color);
&:hover {
&:focus, &:hover {
color: var(--link-color);
background-color: var(--subnav-menu-background-color);
}
}
@@ -16,8 +19,12 @@ div.popup-menu {
ul.popup-menu-content {
display: none;
.icon {
width: 1.5em;
li {
margin: 0 2em 0.25em 0;
i.icon {
width: 2em;
}
}
}
}