]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Restore marker for non-browse search results
[rails.git] / app / assets / javascripts / index.js
index 43b7fefe0b4caddd7d4ec2f1d9cefcf143307a50..55f1f8f1e95a60ef680798f58503ca3f095ffde4 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(),
@@ -201,10 +201,6 @@ $(document).ready(function () {
       e.preventDefault();
   });
 
-  if (OSM.preferred_editor == "remote" && $('body').hasClass("site-edit")) {
-    remoteEditHandler(map.getBounds());
-  }
-
   if (OSM.params().edit_help) {
     $('#editanchor')
       .removeAttr('title')
@@ -284,11 +280,27 @@ $(document).ready(function () {
     "/changeset/:id":              OSM.Browse(map, 'changeset')
   });
 
+  if (OSM.preferred_editor == "remote" && document.location.pathname == "/edit") {
+    remoteEditHandler(map.getBounds());
+    OSM.router.setCurrentPath("/");
+  }
+
   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) {