Sha256: 59be4507ce81817265622165f92994f6ca9d3692d69ec27287549e0ba215962a

Contents?: true

Size: 1.1 KB

Versions: 7

Compression:

Stored size: 1.1 KB

Contents

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

    # We have to figure out the template dynamically.
    @Template = null

    @QueryDefaults =
        maxwidth  : 620
        maxheight : 550
        format    : 'json'

    @Matchers = [
        new RegExp /https?:\/\/([^\/]+)\/([^\/]+)\/([^\/]+)\/?/i
    ]


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

        domain  = match[1]
        type    = match[2]
        id      = match[3]

        template = @_findTemplate(type)

        oldDocumentWrite = document.write
        document.write = (html) => @wrapper.append(html)

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

        setTimeout ->
            document.write = oldDocumentWrite
        , 500

    _findTemplate: (type) ->
        template = switch type
            when 's' then 'polldaddy_survey'
            when 'poll', 'p' then 'polldaddy_poll'

        Embeditor.Template(template)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
embeditor-rails-2.2.0 app/assets/javascripts/embeditor/adapters/polldaddy.js.coffee
embeditor-rails-2.0.1 app/assets/javascripts/embeditor/adapters/polldaddy.js.coffee
embeditor-rails-2.0.0 app/assets/javascripts/embeditor/adapters/polldaddy.js.coffee
embeditor-rails-2.0.0.beta app/assets/javascripts/embeditor/adapters/polldaddy.js.coffee
embeditor-rails-1.1.1 app/assets/javascripts/embeditor/adapters/polldaddy.js.coffee
embeditor-rails-1.1.0 app/assets/javascripts/embeditor/adapters/polldaddy.js.coffee
embeditor-rails-1.0.1 app/assets/javascripts/embeditor/adapters/polldaddy.js.coffee