diff --git a/app/views/contents/_abandon_form.html.erb b/app/views/contents/_abandon_form.html.erb
new file mode 100644
index 0000000..58a6396
--- /dev/null
+++ b/app/views/contents/_abandon_form.html.erb
@@ -0,0 +1,6 @@
+<%= form_for @hydrant, :html => {:id => "abandon_form"} do |f| %>
+ <%= f.hidden_field "id" %>
+ <%= f.hidden_field "user_id", :value => "" %>
+ <%= f.hidden_field "name", :value => "" %>
+ <%= f.submit "Abandon this hydrant", :id => "abandon_form_submit" %>
+<% end %>
diff --git a/app/views/contents/_adoption_form.html.erb b/app/views/contents/_adoption_form.html.erb
index bbd36aa..3931d4f 100644
--- a/app/views/contents/_adoption_form.html.erb
+++ b/app/views/contents/_adoption_form.html.erb
@@ -1,12 +1,10 @@
<%= form_for @hydrant, :html => {:id => "adoption_form"} do |f| %>
Adopt this Hydrant
-
- <%= f.hidden_field "id" %>
- <%= f.hidden_field "user_id", :value => current_user.id %>
- <%= f.label "name", "Give your hydrant a name", :id => "hydrant_name_label" %>
- <%= f.text_field "name", :tabindex => 1 %>
- <%= f.submit "Adopt!", :tabindex => 2, :id => "adoption_form_submit" %>
-
By adopting this hydrant, you agree to the <%= link_to "Terms of Service", "#", :tabindex => 3 %>.
-
+ <%= f.hidden_field "id" %>
+ <%= f.hidden_field "user_id", :value => current_user.id %>
+ <%= f.label "name", "Give your hydrant a name", :id => "hydrant_name_label" %>
+ <%= f.text_field "name", :tabindex => 1 %>
+ <%= f.submit "Adopt!", :tabindex => 2, :id => "adoption_form_submit" %>
+ By adopting this hydrant, you agree to the <%= link_to "Terms of Service", "#", :tabindex => 3 %>.
<% end %>
<%= render :partial => 'sign_out_form' %>
diff --git a/app/views/contents/_thank_you.html.erb b/app/views/contents/_thank_you.html.erb
index 769ad97..69aab2e 100644
--- a/app/views/contents/_thank_you.html.erb
+++ b/app/views/contents/_thank_you.html.erb
@@ -1,2 +1,3 @@
Thank you for adopting this hydrant!
+<%= render :partial => 'abandon_form' %>
<%= render :partial => 'sign_out_form' %>
diff --git a/app/views/javascripts/main.js.erb b/app/views/javascripts/main.js.erb
index a000d33..e93b289 100644
--- a/app/views/javascripts/main.js.erb
+++ b/app/views/javascripts/main.js.erb
@@ -340,6 +340,36 @@ $(function() {
});
return false;
});
+ $('#abandon_form').live('submit', function() {
+ var answer = window.confirm("Are you sure you want to abandon this hydrant?")
+ if(answer) {
+ $.post('<%= hydrant_path :format => "json" %>', {
+ 'id': $('#hydrant_id').val(),
+ 'commit': $('#abandon_form_submit').val(),
+ 'utf8': '✓',
+ 'authenticity_token': $('#abandon_form input[name="authenticity_token"]').val(),
+ '_method': 'put',
+ 'hydrant': {
+ 'user_id': $('#hydrant_user_id').val(),
+ 'name': $('#hydrant_name').val()
+ }
+ }, function(data) {
+ $.get('<%= contents_path %>', {
+ 'hydrant_id': activeHydrantId
+ }, function(data) {
+ activeInfoWindow.setContent(data);
+ image = new google.maps.MarkerImage('/images/markers/red.png',
+ new google.maps.Size(27.0, 37.0),
+ new google.maps.Point(0, 0),
+ new google.maps.Point(13.0, 18.0)
+ );
+ activeMarker.setIcon(image);
+ activeMarker.setAnimation(null);
+ });
+ });
+ return false;
+ }
+ });
$('#steal_form').live('submit', function() {
var answer = window.confirm("Are you sure you want to steal this hydrant?")
if(answer) {