Skip to content

Commit

Permalink
js sdk init fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pomartel committed Apr 1, 2011
1 parent 1518589 commit a626851
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/facebooker2/rails/helpers/javascript.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ def fb_html_safe(str)
end

def fb_connect_async_js(app_id=Facebooker2.app_id,options={},&proc)
opts = Hash.new(true).merge!(options)
cookie = opts[:cookie]
status = opts[:status]
xfbml = opts[:xfbml]
opts = Hash.new.merge!(options)
cookie = opts[:cookie] || true
status = opts[:status] || true
xfbml = opts[:xfbml] || true
channel_url = opts[:channel_url]
lang = opts[:locale] || 'en_US'
extra_js = capture(&proc) if block_given?
js = <<-JAVASCRIPT
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
Expand All @@ -32,13 +34,9 @@ def fb_connect_async_js(app_id=Facebooker2.app_id,options={},&proc)
};
(function() {
var s = document.createElement('div');
s.setAttribute('id','fb-root');
document.documentElement.getElementsByTagName("body")[0].appendChild(s);
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
s.appendChild(e);
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
Expand Down

0 comments on commit a626851

Please sign in to comment.