mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-10 18:39:22 +08:00
feat(mobile): context menu triggering
This commit is contained in:
parent
0eca95cecb
commit
1eecf9a5c8
@ -1,5 +1,6 @@
|
||||
import { CommandNames } from '../components/app_context.js';
|
||||
import keyboardActionService from '../services/keyboard_actions.js';
|
||||
import utils from '../services/utils.js';
|
||||
|
||||
interface ContextMenuOptions<T extends CommandNames> {
|
||||
x: number;
|
||||
@ -34,13 +35,21 @@ class ContextMenu {
|
||||
private $widget!: JQuery<HTMLElement>;
|
||||
private dateContextMenuOpenedMs: number;
|
||||
private options?: ContextMenuOptions<any>;
|
||||
private isMobile: boolean;
|
||||
|
||||
constructor() {
|
||||
this.$widget = $("#context-menu-container");
|
||||
this.$widget.addClass("dropend");
|
||||
this.dateContextMenuOpenedMs = 0;
|
||||
this.isMobile = utils.isMobile();
|
||||
|
||||
$(document).on('click', () => this.hide());
|
||||
$(document).on('click', (e) => {
|
||||
if (this.isMobile && $(e.target).closest("#context-menu-container").length) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.hide();
|
||||
});
|
||||
}
|
||||
|
||||
async show<T extends CommandNames>(options: ContextMenuOptions<T>) {
|
||||
@ -158,6 +167,16 @@ class ContextMenu {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.isMobile && "items" in item && item.items) {
|
||||
const $target = $(e.target);
|
||||
$target
|
||||
.parents(".dropdown-item")
|
||||
.find("ul.dropdown-menu")
|
||||
.toggleClass("show");
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
this.hide();
|
||||
|
||||
if ("handler" in item && item.handler) {
|
||||
|
@ -966,7 +966,7 @@ a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
li.dropdown-submenu:hover > ul.dropdown-menu {
|
||||
body.desktop li.dropdown-submenu:hover > ul.dropdown-menu {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user