Sha256: a3cbf0c6b1a117a9e6237451111e10a56ceed62ef343923fccb09861c33a80b1

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

class Embeditor.Adapters.YouTube extends Embeditor.Adapters.StaticTemplate
    className: "YouTube"

    @VideoTemplate    = Embeditor.Template('youtube')
    @PlaylistTemplate = Embeditor.Template('youtube_playlist')

    @QueryDefaults =
        maxwidth  : 560
        maxheight : 315

    @Matchers = [
        /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/i,
        /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?list=|(embed|v)\/))([^\?&"'>]+)/i
    ]

    swap: ->
        match = @_parseUrl()
        return false if not match

        id  = match[5]

        template = if id.length > 11 then YouTube.PlaylistTemplate else YouTube.VideoTemplate

        @embed template
            maxheight   : @queryParams.maxheight
            maxwidth    : @queryParams.maxwidth
            id          : id

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
embeditor-rails-2.2.0 app/assets/javascripts/embeditor/adapters/youtube.js.coffee