+ 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({pan: false});
+ };
+
+ return page;
+ };
+
+ OSM.Browse = function(map) {
+ var page = {};
+
+ page.pushstate = page.popstate = function(path, type, id) {
+ $('#sidebar_content').load(path + "?xhr=1", function(a, b, xhr) {
+ if (xhr.getResponseHeader('X-Page-Title')) {
+ document.title = xhr.getResponseHeader('X-Page-Title');
+ }
+ page.load(path, type, id);
+ });
+ };
+
+ page.load = function(path, type, id) {
+ if (OSM.STATUS === 'api_offline' || OSM.STATUS === 'database_offline') return;
+
+ map.addObject({type: type, id: parseInt(id)}, {zoom: window.location.hash == ""});
+ };
+
+ page.unload = function() {
+ map.removeObject();
+ };
+
+ return page;
+ };
+
+ var history = OSM.History(map),
+ note = OSM.Note(map);
+
+ OSM.route = OSM.Router(map, {
+ "/": OSM.Index(map),
+ "/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,
+ "/browse/note/:id": note,
+ "/browse/:type/:id(/history)": OSM.Browse(map)
+ });