Giter Club home page Giter Club logo

fbready's Introduction

FBReady

Prepare all stuffs for using Facebook JavaScript SDK

Features

  • Append "fb-root" element (if not exists)
  • Append Facebook JavaScript SDK resource (if not exists)
  • on() let you attach callback for "ready", "login" event
  • render() will parse XFBML (ex: Like Button) without asynchronous context

Usage

Firstly, get your application id on https://developers.facebook.com/, then initialize FBReady with the appId.

var fbready = new FBReady( your_application_id );

You don't need to install "fb-root" or script code to import SDK.

"ready" Event

Attach callback for "ready" event. This will be called when anything about connection is done.

fbready.on("ready", function(){
	console.log("Connected to Facebook !");
});

"login" Event

To do something with authenticated context, "login" event is usable.

fbready.on("login", function(){
	console.log("Logged in !");
	FB.api(...);
});

FBReady doesn't have any interface to login. Call FB.login() on your own context.

Show Facebook Widget

Use render to show XFBML widget such as "Like Button".

fbready.render();

No need to call it in callback. render() just registers callback and waits for preparing application.

Confliction

  • If FB object exists, FBReady try to use the FB and doesn't install new "all.js".

  • If FB.init() has been already called, that looks like working but not good.
    You will see a message like "FB.init has already been called".
    It may be caused by installing code for widgets such as "Like Button"
    because they call automatically FB.init.

  • In context of callback for FB.getLoginStatus(), FBReady does not work.

API

Events

  • ready : Connection process is done
  • login : Logged in

Methods

on(name:String, callback:Function)

Register callback for the named event.

fire(name:String)

Fire the named event.

render()

Render facebook widgets on the page.
This call FB.XFBML.parse()

Author

mach3

fbready's People

Contributors

mach3 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.