Sha256: bd941330df9b823d57547536bf052d8d63c67e0dad58caf467b5fe927263ed3b

Contents?: true

Size: 731 Bytes

Versions: 9

Compression:

Stored size: 731 Bytes

Contents

class @Tags

  constructor: (element, options={}) ->
    @el = $(element)
    @tags = []

    @options =
      placeholder: 'Enter tags'
      multiple: true
      tokenSeparators: [","]
      tags: () =>
        query = @el.select2('container').find('input.select2-input').val()
        @search(query)
    @options = $.extend {}, @options, options

    @el.select2(@options)

  search: (query='') ->
    if query?
      $.ajax(
        type: 'GET'
        url: '/admin/api/tags/search'
        data: {q: query}
        async: false
        success: (data) =>
          @tags = $.map(data.results, (e) => e.text)
      )
    @tags


$.fn.taggable = ->
  @each ->
    new Tags(this)

jQuery ->
  $('input.js-token-input').taggable()

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
georgia-0.7.8 app/assets/javascripts/georgia/components/tags.js.coffee
georgia-0.7.7 app/assets/javascripts/georgia/components/tags.js.coffee
georgia-0.7.6 app/assets/javascripts/georgia/components/tags.js.coffee
georgia-0.7.5 app/assets/javascripts/georgia/components/tags.js.coffee
georgia-0.7.4 app/assets/javascripts/georgia/components/tags.js.coffee
georgia-0.7.3 app/assets/javascripts/georgia/components/tags.js.coffee
georgia-0.7.2 app/assets/javascripts/georgia/components/tags.js.coffee
georgia-0.7.1 app/assets/javascripts/georgia/components/tags.js.coffee
georgia-0.7.0 app/assets/javascripts/georgia/components/tags.js.coffee