facebook_url_helper.rb

Path: lib/facebooker/rails/facebook_url_helper.rb
Last Update: Tue May 05 12:50:29 -0400 2009

Extends the ActionView::Helpers::UrlHelper module. See it for details on the usual url helper methods: url_for, link_to, button_to, etc.

Mostly, the changes sanitize javascript into facebook javascript. It sanitizes link_to solely by altering the private methods: convert_options_to_javascript!, confirm_javascript_function, and method_javascript_function. For button_to, it alters button_to itself, as well as confirm_javascript_function. No other methods need to be changed because of Facebook javascript.

For button_to and link_to, adds alternate confirm options for facebook.

Options

  • :confirm => ‘question?‘ - This will add a JavaScript confirm prompt with the question specified.

    Example:

      # Generates: <a href="http://rubyforge.org/projects/facebooker" onclick="
      #                 var dlg = new Dialog().showChoice('Please Confirm', 'Go to Facebooker?').setStyle();
      #                 var a=this;dlg.onconfirm = function() {
      #                   document.setLocation(a.getHref());
      #                 }; return false;">Facebooker</a>
      link_to("Facebooker", "http://rubyforge.org/projects/facebooker", :confirm=>"Go to Facebooker?")
    

    Alternatively, options[:confirm] may be specified. See the Facebook page wiki.developers.facebook.com/index.php/FBJS. These options are:

    :title:Specifies the title of the Facebook dialog. Default is "Please Confirm".
    :content:Specifies the title of the Facebook dialog. Default is "Are you sure?".

    Example:

      # Generates: <a href="http://rubyforge.org/projects/facebooker" onclick="
      #                 var dlg = new Dialog().showChoice('the page says:', 'Go to Facebooker?').setStyle();
      #                 var a=this;dlg.onconfirm = function() {
      #                   document.setLocation(a.getHref());
      #                 }; return false;">Facebooker</a>
      link_to("Facebooker", "http://rubyforge.org/projects/facebooker", :confirm=>{:title=>"the page says:", :content=>"Go to Facebooker?"})
    

    Any other options passed are assumed to be css styles. Again, see the Facebook page wiki.developers.facebook.com/index.php/FBJS.

    Example:

      # Generates: <a href="http://rubyforge.org/projects/facebooker" onclick="
      #                 var dlg = new Dialog().showChoice('the page says:', 'Are you sure?').setStyle({color: 'pink', width: '200px'});
      #                 var a=this;dlg.onconfirm = function() {
      #                   document.setLocation(a.getHref());
      #                 }; return false;">Facebooker</a>
      link_to("Facebooker", "http://rubyforge.org/projects/facebooker", :confirm=>{:title=>"the page says:, :color=>"pink", :width=>"200px"})
    

[Validate]