Skip to content

Instantly share code, notes, and snippets.

@brijeshb42
Last active February 19, 2017 19:20
Show Gist options
  • Save brijeshb42/a8ee12f59844eeee930cb98761e89107 to your computer and use it in GitHub Desktop.
Save brijeshb42/a8ee12f59844eeee930cb98761e89107 to your computer and use it in GitHub Desktop.
// declare functions for all the different types of embeds as shown previously
const Types = {
youtube,
vimeo,
vine,
twitter,
facebook,
instagram,
iframe
};
export const load = (node = document) => {
const $nodes = $(node).find('[data-embed-loaded=false]');
$nodes.each(function () {
const $this = $(this);
const type = $this.data('embed-type');
if (Types.hasOwnProperty(type)) {
Types[type]($this);
}
$this.attr(loadedAttr, 'true');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment