]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
The value of mapParams.object is always a node/way/relation now
[rails.git] / app / assets / javascripts / index.js
index 43b7fefe0b4caddd7d4ec2f1d9cefcf143307a50..c5532cfc4ca0791858597f61cf51e9dc30032618 100644 (file)
@@ -144,7 +144,7 @@ $(document).ready(function () {
   expiry.setYear(expiry.getFullYear() + 10);
 
   map.on('moveend layeradd layerremove', function() {
-    updatelinks(
+    updateLinks(
       map.getCenter().wrap(),
       map.getZoom(),
       map.getLayersCode(),
@@ -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) {