Created
April 23, 2012 20:09
-
-
Save adammiller/2473487 to your computer and use it in GitHub Desktop.
FB init example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define( 'healthy', | |
['underscore', 'healthy/intro', 'healthy/quiz', 'healthy/results'], | |
function( _, intro, quiz, results ) { | |
var Healthy = { | |
'publicFn': { | |
'init': function( bodyClass ) { | |
Healthy.privateFn.setup( bodyClass ); | |
Healthy.privateFn.onFacebookInit( function() { | |
$( window ).trigger( 'FBInit' ); | |
} ); | |
} | |
}, | |
'privateFn': { | |
'setup': function( bodyClass ) { | |
var elem = document.createElement('canvas'), | |
canvasSupported = !!(elem.getContext && elem.getContext('2d')); | |
// FOR TESTING | |
// canvasSupported = false; | |
// ghetto setup code activate! | |
if ( bodyClass.match( 'intro' ) ) { | |
intro.init( { 'canvasSupported': canvasSupported } ); | |
} else if ( bodyClass.match( 'quiz' ) ) { | |
quiz.init( { 'canvasSupported': canvasSupported } ); | |
} else if ( bodyClass.match( 'results' ) ) { | |
results.init( { 'canvasSupported': canvasSupported } ); | |
} | |
}, | |
'onFacebookInit': function( callback ) { | |
if ( !( 'FB' in window ) || !FB.apiDidInit ) { | |
setTimeout( function() { Healthy.privateFn.onFacebookInit( callback ); }, 50 ); | |
} else { | |
if( callback ) callback(); | |
} | |
} | |
} | |
}; | |
return Healthy.publicFn; | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript" charset="utf-8"></script> | |
<div id="fb-root"></div> | |
<script type="text/javascript"> | |
(function(d){ | |
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} | |
js = d.createElement('script'); js.id = id; js.async = true; | |
js.src = "//connect.facebook.net/en_US/all.js"; | |
d.getElementsByTagName('head')[0].appendChild(js); | |
}(document)); | |
window.fbAsyncInit = function() { | |
FB.init( { | |
appId : '147102975395246', // App ID | |
channelUrl : '//healthiestyou.barbariangroup.com/channel.html', // Channel File | |
status : true, // check login status | |
cookie : true, // enable cookies to allow the server to access the session | |
oauth : true, // enable OAuth 2.0 | |
xfbml : true // parse XFBML | |
} ); | |
FB.apiDidInit = true; | |
} | |
</script> | |
<script src="js/bin/healthy_you.js" type="text/javascript" charset="utf-8"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment