]> 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 1cbd97f86351e442f210d320e41167c5f42b1969..c5532cfc4ca0791858597f61cf51e9dc30032618 100644 (file)
@@ -140,18 +140,28 @@ $(document).ready(function () {
 
   $('.leaflet-control .control-button').tooltip({placement: 'left', container: 'body'});
 
+  var expiry = new Date();
+  expiry.setYear(expiry.getFullYear() + 10);
+
   map.on('moveend layeradd layerremove', function() {
-    updatelinks(
+    updateLinks(
       map.getCenter().wrap(),
       map.getZoom(),
       map.getLayersCode(),
       map._object);
 
-    var expiry = new Date();
-    expiry.setYear(expiry.getFullYear() + 10);
     $.cookie("_osm_location", cookieContent(map), { expires: expiry });
   });
 
+  if ($.cookie('_osm_welcome') == 'hide') {
+    $('.welcome').hide();
+  }
+
+  $('.welcome .close').on('click', function() {
+    $('.welcome').hide();
+    $.cookie("_osm_welcome", 'hide', { expires: expiry });
+  });
+
   if (OSM.PIWIK) {
     map.on('layeradd', function (e) {
       if (e.layer.options) {
@@ -277,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) {