Skip to content

Instantly share code, notes, and snippets.

@ifthenelse
Last active December 22, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifthenelse/6410700 to your computer and use it in GitHub Desktop.
Save ifthenelse/6410700 to your computer and use it in GitHub Desktop.
Facebook autogrowth code for Facebook Tabs.
<div id="fb-root"></div>
<script type="text/javascript">
var goTo = true;
function goToLogIn() {
if (goTo) {
self.location = "{{ path('facebook_security_check') }}";
}
}
window.fbAsyncInit = function() {
FB.init({
appId: '{{ facebook_app_id }}',
cookie: true,
xfbml: true,
oauth: true,
status: false
});
FB.Event.subscribe('auth.statusChange', function(response) {
setTimeout(goToLogIn, 500);
});
// FB.Canvas.setAutoGrow(true);
if($('.in_fb').size()){
var _fb_auto = {};
_fb_auto.body = $('body');
_fb_auto.wr = $('.main_centered_wr');
_fb_auto.offset = 0;
_fb_auto.mt = 0;
setInterval(function(){
// _fb_auto.body.height(_fb_auto.body.height() + _fb_auto.bg_offset);
FB.Canvas.setSize({ width: 810, height: (_fb_auto.body.height() + _fb_auto.offset - _fb_auto.mt) });
},500);
}
};
(function() {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment