Merge branch 'master' of http://github.com/mixr/facebooker2
* 'master' of http://github.com/mixr/facebooker2: - the async call needs to load into the body, otherwise FB.ui doesn't work in "dialog" mode - facebook also recommends loading into the front of the body: http://developers.facebook.com/docs/reference/javascript/FB.init added methods fb_concat and fb_html_safe -> use concat or not, depending on rails version -> use html_safe when available fixed version check make fb_connect_async_js return a html_safe string for rails 3 use :locale parameter in options to set locale of fb-connect javascript assets Conflicts: lib/facebooker2/rails/helpers/javascript.rb
This commit is contained in:
commit
0937d2ba9d
@ -2,6 +2,13 @@ module Facebooker2
|
||||
module Rails
|
||||
module Helpers
|
||||
module Javascript
|
||||
def fb_concat(str)
|
||||
if ::Rails::VERSION::STRING.to_i > 2
|
||||
str
|
||||
else
|
||||
concat(str)
|
||||
end
|
||||
end
|
||||
|
||||
def fb_html_safe(str)
|
||||
if str.respond_to?(:html_safe)
|
||||
@ -16,6 +23,7 @@ module Facebooker2
|
||||
cookie = opts[:cookie]
|
||||
status = opts[:status]
|
||||
xfbml = opts[:xfbml]
|
||||
locale = options[:locale] || "en_US"
|
||||
extra_js = capture(&proc) if block_given?
|
||||
js = <<-JAVASCRIPT
|
||||
<script>
|
||||
@ -34,13 +42,13 @@ module Facebooker2
|
||||
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.src = document.location.protocol + '//connect.facebook.net/#{locale}/all.js';
|
||||
e.async = true;
|
||||
s.appendChild(e);
|
||||
}());
|
||||
</script>
|
||||
JAVASCRIPT
|
||||
js
|
||||
fb_html_safe(block_given? ? fb_concat(js) : js)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user