]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/history.js
Remove unused (and bogus) code
[rails.git] / app / assets / javascripts / index / history.js
index 4a2b96be4066bfd0e62dd145162b23242dd240c4..8103f047ed5d054e29c0a65fb27c2654150a965b 100644 (file)
@@ -1,3 +1,5 @@
+//= require jquery.simulate
+
 OSM.History = function(map) {
   var page = {};
 
@@ -10,8 +12,9 @@ OSM.History = function(map) {
       unHighlightChangeset($(this).data("changeset").id);
     })
     .on("click", "[data-changeset]", function (e) {
-      e.preventDefault();
-      clickChangeset($(this).data("changeset").id);
+      if (!$(e.target).is('a')) {
+        clickChangeset($(this).data("changeset").id, e);
+      }
     });
 
   var group = L.featureGroup()
@@ -22,7 +25,7 @@ OSM.History = function(map) {
       unHighlightChangeset(e.layer.id);
     })
     .on("click", function (e) {
-      clickChangeset(e.layer.id);
+      clickChangeset(e.layer.id, e);
     });
 
   group.getLayerId = function(layer) {
@@ -39,15 +42,15 @@ OSM.History = function(map) {
     $("#changeset_" + id).removeClass("selected");
   }
 
-  function clickChangeset(id) {
-    OSM.router.route($("#changeset_" + id).find(".changeset_id").attr("href"));
+  function clickChangeset(id, e) {
+    $("#changeset_" + id).find("a.changeset_id").simulate("click", e);
   }
 
-  function loadData() {
-    var data = {};
+  function update() {
+    var data = {list: '1'};
 
     if (window.location.pathname === '/history') {
-      data = {bbox: map.getBounds().wrap().toBBoxString()};
+      data.bbox = map.getBounds().wrap().toBBoxString();
     }
 
     $.ajax({
@@ -59,6 +62,11 @@ OSM.History = function(map) {
         updateMap();
       }
     });
+
+    var feedLink = $('link[type="application/atom+xml"]'),
+      feedHref = feedLink.attr('href').split('?')[0];
+
+    feedLink.attr('href', feedHref + '?bbox=' + data.bbox);
   }
 
   function loadMore(e) {
@@ -118,18 +126,15 @@ OSM.History = function(map) {
     map.addLayer(group);
 
     if (window.location.pathname === '/history') {
-      map.on("moveend", loadData)
+      map.on("moveend", update);
     }
 
-    loadData();
+    update();
   };
 
   page.unload = function() {
     map.removeLayer(group);
-
-    if (window.location.pathname === '/history') {
-      map.off("moveend", loadData)
-    }
+    map.off("moveend", update);
 
     $("#history_tab").removeClass("current");
   };