aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb4
-rw-r--r--app/controllers/request_controller.rb18
-rw-r--r--app/controllers/user_controller.rb9
-rw-r--r--app/views/layouts/no_chrome.rhtml47
-rw-r--r--app/views/request/new.rhtml38
-rw-r--r--app/views/request/preview.rhtml33
-rw-r--r--app/views/user/signin_successful.rhtml6
7 files changed, 71 insertions, 84 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 5f18be2e5..4e6ad5efb 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -192,7 +192,9 @@ class ApplicationController < ActionController::Base
post_redirect = PostRedirect.new(:uri => request.request_uri, :post_params => params,
:reason_params => reason_params)
post_redirect.save!
- redirect_to signin_url(:token => post_redirect.token)
+ # 'modal' controls whether the sign-in form will be displayed in the typical full-blown
+ # page or on its own, useful for pop-ups
+ redirect_to signin_url(:token => post_redirect.token, :modal => params[:modal])
return false
end
return true
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index d39b78f36..88fb9be6c 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -276,6 +276,15 @@ class RequestController < ApplicationController
return
end
+ if !authenticated?(
+ :web => _("To send your FOI request"),
+ :email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name),
+ :email_subject => _("Confirm your FOI request to ") + @info_request.public_body.name
+ )
+ # do nothing - as "authenticated?" has done the redirect to signin page for us
+ return
+ end
+
# Show preview page, if it is a preview
if params[:preview].to_i == 1
message = ""
@@ -298,15 +307,6 @@ class RequestController < ApplicationController
return
end
- if !authenticated?(
- :web => _("To send your FOI request"),
- :email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name),
- :email_subject => _("Confirm your FOI request to ") + @info_request.public_body.name
- )
- # do nothing - as "authenticated?" has done the redirect to signin page for us
- return
- end
-
@info_request.user = authenticated_user
# This automatically saves dependent objects, such as @outgoing_message, in the same transaction
@info_request.save!
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 3dcdf973b..3e3913fae 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -109,7 +109,7 @@ class UserController < ApplicationController
session[:user_circumstance] = nil
session[:remember_me] = params[:remember_me] ? true : false
- if @is_modal_dialog
+ if is_modal_dialog
render :action => 'signin_successful'
else
do_post_redirect @post_redirect
@@ -507,10 +507,13 @@ class UserController < ApplicationController
private
+ def is_modal_dialog
+ (params[:modal].to_i != 0)
+ end
+
# when logging in through a modal iframe, don't display chrome around the content
def select_layout
- @is_modal_dialog = (params[:modal].to_i != 0)
- @is_modal_dialog ? 'no_chrome' : 'default'
+ is_modal_dialog ? 'no_chrome' : 'default'
end
# Decide where we are going to redirect back to after signin/signup, and record that
diff --git a/app/views/layouts/no_chrome.rhtml b/app/views/layouts/no_chrome.rhtml
index 2c6463bdc..8225aec75 100644
--- a/app/views/layouts/no_chrome.rhtml
+++ b/app/views/layouts/no_chrome.rhtml
@@ -1,39 +1,14 @@
-<!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') %>
+<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 %>
- </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 id="<%= controller.controller_name + "_" + controller.action_name %>" class="controller_<%= controller.controller_name %>">
+ <%= yield :layout %>
</div>
- </body>
-</html>
+ </div>
+</div>
diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml
index e8dd395a4..6105fe344 100644
--- a/app/views/request/new.rhtml
+++ b/app/views/request/new.rhtml
@@ -9,6 +9,43 @@
});
</script>
+<% if !@user %>
+<%= javascript_include_tag 'jquery.fancybox-1.3.4.pack' %>
+<%= javascript_include_tag 'jquery.form' %>
+<script>
+ function onSuccessfulLogin() {
+ $.fancybox.close();
+ $("#write_form").ajaxFormUnbind();
+ $("#write_form").submit();
+ }
+
+ function interceptFormSubmit(form_id) {
+ $(form_id).ajaxForm({
+ success: function(responseText) {
+ $("#fancybox-content").html(responseText);
+ interceptFormSubmits();
+ }
+ });
+ };
+
+ function interceptFormSubmits() {
+ interceptFormSubmit("#signin_form");
+ interceptFormSubmit("#signup_form");
+ };
+
+ $(document).ready(function() {
+ $("#write_form").ajaxForm({
+ success: function(responseText) {
+ $.fancybox({
+ 'content': responseText,
+ 'onComplete': interceptFormSubmits
+ });
+ }
+ });
+ });
+</script>
+<% end %>
+
<% @title = _("Make an {{law_used_short}} request to '{{public_body_name}}'",:law_used_short=>h(@info_request.law_used_short),:public_body_name=>h(@info_request.public_body.name)) %>
<% if @existing_request %>
@@ -130,6 +167,7 @@
<%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %>
<%= hidden_field_tag(:submitted_new_request, 1 ) %>
<%= hidden_field_tag(:preview, 1 ) %>
+ <%= hidden_field_tag(:modal, 1 ) %>
<%= submit_tag _("Preview your public request") %>
</div>
diff --git a/app/views/request/preview.rhtml b/app/views/request/preview.rhtml
index 38cbf24f0..45b6a3dc1 100644
--- a/app/views/request/preview.rhtml
+++ b/app/views/request/preview.rhtml
@@ -1,24 +1,3 @@
-<% 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| %>
@@ -59,19 +38,11 @@
<%= hidden_field_tag(:submitted_new_request, 1) %>
<%= hidden_field_tag(:preview, 0 ) %>
<%= 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>
+ <%= submit_tag _("Send request"), :name => 'submit', :id => 'submit_button' %>
</p>
<% if !@info_request.tag_string.empty? %>
<p><strong><%= _('Tags:') %></strong> <%=h @info_request.tag_string %></p>
<% end %>
-<% end %>
+<% end %> \ No newline at end of file
diff --git a/app/views/user/signin_successful.rhtml b/app/views/user/signin_successful.rhtml
index 49eea277f..ca5978a8d 100644
--- a/app/views/user/signin_successful.rhtml
+++ b/app/views/user/signin_successful.rhtml
@@ -4,10 +4,8 @@ You're in.
<a href="#" id="send-request">Continue sending your request</a>
-<script>
- parent.modal_signin_successful = true;
-
+<script>
$("#send-request").click(function() {
- parent.$.fancybox.close(); return false;
+ onSuccessfulLogin(); return false;
});
</script> \ No newline at end of file