Module: AuthlogicFacebookConnect::Helper

Defined in:
lib/authlogic_facebook_connect/helper.rb

Instance Method Summary collapse

Instance Method Details

#authlogic_facebook_login_button(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/authlogic_facebook_connect/helper.rb', line 3

def (options = {})
  # TODO: Make this with correct helpers istead of this uggly hack.
  
  options[:controller] ||= "user_session"
  options[:js] ||= :prototype
  
  case options[:js]
  when :prototype
    js_selector = "$('connect_to_facebook_form')"
  when :jquery
    js_selector = "jQuery('#connect_to_facebook_form')"
  end
  
  output = "<form id='connect_to_facebook_form' method='post' action='/#{options[:controller]}'>\n"
  output << "<input type='hidden' name='authenticity_token' value='#{form_authenticity_token}'/>\n"
  output << "</form>\n"
  output << "<script type='text/javascript' charset='utf-8'>\n"
  output << " function connect_to_facebook() {\n"
  output << "   #{js_selector}.submit();\n"
  output << " }\n"
  output << "</script>\n"
  options.delete(:controller)
  output << ("connect_to_facebook()", options)
  output
end