Sha256: d4a138cd264330c2ae1008fb419dfc4a421b4f308a3478aaf72f12adfb00844b

Contents?: true

Size: 1.23 KB

Versions: 26

Compression:

Stored size: 1.23 KB

Contents

'use strict'

define

  type: 'Base'

  version: '0.1.2'

  initialize: (options) ->
    {identifier} = options
    @names = []

    # TODO access omit method throuhgh sandbox
    widget_options =  _.omit options, 'el', 'ref', '_ref', 'name', 'require', 'baseUrl', 'resource'

    # TODO remove jquery dependency
    injections = @prepare_injections widget_options

    @$el.addClass ['tray', 'widget'].concat(@names).join(' ')

    @identifier ||= identifier

    # TODO find a way to build the id based on content
    if identifier?
      @identifier = identifier
      @$el.attr 'id', identifier

    # TODO get defer through sandbox
    _.defer =>
      @sandbox.start injections

  prepare_injections: (widget_options) ->
    # TODO remove jquery dependency, and use type detection through sandbox
    for name, suboptions of widget_options when $.type(suboptions) is "object"
      @names.push suboptions.name || name

      # TODO do not allow elements outside of the tray
      # TODO remove jquery dependency, and use documentFragment to build widgets
      # TODO allow widgets without elements
      @$el.append suboptions.el = jQuery '<div class="widget"></div>'

      @injection
        name: suboptions.name || name
        options: suboptions

Version data entries

26 entries across 26 versions & 1 rubygems

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