14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/facebooker2/rails/helpers/javascript.rb', line 14
def fb_connect_async_js(app_id=Facebooker2.app_id,options={},&proc)
opts = Hash.new.merge!(options)
cookie = opts[:cookie].nil? ? true : opts[:cookie]
status = opts[:status].nil? ? true : opts[:status]
xfbml = opts[:xfbml].nil? ? true : opts[:xfbml]
channel_url = opts[:channel_url]
lang = opts[:locale] || 'en_US'
= capture(&proc) if block_given?
js = <<-JAVASCRIPT
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '#{app_id}',
status : #{status}, // check login status
cookie : #{cookie}, // enable cookies to allow the server to access the session
#{"channelUrl : '#{channel_url}', // add channelURL to avoid IE redirect problems" unless channel_url.blank?}
oauth : true,
xfbml : #{xfbml} // parse XFBML
});
#{}
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/#{lang}/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
JAVASCRIPT
escaped_js = fb_html_safe(js)
if block_given?
concat(escaped_js)
""
else
escaped_js
end
end
|