Files
danbooru/app/components/popup_menu_component/popup_menu_component.js
evazion 7629a99030 Fix #4675: Comment tooltip doesn't show properly on phone.
Possible fix for #4675. This is still wonky; tapping the menu icon now
opens the menu, but doesn't close it. You have to tap outside the menu
to hide it.
2021-01-23 01:16:46 -06:00

37 lines
955 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",
touch: "hold",
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;