Clean up diary_entry.js
This commit is contained in:
parent
7f6320ed10
commit
8d13c39400
2 changed files with 27 additions and 23 deletions
|
@ -1,33 +1,37 @@
|
|||
var marker;
|
||||
$(document).ready(function () {
|
||||
var marker;
|
||||
|
||||
function setLocation( e ) {
|
||||
closeMapPopup();
|
||||
function setLocation(e) {
|
||||
closeMapPopup();
|
||||
|
||||
var lonlat = getEventPosition(e);
|
||||
var lonlat = getEventPosition(e);
|
||||
|
||||
$("#latitude").val(lonlat.lat);
|
||||
$("#longitude").val(lonlat.lon);
|
||||
$("#latitude").val(lonlat.lat);
|
||||
$("#longitude").val(lonlat.lon);
|
||||
|
||||
if (marker) {
|
||||
removeMarkerFromMap(marker);
|
||||
if (marker) {
|
||||
removeMarkerFromMap(marker);
|
||||
}
|
||||
|
||||
marker = addMarkerToMap(lonlat, null, I18n.t('diary_entry.edit.marker_text'));
|
||||
}
|
||||
|
||||
marker = addMarkerToMap(lonlat, null, I18n.t('diary_entry.edit.marker_text'));
|
||||
}
|
||||
$("#usemap").click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
function openMap() {
|
||||
$("#map").show();
|
||||
$("#usemap").hide();
|
||||
$("#map").show();
|
||||
$("#usemap").hide();
|
||||
|
||||
var params = $("#map").data();
|
||||
var centre = new OpenLayers.LonLat(params.lon, params.lat);
|
||||
var map = createMap("map");
|
||||
var params = $("#map").data();
|
||||
var centre = new OpenLayers.LonLat(params.lon, params.lat);
|
||||
var map = createMap("map");
|
||||
|
||||
setMapCenter(centre, params.zoom);
|
||||
setMapCenter(centre, params.zoom);
|
||||
|
||||
if ($("#latitude").val() && $("#longitude").val()) {
|
||||
marker = addMarkerToMap(centre, null, I18n.t('diary_entry.edit.marker_text'));
|
||||
}
|
||||
if ($("#latitude").val() && $("#longitude").val()) {
|
||||
marker = addMarkerToMap(centre, null, I18n.t('diary_entry.edit.marker_text'));
|
||||
}
|
||||
|
||||
map.events.register("click", map, setLocation);
|
||||
}
|
||||
map.events.register("click", map, setLocation);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<td>
|
||||
<%= content_tag "div", "", :id => "map", :data => {:lat => @lat, :lon => @lon, :zoom => @zoom} %>
|
||||
<span class="location"><%= 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" %></span>
|
||||
<a href="javascript:openMap()" id="usemap"><%= t 'diary_entry.edit.use_map_link' -%></a>
|
||||
<a href="#" id="usemap"><%= t 'diary_entry.edit.use_map_link' -%></a>
|
||||
<br/><br/>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue