* 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.
36 lines
934 B
JavaScript
36 lines
934 B
JavaScript
import { delegate } from 'tippy.js';
|
|
import 'tippy.js/dist/tippy.css';
|
|
|
|
class PopupMenuComponent {
|
|
static initialize() {
|
|
delegate("body", {
|
|
allowHTML: true,
|
|
interactive: true,
|
|
theme: "common-tooltip",
|
|
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) {
|
|
let $content = $(element).parents(".popup-menu").find(".popup-menu-content");
|
|
$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);
|
|
|
|
export default PopupMenuComponent;
|