- function initialize() {
- if (addNoteButton.hasClass("disabled")) return;
- if (addNoteButton.hasClass("active")) return;
-
- addNoteButton.addClass("active");
-
- map.addLayer(noteLayer);
-
- var mapSize = map.getSize();
- var markerPosition;
-
- if (mapSize.y > 800) {
- markerPosition = [mapSize.x / 2, mapSize.y / 2];
- } else if (mapSize.y > 400) {
- markerPosition = [mapSize.x / 2, 400];
- } else {
- markerPosition = [mapSize.x / 2, mapSize.y];
- }
-
- newNote = L.marker(map.containerPointToLatLng(markerPosition), {
- icon: noteIcons["new"],
- opacity: 0.9,
- draggable: true
- });
-
- newNote.addTo(noteLayer)
-
- newNote.on("remove", function (e) {
- addNoteButton.removeClass("active");
- }).on("dragstart", function (e) {
- $(newNote).stopTime("removenote");
- }).on("dragend", function (e) {
- content.find("textarea").focus();
- });
-
- content.find("textarea")
- .on("input", disableWhenBlank)
- .focus();
-
- function disableWhenBlank(e) {
- $(e.target.form.add).prop("disabled", $(e.target).val() === "");
- }
-
- content.find('input[type=submit]').on('click', function(e) {
- e.preventDefault();
- createNote(newNote, e.target.form, '/api/0.6/notes.json');
- });
- }
+ page.pushstate = page.popstate = function (path) {
+ OSM.loadSidebarContent(path, page.load);
+ };
+
+ page.load = function () {
+ if (addNoteButton.hasClass("disabled")) return;
+ if (addNoteButton.hasClass("active")) return;
+
+ addNoteButton.addClass("active");
+
+ map.addLayer(noteLayer);
+
+ var mapSize = map.getSize();
+ var markerPosition;