Sha256: b4894ceb14b372458877fb5e9f90e65a18c4545ed11ecc695e35bb037d528ae8

Contents?: true

Size: 1018 Bytes

Versions: 9

Compression:

Stored size: 1018 Bytes

Contents

decko.slot.ready (slot) ->
  slot.find('._autocomplete').each (_i) ->
    decko.initAutoCardPlete($(this))

  slot.find('._select2autocomplete').each (_i) ->
    decko.select2Autocomplete.init $(this)

decko.initAutoCardPlete = (input) ->
  optionsCard = input.data 'options-card'
  return unless !!optionsCard
  path = optionsCard + '.json?view=name_match'
  input.autocomplete { source: decko.slot.path(path) }

decko.select2Autocomplete =
  init: (el, options, ajaxOptions) ->
    opts = $.extend {}, @_defaults(el), options
    $.extend opts.ajax, ajaxOptions if ajaxOptions
    el.select2 opts

  _defaults: (el)->
    multiple: false
    width: "100%!important"
    minimumInputLength: 0
    maximumSelectionSize: 1

    placeholder: el.attr("placeholder")
    escapeMarkup: (markup) -> markup

    ajax:
      delay: 200
      cache: true
      url: decko.path ':search.json'
      processResults: (data) -> results: data
      data: (params) ->
        query: { keyword: params.term }
        view: "complete"

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
card-mod-search-0.16.0 assets/script/autocomplete.js.coffee
card-mod-search-0.15.6 assets/script/autocomplete.js.coffee
card-mod-search-0.15.5 assets/script/autocomplete.js.coffee
card-mod-search-0.15.4 assets/script/autocomplete.js.coffee
card-mod-search-0.15.3 assets/script/autocomplete.js.coffee
card-mod-search-0.15.2.pre1 assets/script/autocomplete.js.coffee
card-mod-search-0.15.1.1 assets/script/autocomplete.js.coffee
card-mod-search-0.15.1 assets/script/autocomplete.js.coffee
card-mod-search-0.15.0 assets/script/autocomplete.js.coffee