From 04887011d4e8c4e4394fd95479972e636d7c48d7 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 5 Oct 2012 11:54:13 -0700 Subject: [PATCH] Eliminate interpolation in diary entry JS --- app/views/diary_entry/edit.html.erb | 17 ++++++++--------- config/i18n-js.yml | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/diary_entry/edit.html.erb b/app/views/diary_entry/edit.html.erb index 0952c901b..33e4d2719 100644 --- a/app/views/diary_entry/edit.html.erb +++ b/app/views/diary_entry/edit.html.erb @@ -19,7 +19,7 @@ <%= 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' -%>

@@ -51,23 +51,22 @@ removeMarkerFromMap(marker); } - marker = addMarkerToMap(lonlat, null, "<%= t 'diary_entry.edit.marker_text' -%>"); + marker = addMarkerToMap(lonlat, null, I18n.t('diary_entry.edit.marker_text')); } function openMap() { $("#map").show(); $("#usemap").hide(); - var centre = new OpenLayers.LonLat(<%= @lon %>, <%= @lat %>); - var zoom = <%= @zoom %>; - + var params = $("#map").data(); + var centre = new OpenLayers.LonLat(params.lon, params.lat); var map = createMap("map"); - setMapCenter(centre, zoom); + setMapCenter(centre, params.zoom); - <% if @diary_entry.latitude and @diary_entry.longitude %> - marker = addMarkerToMap(centre, null, "<%= t 'diary_entry.edit.marker_text' -%>"); - <% end %> + 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/config/i18n-js.yml b/config/i18n-js.yml index 29855fe48..982d60da7 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" -- 2.39.5