diff --git a/app/assets/javascripts/diary_entry.js b/app/assets/javascripts/diary_entry.js
new file mode 100644
index 0000000000..c16930480e
--- /dev/null
+++ b/app/assets/javascripts/diary_entry.js
@@ -0,0 +1,37 @@
+$(document).ready(function () {
+ var marker;
+
+ function setLocation(e) {
+ closeMapPopup();
+
+ var lonlat = getEventPosition(e);
+
+ $("#latitude").val(lonlat.lat);
+ $("#longitude").val(lonlat.lon);
+
+ if (marker) {
+ removeMarkerFromMap(marker);
+ }
+
+ marker = addMarkerToMap(lonlat, null, I18n.t('diary_entry.edit.marker_text'));
+ }
+
+ $("#usemap").click(function (e) {
+ e.preventDefault();
+
+ $("#map").show();
+ $("#usemap").hide();
+
+ var params = $("#map").data();
+ var centre = new OpenLayers.LonLat(params.lon, params.lat);
+ var map = createMap("map");
+
+ setMapCenter(centre, params.zoom);
+
+ if ($("#latitude").val() && $("#longitude").val()) {
+ marker = addMarkerToMap(centre, null, I18n.t('diary_entry.edit.marker_text'));
+ }
+
+ map.events.register("click", map, setLocation);
+ });
+});
diff --git a/app/views/diary_entry/edit.html.erb b/app/views/diary_entry/edit.html.erb
index 0952c901bb..0cdd3b098b 100644
--- a/app/views/diary_entry/edit.html.erb
+++ b/app/views/diary_entry/edit.html.erb
@@ -1,3 +1,7 @@
+<% content_for :head do %>
+ <%= javascript_include_tag "diary_entry" %>
+<% end %>
+
<%= @title %>
<%= error_messages_for 'diary_entry' %>
@@ -19,9 +23,9 @@
<%= t 'diary_entry.edit.location' -%> |
-
+ <%= content_tag "div", "", :id => "map", :data => {:lat => @lat, :lon => @lon, :zoom => @zoom} %>
<%= t 'diary_entry.edit.latitude' -%> <%= f.text_field :latitude, :size => 20, :id => "latitude" %> <%= t 'diary_entry.edit.longitude' -%> <%= f.text_field :longitude, :size => 20, :id => "longitude" %>
- <%= t 'diary_entry.edit.use_map_link' -%>
+ <%= t 'diary_entry.edit.use_map_link' -%>
|
@@ -34,42 +38,3 @@
<% end %>
-
-
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 518d712fa4..f4602ce709 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -56,7 +56,7 @@
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
- config.assets.precompile += %w( index.js edit.js browse.js changeset.js user.js pngfix.js swfobject.js )
+ config.assets.precompile += %w( index.js edit.js browse.js changeset.js user.js diary_entry.js pngfix.js swfobject.js )
config.assets.precompile += %w( large-ltr.css small-ltr.css print-ltr.css )
config.assets.precompile += %w( large-rtl.css small-rtl.css print-rtl.css )
config.assets.precompile += %w( browse.css theme/openstreetmap/style.css )
diff --git a/config/i18n-js.yml b/config/i18n-js.yml
index 29855fe48c..982d60da74 100644
--- a/config/i18n-js.yml
+++ b/config/i18n-js.yml
@@ -28,3 +28,4 @@ translations:
- "*.javascripts.*"
- "*.site.index.remote_failed"
- "*.site.sidebar.search_results"
+ - "*.diary_entry.edit.marker_text"