]> git.openstreetmap.org Git - rails.git/commitdiff
Add zoom to note
authorAaron Lidman <aaronlidman@gmail.com>
Tue, 12 Nov 2013 23:12:32 +0000 (15:12 -0800)
committerAaron Lidman <aaronlidman@gmail.com>
Tue, 12 Nov 2013 23:12:40 +0000 (15:12 -0800)
app/assets/javascripts/index.js
app/assets/javascripts/index/note.js.erb
app/views/browse/note.html.erb

index e0ca66766ff877079a0d118cb2c4e588bf1e4bc2..15b45d31c34e407bb456e4ac39cad936ebd35b0b 100644 (file)
@@ -204,7 +204,7 @@ $(document).ready(function () {
     page.load = function(path, type, id) {
       if (OSM.STATUS === 'api_offline' || OSM.STATUS === 'database_offline') return;
 
     page.load = function(path, type, id) {
       if (OSM.STATUS === 'api_offline' || OSM.STATUS === 'database_offline') return;
 
-      map.addObject({type: type, id: parseInt(id)}, {zoom: true});
+      map.addObject({type: type, id: parseInt(id)}, {zoom: window.location.hash == ""});
     };
 
     page.unload = function() {
     };
 
     page.unload = function() {
index a11f6a72c93a8dc8393aeea1c98be5d470082edf..9afe3b5f887bf54e58d0299ae1f3e406c8dea592 100644 (file)
@@ -1,7 +1,8 @@
 OSM.Note = function(map) {
     var noteLayer = map.noteLayer,
         content = $('#sidebar_content'),
 OSM.Note = function(map) {
     var noteLayer = map.noteLayer,
         content = $('#sidebar_content'),
-        page = {};
+        page = {},
+        marker;
 
     var noteIcons = {
         "new": L.icon({
 
     var noteIcons = {
         "new": L.icon({
@@ -67,7 +68,7 @@ OSM.Note = function(map) {
         page.load();
     };
 
         page.load();
     };
 
-    page.load = function() {
+    page.load = function(path, id) {
         var loadTimer = setTimeout(setLoading, 250);
         $('#sidebar_content').load(window.location.pathname + "?xhr=1", function(a, b, xhr) {
             if (xhr.getResponseHeader('X-Page-Title')) {
         var loadTimer = setTimeout(setLoading, 250);
         $('#sidebar_content').load(window.location.pathname + "?xhr=1", function(a, b, xhr) {
             if (xhr.getResponseHeader('X-Page-Title')) {
@@ -76,9 +77,16 @@ OSM.Note = function(map) {
             bind();
             clearTimeout(loadTimer);
             clearLoading();
             bind();
             clearTimeout(loadTimer);
             clearLoading();
+
+            if (!map.hasLayer(noteLayer)) map.addLayer(noteLayer);
+            if (window.location.hash == "") map.panTo($('.details').data().coordinates.split(','));
         });
     };
 
         });
     };
 
+    page.unload = function() {
+        if (marker) map.removeLayer(marker);
+    };
+
     function setLoading() {
       if($('#browse_status').is(':empty')) {
         $('#browse_status').append($('<p></p>').text(I18n.t('browse.start_rjs.loading')));
     function setLoading() {
       if($('#browse_status').is(':empty')) {
         $('#browse_status').append($('<p></p>').text(I18n.t('browse.start_rjs.loading')));
index f6db9f154c114c56e5c8aab28ba95ed9ba2f53a2..a377ada6a7d857735571478a19b7db473da50086 100644 (file)
@@ -6,7 +6,7 @@
 </h2>
 
 <div class="browse-section">
 </h2>
 
 <div class="browse-section">
-  <div class="details">
+  <div class="details" data-coordinates="<%= number_with_delimiter(@note.lat) %>,<%=number_with_delimiter(@note.lon) %>" data-status="<%= @note.status %>">
     <%= t "browse.note.#{@note.status}_title", :note_name => @note.id %>
       <br/>
     <%= note_event('open', @note.created_at, @note.author) %>
     <%= t "browse.note.#{@note.status}_title", :note_name => @note.id %>
       <br/>
     <%= note_event('open', @note.created_at, @note.author) %>