-
Notifications
You must be signed in to change notification settings - Fork 4
/
view_helpers.rb
37 lines (33 loc) · 1.08 KB
/
view_helpers.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
30
31
32
33
34
35
36
37
# encoding: utf-8
module DeviseFacebookOpenGraph
module Rails
module ViewHelpers
#
# Inserts facebook HTML and javascript tag for initializing
# JavaScript SDK. See http://developers.facebook.com/docs/authentication/: Single Sign-on.
#
# Some options to this helper-method might be added in the future :-)
#
def facebook_init_javascript_sdk
buffer = content_tag :div, '', :id => 'fb-root'
buffer << javascript_include_tag(DeviseFacebookOpenGraph::Facebook::Config.sdk_java_script_source)
buffer << javascript_tag(<<-JAVASCRIPT)
FB.init({
appId: '#{DeviseFacebookOpenGraph::Facebook::Config.application_id}',
status: true,
cookie: true,
xfbml: true
});
FB.Event.subscribe('auth.sessionChange', function(response) {
if (response.session) {
alert("Logged in via FB!");
} else {
alert("Logged out via FB!");
}
});
JAVASCRIPT
buffer.html_safe
end
end
end
end