From eddb3ed58a4408e52f82a972bcefe00bb7091774 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 19 Dec 2017 19:31:02 -0500 Subject: [PATCH] hook on hash change which allows us navigation with alt-left, alt-right --- public/javascripts/note_tree.js | 12 +++++++++++- services/build.js | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/public/javascripts/note_tree.js b/public/javascripts/note_tree.js index 63ebb5a18..b6031678f 100644 --- a/public/javascripts/note_tree.js +++ b/public/javascripts/note_tree.js @@ -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, diff --git a/services/build.js b/services/build.js index 13a6403c2..46382d5f5 100644 --- a/services/build.js +++ b/services/build.js @@ -1 +1 @@ -module.exports = { build_date:"2017-12-18T00:01:16-05:00", build_revision: "f96e38fd13152eee4700ead265c5b255b8e6853e" }; +module.exports = { build_date:"2017-12-18T23:45:10-05:00", build_revision: "b0e2d99a7b1073e9ee593b386afa19a62a2651eb" };