deleted_lat = null;
deleted_lon = null;
respondToHomeUpdate();
+ }).on("moveend", function () {
+ var lat = $("#home_lat").val(),
+ lon = $("#home_lon").val();
+
+ $("#home_show").prop("disabled", isCloseEnoughToMapCenter(lat, lon));
});
$("#home_lat, #home_lon").on("input", function () {
}
}
+ function isCloseEnoughToMapCenter(lat, lon) {
+ var inputPt = map.latLngToContainerPoint([lat, lon]),
+ centerPt = map.latLngToContainerPoint(map.getCenter());
+
+ return centerPt.distanceTo(inputPt) < 10;
+ }
+
function updateAuthUID() {
var provider = $("select#user_auth_provider").val();
<%= f.text_field :home_lat, :wrapper_class => "col-sm-4", :id => "home_lat" %>
<%= f.text_field :home_lon, :wrapper_class => "col-sm-4", :id => "home_lon" %>
<div class="col-sm-4 pt-2 align-self-end">
- <button type="button" id="home_show" class="btn btn-outline-primary"<% unless current_user.has_home? %> hidden<% end %>><%= t ".show" %></button>
+ <button type="button" id="home_show" class="btn btn-outline-primary"<% unless current_user.has_home? %> hidden<% end %> disabled><%= t ".show" %></button>
<button type="button" id="home_delete" class="btn btn-outline-primary"<% unless current_user.has_home? %> hidden<% end %>><%= t ".delete" %></button>
<button type="button" id="home_undelete" class="btn btn-outline-primary" hidden><%= t ".undelete" %></button>
</div>