hook on hash change which allows us navigation with alt-left, alt-right

This commit is contained in:
azivner
2017-12-19 19:31:02 -05:00
parent 58e3e8895a
commit eddb3ed58a
2 changed files with 12 additions and 2 deletions

View File

@@ -505,12 +505,16 @@ const noteTree = (function() {
await getTree().reload(notes);
}
function getNotePathFromAddress() {
return document.location.hash.substr(1); // strip initial #
}
function loadTree() {
return server.get('tree').then(resp => {
startNotePath = resp.start_note_path;
if (document.location.hash) {
startNotePath = document.location.hash.substr(1); // strip initial #
startNotePath = getNotePathFromAddress();
}
return prepareNoteTree(resp.notes);
@@ -668,6 +672,12 @@ const noteTree = (function() {
$(document).bind('keydown', 'ctrl+.', scrollToCurrentNote);
$(window).bind('hashchange', function() {
const notePath = getNotePathFromAddress();
activateNode(notePath);
});
return {
reload,
collapseTree,