X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/d5a765588f5818bf46575392fa7ccbd4af0de574..e418075e26d80d68e4127d3358a2d8b11dee3a13:/app/assets/javascripts/index.js diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 273ce581a..c5532cfc4 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -287,8 +287,19 @@ $(document).ready(function () { OSM.router.load(); $(document).on("click", "a", function(e) { - if (e.isDefaultPrevented() || e.isPropagationStopped()) return; - if (this.host === window.location.host && OSM.router.route(this.pathname + this.search + this.hash)) e.preventDefault(); + if (e.isDefaultPrevented() || e.isPropagationStopped()) + return; + + // Open links in a new tab as normal. + if (e.which > 1 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) + return; + + // Ignore cross-protocol and cross-origin links. + if (location.protocol !== this.protocol || location.host !== this.host) + return; + + if (OSM.router.route(this.pathname + this.search + this.hash)) + e.preventDefault(); }); $(".search_form").on("submit", function(e) {