fix keyboard shortcut setup on mobile

This commit is contained in:
azivner 2018-12-24 18:39:31 +01:00
parent 35cf8026b0
commit eeb62a6cf2
3 changed files with 16 additions and 6 deletions

View file

@ -5,13 +5,17 @@ import treeCache from "./tree_cache.js";
import treeBuilder from "./tree_builder.js";
const $tree = $("#tree");
const $detail = $("#detail");
$detail.on('hide.bs.modal', e => {
$tree.show();
});
async function showTree() {
const tree = await treeService.loadTree();
$tree.fancytree({
autoScroll: true,
keyboard: false, // we takover keyboard handling in the hotkeys plugin
extensions: ["dnd5", "clones"],
source: tree,
scrollParent: $tree,
@ -24,7 +28,9 @@ async function showTree() {
noteDetailService.switchToNote(noteId, true);
$("#detail").modal();
$tree.hide();
$detail.modal();
},
expand: (event, data) => treeService.setExpandedToServer(data.node.data.branchId, true),
collapse: (event, data) => treeService.setExpandedToServer(data.node.data.branchId, false),

View file

@ -136,11 +136,13 @@ function randomString(len) {
}
function bindShortcut(keyboardShortcut, handler) {
$(document).bind('keydown', keyboardShortcut, e => {
handler();
if (isDesktop()) {
$(document).bind('keydown', keyboardShortcut, e => {
handler();
e.preventDefault();
});
e.preventDefault();
});
}
}
function isMobile() {

View file

@ -19,6 +19,8 @@
</button>
</div>
<div class="modal-body">
<span id="saved-indicator" title="All changes have been saved" class="jam jam-check"></span>
<div id="note-detail-text" class="note-detail-component" tabindex="10000"></div>
<div id="note-detail-code" class="note-detail-component"></div>