X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/a805e0b545a37b19a4162e71850bef9aba9d6628..7a435df917edbad034db908b7a00d14d31b7396b:/app/assets/javascripts/index.js diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 2d9300247..e0ca66766 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -11,6 +11,7 @@ //= require index/notes //= require index/history //= require index/note +//= require index/new_note //= require router $(document).ready(function () { @@ -158,19 +159,31 @@ $(document).ready(function () { OSM.Index = function(map) { var page = {}; - page.pushstate = page.popstate = function(path) { - $("#content").addClass("overlay-sidebar"); - map.invalidateSize(); + function loadContent(path) { $('#sidebar_content').load(path + "?xhr=1", function(a, b, xhr) { if (xhr.getResponseHeader('X-Page-Title')) { document.title = xhr.getResponseHeader('X-Page-Title'); } }); + } + + page.pushstate = function(path) { + $("#content").addClass("overlay-sidebar"); + map.invalidateSize({pan: false}) + .panBy([-300, 0], {animate: false}); + loadContent(path); + }; + + page.popstate = function(path) { + $("#content").addClass("overlay-sidebar"); + map.invalidateSize({pan: false}); + loadContent(path); }; page.unload = function() { + map.panBy([300, 0], {animate: false}); $("#content").removeClass("overlay-sidebar"); - map.invalidateSize(); + map.invalidateSize({pan: false}); }; return page; @@ -191,11 +204,7 @@ $(document).ready(function () { page.load = function(path, type, id) { if (OSM.STATUS === 'api_offline' || OSM.STATUS === 'database_offline') return; - if (type === 'note') { - map.noteLayer.showNote(parseInt(id)); - } else { - map.addObject({type: type, id: parseInt(id)}, {zoom: true}); - } + map.addObject({type: type, id: parseInt(id)}, {zoom: true}); }; page.unload = function() { @@ -213,6 +222,7 @@ $(document).ready(function () { "/search": OSM.Search(map), "/export": OSM.Export(map), "/history": history, + "/new_note": OSM.NewNote(map), "/user/:display_name/edits": history, "/browse/friends": history, "/browse/nearby": history,