Sha256: 52b680ade90c3bc01ca915b17b328cd2ce08dedd586abd29adb4e9582cef38f1

Contents?: true

Size: 877 Bytes

Versions: 5

Compression:

Stored size: 877 Bytes

Contents

class PostShow
  constructor: ->
    @convert_videos_to_responsive()
    @track()

  convert_videos_to_responsive: =>
    self = this

    $(".post-body iframe").each ->
      $iframe = $(this)

      if self.is_video_embed_url($iframe.attr('src'))
        $wrapper = $("<div class='embed-responsive embed-responsive-16by9 video-embed-wrap'></div>")
        $iframe.removeAttr("width").removeAttr("height").addClass("embed-responsive-item video-embed")
        $iframe.wrap($wrapper)



  is_video_embed_url: (url) =>
    url_parts = url.match(/https?:\/\/(:?www.)?(\w*)/)

    if url_parts >= 3
      provider = url_parts

      if provider == 'youtube' or provider == 'vimeo' or provider == 'player' or provider == 'youtu.be'
        return true

    false

  track: =>
    setTimeout ->
      $.get $(".post").attr("data-tracking-uri")
    , 500

window.PostShow = PostShow

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
virgo-0.3.14 app/assets/javascripts/virgo/posts/show.coffee
virgo-0.3.13 app/assets/javascripts/virgo/posts/show.coffee
virgo-0.3.12 app/assets/javascripts/virgo/posts/show.coffee
virgo-0.3.11 app/assets/javascripts/virgo/posts/show.coffee
virgo-0.3.10 app/assets/javascripts/virgo/posts/show.coffee