-
Notifications
You must be signed in to change notification settings - Fork 52
/
helper.rb
29 lines (26 loc) · 1.03 KB
/
helper.rb
1
2
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
28
29
module AuthlogicFacebookConnect
module Helper
def authlogic_facebook_login_button(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 << fb_login_button("connect_to_facebook()", options)
output
end
end
end