Skip to content

Instantly share code, notes, and snippets.

@brijeshb42
Last active February 19, 2017 12:41
Show Gist options
  • Save brijeshb42/c4f10775eceac9c1c1de959193105d50 to your computer and use it in GitHub Desktop.
Save brijeshb42/c4f10775eceac9c1c1de959193105d50 to your computer and use it in GitHub Desktop.
<figure
data-embed-type="facebook"
data-embed-url="https://www.facebook.com/scroll.in/videos/1289835134432697/"
data-embed-loaded="false">
<div
class="fb-video"
data-href="https://www.facebook.com/scroll.in/videos/1289835134432697/"
data-allowfullscreen="true"
data-width="auto">
</div>
</figure>
window.fbAsyncInit = function () {
window.FB.init({
appId: 'YOUR_APP_ID',
version: 'v2.x',
xfbml: true
});
window.FB.XFBML.parse();
};
export function facebook ($node) {
var $div = $node.find('div');
if ($(window).width() > 400) {
$div.attr('data-width', parseInt($node.parent().width(), 10));
} else {
$div.attr('data-width', 'auto');
}
if (typeof window.FB !== 'undefined' && window.FB.XFBML) {
window.FB.XFBML.parse($div[0]);
} else {
var fbroot = document.getElementById('fb-root');
if (fbroot === null) {
fbroot = document.createElement('div');
fbroot.id = 'fb-root';
document.getElementsByTagName('body')[0].appendChild(fbroot);
$.getScript('https://connect.facebook.net/en_US/sdk.js');
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment