Insert the fb-root dynamically
This commit is contained in:
parent
6b721aaca9
commit
52491b2446
@ -1,6 +1,6 @@
|
|||||||
spec = Gem::Specification.new do |s|
|
spec = Gem::Specification.new do |s|
|
||||||
s.name = 'facebooker2'
|
s.name = 'facebooker2'
|
||||||
s.version = '0.0.3'
|
s.version = '0.0.4'
|
||||||
s.summary = "Facebook Connect integration library for ruby and rails"
|
s.summary = "Facebook Connect integration library for ruby and rails"
|
||||||
s.description = "Facebook Connect integration library for ruby and rails"
|
s.description = "Facebook Connect integration library for ruby and rails"
|
||||||
s.files = Dir['lib/**/*.rb']
|
s.files = Dir['lib/**/*.rb']
|
||||||
|
@ -26,6 +26,12 @@ module Facebooker2
|
|||||||
content_tag("fb:login-button",text,options.merge(:onlogin=>js))
|
content_tag("fb:login-button",text,options.merge(:onlogin=>js))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fb_login(options = {},&proc)
|
||||||
|
js = capture(&proc)
|
||||||
|
text = options.delete(:text)
|
||||||
|
concat(content_tag("fb:login-button",text,options.merge(:onlogin=>js)))
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Logs the user out of facebook and redirects to the given URL
|
# Logs the user out of facebook and redirects to the given URL
|
||||||
# args are passed to the call to link_to_function
|
# args are passed to the call to link_to_function
|
||||||
|
@ -2,13 +2,13 @@ module Facebooker2
|
|||||||
module Rails
|
module Rails
|
||||||
module Helpers
|
module Helpers
|
||||||
module Javascript
|
module Javascript
|
||||||
def fb_connect_async_js(app_id=Facebooker2.app_id,options={})
|
def fb_connect_async_js(app_id=Facebooker2.app_id,options={},&proc)
|
||||||
opts = Hash.new(true).merge!(options)
|
opts = Hash.new(true).merge!(options)
|
||||||
cookie = opts[:cookie]
|
cookie = opts[:cookie]
|
||||||
status = opts[:status]
|
status = opts[:status]
|
||||||
xfbml = opts[:xfbml]
|
xfbml = opts[:xfbml]
|
||||||
|
extra_js = capture(&proc) if block_given?
|
||||||
js = <<-JAVASCRIPT
|
js = <<-JAVASCRIPT
|
||||||
<div id="fb-root"></div>
|
|
||||||
<script>
|
<script>
|
||||||
window.fbAsyncInit = function() {
|
window.fbAsyncInit = function() {
|
||||||
FB.init({
|
FB.init({
|
||||||
@ -17,16 +17,21 @@ module Facebooker2
|
|||||||
cookie : #{cookie}, // enable cookies to allow the server to access the session
|
cookie : #{cookie}, // enable cookies to allow the server to access the session
|
||||||
xfbml : #{xfbml} // parse XFBML
|
xfbml : #{xfbml} // parse XFBML
|
||||||
});
|
});
|
||||||
|
#{extra_js}
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
ar s = document.createElement('div');
|
||||||
|
s.setAttribute('id','fb-root');
|
||||||
|
document.documentElement.getElementsByTagName("HEAD")[0].appendChild(s);
|
||||||
var e = document.createElement('script');
|
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/en_US/all.js';
|
||||||
e.async = true;
|
e.async = true;
|
||||||
document.getElementById('fb-root').appendChild(e);
|
s.appendChild(e);
|
||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
JAVASCRIPT
|
JAVASCRIPT
|
||||||
|
block_given? ? concat(js) : js
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user