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

View File

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

View File

@ -19,6 +19,8 @@
</button> </button>
</div> </div>
<div class="modal-body"> <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-text" class="note-detail-component" tabindex="10000"></div>
<div id="note-detail-code" class="note-detail-component"></div> <div id="note-detail-code" class="note-detail-component"></div>