+ OSM.Index = function(map) {
+ var page = {};
+
+ page.pushstate = function() {
+ $("#content").addClass("overlay-sidebar");
+ map.invalidateSize({pan: false})
+ .panBy([-350, 0], {animate: false});
+ };
+
+ page.load = function() {
+ return map.getState();
+ };
+
+ page.popstate = function() {
+ $("#content").addClass("overlay-sidebar");
+ map.invalidateSize({pan: false});
+ };
+
+ page.unload = function() {
+ map.panBy([350, 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) {
+ OSM.loadSidebarContent(path, function() {
+ page.load(path, type, id);
+ });
+ };
+
+ page.load = function(path, type, id) {
+ map.addObject({type: type, id: parseInt(id)});
+ };
+
+ page.unload = function() {
+ map.removeObject();
+ };
+
+ return page;
+ };
+
+ var history = OSM.History(map);
+
+ OSM.router = OSM.Router(map, {
+ "/": OSM.Index(map),
+ "/search": OSM.Search(map),
+ "/export": OSM.Export(map),
+ "/new_note": OSM.NewNote(map),
+ "/history": history,
+ "/user/:display_name/edits": history,
+ "/browse/friends": history,
+ "/browse/nearby": history,
+ "/browse/note/:id": OSM.Note(map),
+ "/browse/:type/:id(/history)": OSM.Browse(map)
+ });