Sha256: 4176c3d625fdae5042a2937f35c55bb30adf3da18be8c3547686b712ab6ff5a4

Contents?: true

Size: 1.29 KB

Versions: 48

Compression:

Stored size: 1.29 KB

Contents

'use strict';

lazy_require = 'observable'
define ['stampit/stampit', lazy_require], (stampit, observable) ->

  handlers =
    adapter_loaded: (composable) ->
      builder  = stampit.compose(adaptable, composable)
      @adapter = builder options: @options.adapter

      handlers.adapter_initialized.call @

    # Event handlers and state restoring
    adapter_initialized: ->

      if @sandbox.signed_in
        @adapter.user = @sandbox.current_user
      else
        @sandbox.once 'user.signed_in', handlers.user_signed_in, @

      @sandbox.on 'support.default.focus', @focus, @


    user_signed_in: (user) -> @adapter.user = @sandbox.current_user

  adaptable = stampit().methods(
    focus: -> throw new Error "Not implemented by this interface."
  ).enclose -> observable @

  type: 'Base'

  focus: -> @adapter.focus()

  initialize: (options) ->

    unless @options.adapter?
      throw new TypeError "No adapter specified for support widget '#{@identifier}'."

    @options.adapter = @sandbox.util.extend @options.adapter,
      name : options.adapterName
      token: options.adapterToken

    require ["widgets/support/adapters/#{options.adapter.name}"], (composable) => handlers.adapter_loaded.call @, composable

    # TODO implement a type of widget that does not require element
    @$el.remove();


Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
ende-0.5.22 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.21 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.20 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.19 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.18 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.17 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.16 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.15 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.14 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.13 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.12 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.10 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.9 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.8 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.7 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.6 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.4.25 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.5 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.4 lib/assets/javascripts/widgets/support/main.js.coffee
ende-0.5.3 lib/assets/javascripts/widgets/support/main.js.coffee