From 9259db9f8735c9ae7547561cc18c84424c42d595 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 27 Aug 2017 14:57:03 -0400 Subject: [PATCH] internal link loads referenced note instead of opening into new tab --- static/js/init.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/static/js/init.js b/static/js/init.js index 78695d207..feec14292 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -76,4 +76,20 @@ $('#recentNotesSelectBox').keydown(function(e) { $('#recentNotesSelectBox').dblclick(function(e) { setActiveNoteBasedOnRecentNotes(); +}); + +// when click on link popup, in case of internal link, just go the the referenced note instead of default behavior +// of opening the link in new window/tab +$(document).on('click', 'div.popover-content a', function(e) { + const targetUrl = $(e.target).attr("href"); + + const noteIdMatch = /app#([A-Za-z0-9]{22})/.exec(targetUrl); + + if (noteIdMatch !== null) { + const noteId = noteIdMatch[1]; + + $("#tree").fancytree('getNodeByKey', noteId).setActive(); + + e.preventDefault(); + } }); \ No newline at end of file