Sha256: d39a879be3e7b9f2528f5c0d9ac5cdbd3911ed74682e4965e3b77bb2245d7460

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

module AuthlogicFacebookConnect
  module Helper
    def authlogic_facebook_login_button(options = {})
      # TODO: Make this with correct helpers istead of this uggly hack.
      
      options[:controller] ||= "user_session"
      options[:js] ||= :prototype
      
      case options[:js]
      when :prototype
        js_selector = "$('connect_to_facebook_form')"
      when :jquery
        js_selector = "jQuery('#connect_to_facebook_form')"
      end
      
      output = "<form id='connect_to_facebook_form' method='post' action='/#{options[:controller]}'>\n"
      output << "<input type='hidden' name='authenticity_token' value='#{form_authenticity_token}'/>\n"
      output << "</form>\n"
      output << "<script type='text/javascript' charset='utf-8'>\n"
      output << " function connect_to_facebook() {\n"
      output << "   #{js_selector}.submit();\n"
      output << " }\n"
      output << "</script>\n"
      options.delete(:controller)
      output << fb_login_button("connect_to_facebook()", options)
      output
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
secobarbital-authlogic_facebook_connect-1.0.1 lib/authlogic_facebook_connect/helper.rb
secobarbital-authlogic_facebook_connect-1.0.0 lib/authlogic_facebook_connect/helper.rb
jerryvos-authlogic_facebook_connect-1.0.2 lib/authlogic_facebook_connect/helper.rb
jerryvos-authlogic_facebook_connect-1.0.0 lib/authlogic_facebook_connect/helper.rb