Sha256: b055d5df33a67cbf51c1edda40884caf50115946de3f6e73bb0199dc7b7d50db
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
module FacebookSocialPlugins module ScriptHelper # app_id - facebook app id, a number/string, fx '753632322' # domain - fx www.example.com # options - status, cookie, xfbml (true|false) # - :channel => 'channel.html' def async_init_script app_id, domain, options = {} %Q{ window.fbAsyncInit = function() { FB.init({ appId : '#{app_id}', // App ID channelUrl : '//#{domain}/#{options[:channel] || 'assets/facebook_channel'}.html', // Channel File status : #{options[:status] || true}, // check login status cookie : #{options[:cookie] || true}, // enable cookies to allow the server to access the session xfbml : #{options[:xfbml] || true } // parse XFBML }); // Additional initialization code here }; } end def facebook_script locale = :en_US %Q{ (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "#{all_script locale}"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); } end protected # The JavaScript SDK is available in all locales that are supported by Facebook. # This list of supported locales is available as an XML file. # To change the locale of the SDK to match the locale of your site, change en_US to a # supported locale code when loading the SDK. # For example, if your site is in Spanish use es_LA def all_script locale = :en_US "//connect.facebook.net/#{locale}/all.js" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
facebook-social_plugins-0.1.1 | lib/facebook-social_plugins/script_helper.rb |
facebook-social_plugins-0.1.0 | lib/facebook-social_plugins/script_helper.rb |