diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/user_controller.rb | 23 | ||||
-rw-r--r-- | app/views/layouts/default.rhtml | 2 | ||||
-rw-r--r-- | app/views/layouts/no_chrome.rhtml | 39 | ||||
-rw-r--r-- | app/views/request/preview.rhtml | 35 | ||||
-rw-r--r-- | app/views/user/_signin.rhtml | 1 | ||||
-rw-r--r-- | app/views/user/_signup.rhtml | 1 | ||||
-rw-r--r-- | app/views/user/signin_successful.rhtml | 13 |
7 files changed, 105 insertions, 9 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index d3c42c7f1..7b99be393 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -72,6 +72,10 @@ class UserController < ApplicationController def signin work_out_post_redirect + # when logging in through a modal iframe, don't display chrome around the content + @is_modal_dialog = (params[:modal].to_i != 0) + layout = @is_modal_dialog ? 'no_chrome' : 'default' + # make sure we have cookies if session.instance_variable_get(:@dbman) if not session.instance_variable_get(:@dbman).instance_variable_get(:@original) @@ -80,7 +84,7 @@ class UserController < ApplicationController redirect_to signin_url(:r => params[:r], :again => 1) return end - render :action => 'no_cookies' + render :action => 'no_cookies', :layout => layout return end end @@ -92,13 +96,13 @@ class UserController < ApplicationController if not params[:user_signin] # First time page is shown - render :action => 'sign' + render :action => 'sign', :layout => layout return else @user_signin = User.authenticate_from_form(params[:user_signin], @post_redirect.reason_params[:user_name] ? true : false) if @user_signin.errors.size > 0 # Failed to authenticate - render :action => 'sign' + render :action => 'sign', :layout => layout return else # Successful login @@ -106,7 +110,12 @@ class UserController < ApplicationController session[:user_id] = @user_signin.id session[:user_circumstance] = nil session[:remember_me] = params[:remember_me] ? true : false - do_post_redirect @post_redirect + + if @is_modal_dialog + render :action => 'signin_successful', :layout => layout + else + do_post_redirect @post_redirect + end else send_confirmation_mail @user_signin end @@ -119,11 +128,15 @@ class UserController < ApplicationController def signup work_out_post_redirect + # when logging in through a modal iframe, don't display chrome around the content + @is_modal_dialog = (params[:modal].to_i != 0) + layout = @is_modal_dialog ? 'no_chrome' : 'default' + # Make the user and try to save it @user_signup = User.new(params[:user_signup]) if !@user_signup.valid? # Show the form - render :action => 'sign' + render :action => 'sign', :layout => layout else user_alreadyexists = User.find_user_by_email(params[:user_signup][:email]) if user_alreadyexists diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index 97462fc91..391f2df15 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -26,6 +26,8 @@ <style type="text/css">@import url("/stylesheets/ie6-custom.css");</style> <![endif]--> <%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %> + <!-- XXX: add conditional include --> + <%= stylesheet_link_tag 'jquery.fancybox-1.3.4', :rel => "stylesheet" %> <% if @feed_autodetect %> <% for feed in @feed_autodetect %> diff --git a/app/views/layouts/no_chrome.rhtml b/app/views/layouts/no_chrome.rhtml new file mode 100644 index 000000000..2c6463bdc --- /dev/null +++ b/app/views/layouts/no_chrome.rhtml @@ -0,0 +1,39 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> +<html lang="<%= I18n.locale %>"> + <head> + <title> + <% if @title %> + <%=@title%> - <%= site_name %> + <% else %> + <%= site_name %> - <%= _('Make and browse Freedom of Information (FOI) requests') %> + <% end %> + </title> + + <script type="text/javascript" src="/javascripts/jquery.js"></script> + + <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %> + <!--[if LT IE 7]> + <style type="text/css">@import url("/stylesheets/ie6.css");</style> + <![endif]--> + <!--[if LT IE 7]> + <style type="text/css">@import url("/stylesheets/ie6-custom.css");</style> + <![endif]--> + <%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %> + </head> + <body> + <div class="entirebody"> + <div id="content"> + <% if flash[:notice] %> + <div id="notice"><%= flash[:notice] %></div> + <% end %> + <% if flash[:error] %> + <div id="error"><%= flash[:error] %></div> + <% end %> + + <div id="<%= controller.controller_name + "_" + controller.action_name %>" class="controller_<%= controller.controller_name %>"> + <%= yield :layout %> + </div> + </div> + </div> + </body> +</html> diff --git a/app/views/request/preview.rhtml b/app/views/request/preview.rhtml index 1dab22960..38cbf24f0 100644 --- a/app/views/request/preview.rhtml +++ b/app/views/request/preview.rhtml @@ -1,3 +1,24 @@ +<% if !@user %> +<%= javascript_include_tag 'jquery.fancybox-1.3.4.pack' %> +<script> + $(document).ready(function() { + $("#submit_button").fancybox({ + 'modal': false, + 'width': 960, + 'height': 500, + 'type': 'iframe', + 'href': '/en/profile/sign_in?modal=1', + 'onClosed': function() { + // modal_signin_successful variable set by modal dialog box + if (typeof modal_signin_successful != 'undefined' ) { + $("#hidden_submit_button").click(); + } + } + }); + }); +</script> +<% end %> + <% @title = "Preview new " + h(@info_request.law_used_short) + " request to '" + h(@info_request.public_body.name) + "'" %> <% form_for(:info_request, @info_request, :html => { :id => 'preview_form' } ) do |f| %> @@ -37,8 +58,16 @@ <%= f.hidden_field(:tag_string) %> <%= hidden_field_tag(:submitted_new_request, 1) %> <%= hidden_field_tag(:preview, 0 ) %> - <%= submit_tag _("Edit this request"), :name => 'reedit' %> - <%= submit_tag _("Send request"), :name => 'submit' %> + <%= submit_tag _("Edit this request"), :name => 'reedit', :id => 'reedit_button' %> + <%= submit_tag _("Send request"), :name => 'submit', :id => 'submit_button' %> + + <!-- Since FancyBox is intercepting the click event to display the modal login form, + and I can't find a way of accessing the underlying default behaviour of the button, + we hide another submit button without FancyBox, to be called programatically. + Feels hacky. --> + <div style="visibility: hidden"> + <%= submit_tag _("Send request"), :name => 'submit', :id => 'hidden_submit_button' %> + </div> </p> <% if !@info_request.tag_string.empty? %> @@ -46,5 +75,3 @@ <% end %> <% end %> - - diff --git a/app/views/user/_signin.rhtml b/app/views/user/_signin.rhtml index c6661696e..49f604ca5 100644 --- a/app/views/user/_signin.rhtml +++ b/app/views/user/_signin.rhtml @@ -28,6 +28,7 @@ <div class="form_button"> <%= hidden_field_tag 'token', params[:token], { :id => 'signin_token' } %> + <%= hidden_field_tag :modal, params[:modal] %> <%= submit_tag _('Sign in') %> </div> <% end %> diff --git a/app/views/user/_signup.rhtml b/app/views/user/_signup.rhtml index 70120bc5f..c3c286151 100644 --- a/app/views/user/_signup.rhtml +++ b/app/views/user/_signup.rhtml @@ -38,6 +38,7 @@ <div class="form_button"> <%= hidden_field_tag 'token', params[:token], { :id => 'signup_token' } %> + <%= hidden_field_tag :modal, params[:modal] %> <%= submit_tag _('Sign up') %> </div> diff --git a/app/views/user/signin_successful.rhtml b/app/views/user/signin_successful.rhtml new file mode 100644 index 000000000..49eea277f --- /dev/null +++ b/app/views/user/signin_successful.rhtml @@ -0,0 +1,13 @@ +<!-- XXX Unfinished page --> + +You're in. + +<a href="#" id="send-request">Continue sending your request</a> + +<script> + parent.modal_signin_successful = true; + + $("#send-request").click(function() { + parent.$.fancybox.close(); return false; + }); +</script>
\ No newline at end of file |