]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/application.js
Don't try and dereference an object that may not exist
[rails.git] / app / assets / javascripts / application.js
index 91354073068c7a321bc4d184a7e0162b754563ed..c52c072a754fa941a33b61b920aebe96e7b3ffe0 100644 (file)
@@ -6,8 +6,7 @@
 //= require augment
 //= require openlayers
 //= require i18n/translations
-//= require globals
-//= require params
+//= require osm
 //= require piwik
 //= require map
 //= require menu
@@ -26,7 +25,7 @@ function zoomPrecision(zoom) {
  * Called as the user scrolls/zooms around to aniplate hrefs of the
  * view tab and various other links
  */
-function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,objid) {
+function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,object) {
   var toPrecision = zoomPrecision(zoom);
   var node;
 
@@ -55,8 +54,8 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj
       args.layers = layers;
     }
 
-    if (objtype && $(link).hasClass("object")) {
-      args[objtype] = objid;
+    if (object && $(link).hasClass("object")) {
+      args[object.type] = object.id;
     }
 
     var minzoom = $(link).data("minzoom");
@@ -84,8 +83,8 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj
     var prefix = shortlinkPrefix();
 
     // Add ?{node,way,relation}=id to the arguments
-    if (objtype && objid) {
-      args[objtype] = objid;
+    if (object) {
+      args[object.type] = object.id;
     }
 
     // This is a hack to omit the default mapnik layer from the shortlink.
@@ -100,7 +99,7 @@ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,obj
     // ?{node,way,relation}= can be safely omitted from the shortlink
     // which encodes lat/lon/zoom. If new URL parameters are added to
     // the main slippy map this needs to be changed.
-    if (args.layers || args[objtype]) {
+    if (args.layers || object) {
       this.href = setArgs(prefix + "/go/" + code, args);
     } else {
       this.href = prefix + "/go/" + code;