[Facebooker-talk] Facebook javascript (FBJS) library

George Deglin george at xapblog.com
Tue Aug 19 21:57:18 EDT 2008


I wrote an fbjs library to help speed up development of some of my
applications. I plan to have some sort of "official" release with a blog
entry and github repository at some point, but I thought you guys might want
to have it earlier.

It's still a work in progress. I've been using every method at least once in
my application but it's still possible there is a bug or two I missed. Let
me know if you find any bugs.


Javascript (stand alone)
http://pastie.org/256150

Rails Helpers:
http://pastie.org/256153


Examples of use:
    Select Element
    $('noelement');

    Select 2 Elements
    $('test1','test2');

    Select elements by class
    getElementsByClass('test2c')

    Select elements by tag
    getElementsByTagName('strike')

    Use Javascript version of .map
    ['a2','b2'].toSource() == map(['a','b'], function(val) { return val+2
}).toSource()

    Recurse through the dom under a selected element and return nodes for
which test is true as an array
    collect($('test1'), function(element){ return (element.getClassName() ==
'test2c') })

    Check if an element is visible
    $('test1').visible()

    Hide an element
    $('test1').hide()

    Show an element
    $('test1').show()

    Toggle element visibility
    $('test1').toggle();

    Remove an element from the dom
    $('test1').remove();

    Get a hash of calculated element dimensions width/height as integers
    $('test1').getDimensions()

    Update remote
    Update: function(target_element, response_type, action_path, callbacks,
post_parameters)
    (FBML/RAW)
    Ajax.Update('test1', 'FBML', 'http://...',{ success: function(){} })

    Load Remote
    Load: function(response_type, action_path, callbacks, post_parameters)
    (FBML/RAW/JSON)
    Ajax.Load('JSON','http://...',{ success:
function(result){console.log(result)} }, {'json':test_content})

    Remote Form
    <%= fbjs_form_remote_tag :update => 'a', :html => { :action => '
http://inigral.ath.cx:3003/javascript_test/test_helpers_res' }, :response =>
'RAW' %>
        <input type="hidden" name="test_hidden" value="test value"/>
        <input type="checkbox" name="test_box" checked="true"/>
        <input name="test_input"/>
        <input type="submit" value="submit"/>
    </form>
    <div id="a"/>

    In place Edit
    Will post: {txt_field_name:'Text inside editable field'}
    <%= fbjs_in_place_editor_text_div('txt_field_name', 'Text inside
editable field', 'http://...', { :class => 'test' }) %>
    <a href="#" onclick="txt_field_name_editor.edit()">edit</a>
    <a href="#" onclick="txt_field_name_editor.save()">save</a>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/facebooker-talk/attachments/20080819/9fa644c0/attachment-0001.html>


More information about the Facebooker-talk mailing list