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 ) {
|
function setLocation(e) {
|
||||||
closeMapPopup();
|
closeMapPopup();
|
||||||
|
|
||||||
var lonlat = getEventPosition(e);
|
var lonlat = getEventPosition(e);
|
||||||
|
|
||||||
$("#latitude").val(lonlat.lat);
|
$("#latitude").val(lonlat.lat);
|
||||||
$("#longitude").val(lonlat.lon);
|
$("#longitude").val(lonlat.lon);
|
||||||
|
|
||||||
if (marker) {
|
if (marker) {
|
||||||
removeMarkerFromMap(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();
|
||||||
$("#map").show();
|
$("#usemap").hide();
|
||||||
$("#usemap").hide();
|
|
||||||
|
|
||||||
var params = $("#map").data();
|
var params = $("#map").data();
|
||||||
var centre = new OpenLayers.LonLat(params.lon, params.lat);
|
var centre = new OpenLayers.LonLat(params.lon, params.lat);
|
||||||
var map = createMap("map");
|
var map = createMap("map");
|
||||||
|
|
||||||
setMapCenter(centre, params.zoom);
|
setMapCenter(centre, params.zoom);
|
||||||
|
|
||||||
if ($("#latitude").val() && $("#longitude").val()) {
|
if ($("#latitude").val() && $("#longitude").val()) {
|
||||||
marker = addMarkerToMap(centre, null, I18n.t('diary_entry.edit.marker_text'));
|
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>
|
<td>
|
||||||
<%= content_tag "div", "", :id => "map", :data => {:lat => @lat, :lon => @lon, :zoom => @zoom} %>
|
<%= 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>
|
<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/>
|
<br/><br/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue