diff --git a/app/controllers/hydrants_controller.rb b/app/controllers/hydrants_controller.rb index 5143d14..f50c86e 100644 --- a/app/controllers/hydrants_controller.rb +++ b/app/controllers/hydrants_controller.rb @@ -11,7 +11,7 @@ class HydrantsController < ApplicationController if user_signed_in? render("adopt", :layout => "info_window") else - render("users/new", :layout => "info_window") + render("sessions/new", :layout => "info_window") end end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 02d1a50..6a5ccb8 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,4 +1,8 @@ class SessionsController < Devise::SessionsController + def new + render("new", :layout => "info_window") + end + def create resource = warden.authenticate(:scope => resource_name) if resource diff --git a/app/views/hydrants/adopt.html.erb b/app/views/hydrants/adopt.html.erb index 269c6ef..a5a4c4a 100644 --- a/app/views/hydrants/adopt.html.erb +++ b/app/views/hydrants/adopt.html.erb @@ -8,4 +8,4 @@

By adopting this hydrant, you agree to the <%= link_to "Terms of Service", "#", :tabindex => 3 %>.

<% end %> <%= render(:partial => 'users/edit_profile') %> -<%= render(:partial => 'users/sign_out') %> +<%= render(:partial => 'sessions/sign_out') %> diff --git a/app/views/sessions/_sign_in.html.erb b/app/views/sessions/_sign_in.html.erb new file mode 100644 index 0000000..a05fac3 --- /dev/null +++ b/app/views/sessions/_sign_in.html.erb @@ -0,0 +1,3 @@ +<%= form_for(:sign_in, :html => {:id => "sign_in_form"}) do |f| %> + <%= f.submit "Sign in", :id => "sign_in_form_submit" %> +<% end %> diff --git a/app/views/users/_sign_out.html.erb b/app/views/sessions/_sign_out.html.erb similarity index 100% rename from app/views/users/_sign_out.html.erb rename to app/views/sessions/_sign_out.html.erb diff --git a/app/views/users/new.html.erb b/app/views/sessions/new.html.erb similarity index 100% rename from app/views/users/new.html.erb rename to app/views/sessions/new.html.erb diff --git a/app/views/users/profile.html.erb b/app/views/users/profile.html.erb index 2a47ed1..61845dd 100644 --- a/app/views/users/profile.html.erb +++ b/app/views/users/profile.html.erb @@ -3,5 +3,7 @@ <% if user_signed_in? %> <%= render(:partial => 'users/edit_profile') %> <%= render(:partial => 'hydrants/steal') %> -<%= render(:partial => 'users/sign_out') %> +<%= render(:partial => 'sessions/sign_out') %> +<% else %> +<%= render(:partial => 'sessions/sign_in') %> <% end %> diff --git a/app/views/users/thank_you.html.erb b/app/views/users/thank_you.html.erb index 5ddc3cd..4c061fe 100644 --- a/app/views/users/thank_you.html.erb +++ b/app/views/users/thank_you.html.erb @@ -1,4 +1,4 @@

Thank you for adopting this hydrant!

<%= render(:partial => 'users/edit_profile') %> <%= render(:partial => 'hydrants/abandon') %> -<%= render(:partial => 'users/sign_out') %> +<%= render(:partial => 'sessions/sign_out') %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 2838dfc..91f66b6 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -378,36 +378,6 @@ $(function() { } return false; }); - $('#sign_out_form').live('submit', function() { - var submitButton = $("#sign_out_form input[type='submit']"); - $(submitButton).attr("disabled", true); - $.ajax({ - type: 'GET', - url: '/users/sign_out.json', - data: { - 'commit': $('#sign_out_form_submit').val(), - 'utf8': '✓', - 'authenticity_token': $('#sign_out_form input[name="authenticity_token"]').val() - }, - beforeSend: function() { - $('#info_window').hide(); - $('#loader').show(); - }, - success: function(data) { - $.ajax({ - type: 'GET', - url: '/hydrant', - data: { - 'hydrant_id': activeHydrantId - }, - success: function(data) { - activeInfoWindow.setContent(data); - } - }); - } - }); - return false; - }); $('#adoption_form').live('submit', function() { var submitButton = $("#adoption_form input[type='submit']"); $(submitButton).attr("disabled", true); @@ -677,13 +647,67 @@ $(function() { } return false; }); + $('#sign_out_form').live('submit', function() { + var submitButton = $("#sign_out_form input[type='submit']"); + $(submitButton).attr("disabled", true); + $.ajax({ + type: 'GET', + url: '/users/sign_out.json', + data: { + 'commit': $('#sign_out_form_submit').val(), + 'utf8': '✓', + 'authenticity_token': $('#sign_out_form input[name="authenticity_token"]').val() + }, + beforeSend: function() { + $('#info_window').hide(); + $('#loader').show(); + }, + success: function(data) { + $.ajax({ + type: 'GET', + url: '/hydrant', + data: { + 'hydrant_id': activeHydrantId + }, + success: function(data) { + activeInfoWindow.setContent(data); + } + }); + } + }); + return false; + }); + $('#sign_in_form').live('submit', function() { + var submitButton = $("#sign_in_form input[type='submit']"); + $(submitButton).attr("disabled", true); + $.ajax({ + type: 'GET', + url: '/users/sign_in', + data: { + 'commit': $('#sign_in_form_submit').val(), + 'utf8': '✓', + 'authenticity_token': $('#sign_in_form input[name="authenticity_token"]').val(), + }, + beforeSend: function() { + $('#info_window').hide(); + $('#loader').show(); + }, + success: function(data) { + activeInfoWindow.setContent(data); + } + }); + return false; + }); $('#back_form').live('submit', function() { - var submitButton = $("#edit_form input[type='submit']"); + var submitButton = $("#back_form input[type='submit']"); $(submitButton).attr("disabled", true); $.ajax({ type: 'GET', url: '/hydrant', data: { + 'commit': $('#back_form_submit').val(), + 'utf8': '✓', + 'authenticity_token': $('#back_form input[name="authenticity_token"]').val(), 'hydrant_id': activeHydrantId }, beforeSend: function() {