From ebd109c946d71b3ccc616ea3966e56ae019638d7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 9 May 2010 12:25:50 +0100 Subject: [PATCH] Replace openID.js with funky rails generated javascript --- app/helpers/user_helper.rb | 10 ++++++++++ app/views/user/login.html.erb | 32 +++++++++++--------------------- public/javascripts/openID.js | 22 ---------------------- 3 files changed, 21 insertions(+), 43 deletions(-) delete mode 100644 public/javascripts/openID.js diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index 0147c3fe6..eb2b34e90 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -1,2 +1,12 @@ module UserHelper + def openid_button(name, url) + link_to_function( + image_tag("#{name}.png", :alt => t("user.login.openid_providers.#{name}.alt")), + nil, + :title => t("user.login.openid_providers.#{name}.title") + ) do |page| + page[:login_form][:user_openid_url][:value] = url + page[:login_form].submit() + end + end end diff --git a/app/views/user/login.html.erb b/app/views/user/login.html.erb index e5f87e180..31379e03e 100644 --- a/app/views/user/login.html.erb +++ b/app/views/user/login.html.erb @@ -1,10 +1,8 @@ -<%= javascript_include_tag 'openID.js' %> -

<%= t 'user.login.heading' %>

<%= t 'user.login.please login', :create_user_link => link_to(t('user.login.create_account'), :controller => 'user', :action => 'new', :referer => params[:referer]) %>

-<% form_tag :action => 'login' do %> +<% form_tag({ :action => "login" }, { :id => "login_form" }) do %> <%= hidden_field_tag('referer', h(params[:referer])) %>
@@ -37,24 +35,16 @@ - - <%= image_tag "openid_logo.png", :alt => t('user.login.openid_providers.openid.title') %> - - - <%= image_tag "yahoo.png", :alt => t('user.login.openid_providers.yahoo.alt') %> - - - <%= image_tag "google.png", :alt => t('user.login.openid_providers.google.alt') %> - - - <%= image_tag "myopenid.png", :alt => t('user.login.openid_providers.myopenid.alt') %> - - - <%= image_tag "wordpress.png", :alt => t('user.login.openid_providers.wordpress.alt') %> - - - <%= image_tag "myspace.png", :alt => t('user.login.openid_providers.myspace.alt') %> - + <%= + link_to_function(image_tag("openid_logo.png", :alt => t("user.login.openid_providers.openid.title")), nil, :title => t("user.login.openid_providers.openid.title")) do |page| + page[:login_form][:user_openid_url][:value] = "http://" + end + %> + <%= openid_button "yahoo", "yahoo.com" %> + <%= openid_button "google", "gmail.com" %> + <%= openid_button "myopenid", "myopenid.com" %> + <%= openid_button "wordpress", "wordpress.com" %> + <%= openid_button "myspace", "myspace.com" %>
diff --git a/public/javascripts/openID.js b/public/javascripts/openID.js deleted file mode 100644 index 007ea0209..000000000 --- a/public/javascripts/openID.js +++ /dev/null @@ -1,22 +0,0 @@ -function openid_signin(provider) -{ - if (provider == 'google') { - document.forms[0].user_openid_url.value="gmail.com"; - document.forms[0].submit(); - } else if (provider == 'yahoo') { - document.forms[0].user_openid_url.value="yahoo.com"; - document.forms[0].submit(); - } else if (provider == 'myopenid') { - document.forms[0].user_openid_url.value="myopenid.com"; - document.forms[0].submit(); - } else if (provider == 'wordpress') { - document.forms[0].user_openid_url.value="wordpress.com"; - document.forms[0].submit(); - } else if (provider == 'myspace') { - document.forms[0].user_openid_url.value="myspace.com"; - document.forms[0].submit(); - } else if (provider == 'openid') { - document.forms[0].user_openid_url.value="http://"; - } - -} -- 2.39.5