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

View File

@ -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" };