Sha256: ab306a7f000f1417a4eb0d3dcff1c970e5bfdb8dc3850285c554d29a0e68445d

Contents?: true

Size: 1022 Bytes

Versions: 6

Compression:

Stored size: 1022 Bytes

Contents

opts =
  select:
    plugins:      ['remove_button']
    hideSelected: false

  tag_list:
    plugins:  ['remove_button', 'drag_drop']
    create:   true
    persist:  false

  relation:
    plugins:      ['remove_button']
    hideSelected: false
    onInitialize: ->
      sel     = this
      options = sel.$input.data('options')
      items   = sel.$input.data('items')
      $.each options, -> sel.addOption this
      if $.isArray items
        $.each items, -> sel.addItem this
      else
        sel.addItem items
    render: 
      option: (item, esc) ->
        pre = if item.depth > 0 then '- '.repeat(item.depth) else ''
        """<div class="option">#{ pre }#{ esc item.text }</div>"""


@app.directive 'selectize', ->
  ($scope, $el, $attrs) ->
    switch $attrs['selectize']
      when 'select'                       then $($el).selectize opts.select
      when 'tag_list'                     then $($el).selectize opts.tag_list
      when 'relation', 'node', 'taxonomy' then $($el).selectize opts.relation

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
push_type_admin-0.7.0 app/assets/javascripts/push_type/fields/select_fields.js.coffee
push_type_admin-0.7.0.beta.1 app/assets/javascripts/push_type/fields/select_fields.js.coffee
push_type_admin-0.6.0 app/assets/javascripts/push_type/fields/select_fields.js.coffee
push_type_admin-0.6.0.beta.4 app/assets/javascripts/push_type/fields/select_fields.js.coffee
push_type_admin-0.6.0.beta.3 app/assets/javascripts/push_type/fields/select_fields.js.coffee
push_type_admin-0.6.0.beta.2 app/assets/javascripts/push_type/fields/select_fields.js.coffee