Skip to content

Instantly share code, notes, and snippets.

@excid3
Created January 3, 2015 16:34
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 excid3/0abf8c533f5e350436cf to your computer and use it in GitHub Desktop.
Save excid3/0abf8c533f5e350436cf to your computer and use it in GitHub Desktop.
wistia oembed
class WistiaEmbed
constructor: (original_tag) ->
@base_url = "//fast.wistia.com/oembed/?url="
@account_url = encodeURIComponent("https://home.wistia.com/medias/")
@original_tag = original_tag
@media_id = original_tag.data("wistia-id")
inject: ->
$.getJSON("#{@base_url}#{@account_url}#{@media_id}&format=json&embedType=seo&videoFoam=true&controlsVisibleOnLoad&callback=?", @parse)
parse: (data) =>
@original_tag.html "<div class='video-wrapper'>#{data.html}</div>"
jQuery ->
$('[data-wistia-id]').each ->
embed = new WistiaEmbed($(this))
embed.inject()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment