diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-09-15 12:28:32 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-09-15 12:28:32 +0200 |
commit | df5c5a8c0164c3401fb114a7f6478e3324694358 (patch) | |
tree | 0dd6e9d2f39c9437d8d1266a2d1cb013d599bb64 | |
parent | 57a0c3bad8333d93815257d7ff603bc34b8b3f4d (diff) | |
parent | c14ba7ce3416c560b0043e2dd8e4ced8e43f6a6d (diff) | |
download | gitbook-df5c5a8c0164c3401fb114a7f6478e3324694358.zip gitbook-df5c5a8c0164c3401fb114a7f6478e3324694358.tar.gz gitbook-df5c5a8c0164c3401fb114a7f6478e3324694358.tar.bz2 |
Merge pull request #919 from gaearon/fix-cmd-click
Don't react when user wants to open a link in a new tab
-rwxr-xr-x | theme/javascript/core/navigation.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/theme/javascript/core/navigation.js b/theme/javascript/core/navigation.js index a4a5b43..c1766ab 100755 --- a/theme/javascript/core/navigation.js +++ b/theme/javascript/core/navigation.js @@ -105,7 +105,19 @@ define([ events.trigger("page.change"); }; + var isLeftClickEvent = function (e) { + return e.button === 0; + }; + + var isModifiedEvent = function (e) { + return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey); + }; + var handlePagination = function (e) { + if (isModifiedEvent(e) || !isLeftClickEvent(e)) { + return; + } + e.stopPropagation(); e.preventDefault(); |