return content[0];
}
+ var addNoteButton = $(".control-note .control-button");
+
function createNote(marker, form, url) {
var location = marker.getLatLng();
notes[feature.properties.id] = updateMarker(marker, feature);
newNote = null;
- $("#createnoteanchor").removeClass("disabled").addClass("geolink");
+ addNoteButton.removeClass("disabled");
}
}
});
}
- $(".leaflet-control-attribution").on("click", "#createnoteanchor", function (e) {
+ addNoteButton.on("click", function (e) {
e.preventDefault();
+ e.stopPropagation();
- if ($(e.target).hasClass("disabled")) return;
+ if (addNoteButton.hasClass("disabled")) return;
- $(e.target).removeClass("geolink").addClass("disabled");
+ addNoteButton.addClass("disabled");
map.addLayer(noteLayer);
draggable: true
});
- var popupContent = $(JST["templates/notes/new"]({
- create_url: $(e.target).attr("href")
- }));
+ var popupContent = $(JST["templates/notes/new"]());
popupContent.find("textarea").on("input", disableWhenBlank);
function disableWhenBlank(e) {
- $(e.target.form).prop("disabled", $(e.target).val() === "");
+ $(e.target.form.add).prop("disabled", $(e.target).val() === "");
}
popupContent.find("input[type=submit]").on("click", function (e) {
e.preventDefault();
- createNote(newNote, e.target.form, $(e.target).data("url"));
+ createNote(newNote, e.target.form, '/api/0.6/notes.json');
});
newNote.addTo(noteLayer).bindPopup(popupContent[0], popupOptions()).openPopup();
newNote.on("remove", function (e) {
- $("#createnoteanchor").removeClass("disabled").addClass("geolink");
+ addNoteButton.removeClass("disabled");
}).on("dragstart", function (e) {
$(newNote).stopTime("removenote");
}).on("dragend", function (e) {
$('<a>')
.attr('class', 'control-button')
.attr('href', '#')
- .attr('title', 'Notes')
+ .attr('title', I18n.t('javascripts.notes.new.add'))
.html('<span class="icon note"></span>')
- .on('click', toggle)
.appendTo($container);
- function toggle(e) {
- e.stopPropagation();
- e.preventDefault();
-
- if (map.hasLayer(map.noteLayer)) {
- map.removeLayer(map.noteLayer);
- } else {
- map.addLayer(map.noteLayer);
- }
- }
-
return $container[0];
};
}
.leaflet-control .zoomin,
-.control-layers .control-button,
-.control-note .control-button {
+.control-layers .control-button {
margin-bottom: 0px;
border-radius: 4px 4px 0px 0px;
}
-.leaflet-control .zoomout {
+.leaflet-control .zoomout,
+.control-key .control-button {
margin-bottom: 0px;
border-radius: 0px;
}
.control-locate .control-button,
-.control-key .control-button,
.control-share .control-button {
border-radius: 0px 0px 4px 4px;
}