From: Tom Hughes Date: Tue, 27 Apr 2010 09:01:40 +0000 (+0100) Subject: Ajaxify the country selection on the terms page X-Git-Tag: live~6294^2~13 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/adb0883d173c18590b66a1ebad1b335c54d3988d Ajaxify the country selection on the terms page --- diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 603fb2a49..27d124dae 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -25,7 +25,11 @@ class UserController < ApplicationController @legale = params[:legale] || OSM.IPToCountry(request.remote_ip) || APP_CONFIG['default_legale'] @text = OSM.legal_text_for_country(@legale) - if @user.invalid? + if request.xhr? + render :update do |page| + page.replace_html "contributorTerms", :partial => "terms" + end + elsif @user.invalid? render :action => 'new' end end diff --git a/app/views/user/_terms.html.erb b/app/views/user/_terms.html.erb new file mode 100644 index 000000000..849f536e3 --- /dev/null +++ b/app/views/user/_terms.html.erb @@ -0,0 +1,30 @@ +

<%= @text['intro'] %>

+
    +
  1. +

    <%= @text['section_1'] %>

    +
  2. +
  3. +

    <%= @text['section_2'] %>

    +
  4. +
  5. +

    <%= @text['section_3'] %>

    +

    <%= @text['active_defn_1'] %>

    +

    <%= @text['active_defn_2'] %>

    +
  6. +
  7. +

    <%= @text['section_4'] %>

    +
  8. +
  9. +

    <%= @text['section_5'] %>

    +
  10. +
  11. +

    <%= @text['section_6'] %>

    +
      +
    1. <%= @text['section_6_1'] %>

    2. +
    3. <%= @text['section_6_2'] %>

    4. +
    +
  12. +
  13. +

    <%= @text['section_7'] %>

    +
  14. +
diff --git a/app/views/user/terms.html.erb b/app/views/user/terms.html.erb index daa4396ff..a370d4b48 100644 --- a/app/views/user/terms.html.erb +++ b/app/views/user/terms.html.erb @@ -4,51 +4,25 @@ <% form_tag :action => 'terms' do %> -

<%= t 'user.terms.legale_select' %>

- <% [['france', 'FR'], ['italy', 'IT'], ['rest_of_world', 'GB']].each do |name,legale| %> - <%= radio_button_tag 'legale', legale, @legale == legale %> - <%= label_tag "legale_#{legale}", t('user.terms.legale_names.' + name) %>
- <% end %> - <%= hidden_field_tag('referer', h(params[:referer])) unless params[:referer].nil? %> - <%= hidden_field('user', 'email') %> - <%= hidden_field('user', 'email_confirmation') %> - <%= hidden_field('user', 'display_name') %> - <%= hidden_field('user', 'pass_crypt') %> - <%= hidden_field('user', 'pass_crypt_confirmation') %> - <%= submit_tag(t('user.terms.legale_button')) %> +

+ <%= t 'user.terms.legale_select' %> + <% [['france', 'FR'], ['italy', 'IT'], ['rest_of_world', 'GB']].each do |name,legale| %> + <%= + radio_button_tag 'legale', legale, @legale == legale, + :onchange => remote_function( + :before => update_page do |page| + page.replace_html 'contributorTerms', image_tag('searching.gif') + end, + :url => {:legale => legale} + ) + %> + <%= label_tag "legale_#{legale}", t('user.terms.legale_names.' + name) %> + <% end %> +

<% end %>
-

<%= @text['intro'] %>

-
    -
  1. -

    <%= @text['section_1'] %>

    -
  2. -
  3. -

    <%= @text['section_2'] %>

    -
  4. -
  5. -

    <%= @text['section_3'] %>

    -

    <%= @text['active_defn_1'] %>

    -

    <%= @text['active_defn_2'] %>

    -
  6. -
  7. -

    <%= @text['section_4'] %>

    -
  8. -
  9. -

    <%= @text['section_5'] %>

    -
  10. -
  11. -

    <%= @text['section_6'] %>

    -
      -
    1. <%= @text['section_6_1'] %>

    2. -
    3. <%= @text['section_6_2'] %>

    4. -
    -
  12. -
  13. -

    <%= @text['section_7'] %>

    -
  14. -
+ <%= render :partial => "terms" %>
<% form_tag :action => 'save' do %> diff --git a/public/stylesheets/common.css b/public/stylesheets/common.css index 362e5d619..2c99cf074 100644 --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@ -562,6 +562,13 @@ div#contributorTerms ol { margin-bottom: 0px; } +div#contributorTerms img { + display: block; + margin-left: auto; + margin-right: auto; + margin-top: 10%; +} + /* Rules for the account settings page */ #accountForm td {