From 470beabf17cebb4b4589d232cf395b8f9a9597d6 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 12 Feb 2014 22:00:12 +0000 Subject: [PATCH] Enhance links so that control/command clicking suppresses navigation Control- or Command-clicking on a link will now open the target tiddler but suppress navigating to it. Kind of like opening in a background tab. --- core/modules/widgets/link.js | 3 ++- core/modules/widgets/navigator.js | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/modules/widgets/link.js b/core/modules/widgets/link.js index a25ba5a1a..7d2fa74d2 100755 --- a/core/modules/widgets/link.js +++ b/core/modules/widgets/link.js @@ -94,7 +94,8 @@ LinkWidget.prototype.handleClickEvent = function (event) { navigateFromTitle: this.getVariable("storyTiddler"), navigateFromNode: this, navigateFromClientRect: { top: bounds.top, left: bounds.left, width: bounds.width, right: bounds.right, bottom: bounds.bottom, height: bounds.height - } + }, + navigateSuppressNavigation: event.metaKey || event.ctrlKey }); event.preventDefault(); event.stopPropagation(); diff --git a/core/modules/widgets/navigator.js b/core/modules/widgets/navigator.js index 49d6101e4..3d0d3f771 100755 --- a/core/modules/widgets/navigator.js +++ b/core/modules/widgets/navigator.js @@ -149,7 +149,9 @@ Handle a tw-navigate event */ NavigatorWidget.prototype.handleNavigateEvent = function(event) { this.addToStory(event.navigateTo,event.navigateFromTitle); - this.addToHistory(event.navigateTo,event.navigateFromClientRect); + if(!event.navigateSuppressNavigation) { + this.addToHistory(event.navigateTo,event.navigateFromClientRect); + } return false; };