Sha256: c6ce735e1bb401a0f77a1b40781c443a73b7903de351a1a820b67a06296ff8ae

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

class IuguUI.SearchFilter extends IuguUI.Base

  layout: "iugu-ui-search-filter"

  defaults:
    filterName: "age"
    fixedFilters: []
    multiSelection: false

  events:
    'click .search-filter-button': 'searchCollection'

  searchCollection: (e) ->
    e.preventDefault()
    button = $(e.target)
    filter = button.data('filter')

    unless @options.multiSelection
      @selected = []

    unless _.indexOf(@selected, filter.toString()) == -1
      @selected = _.without(@selected, filter.toString())
    else
      @selected.push(filter.toString())

    if @selected.length > 0
      @collection.configureFilter @options.filterName + '_filter', @selected
    else
      @collection.removeFilter @options.filterName + '_filter'

    @collection.fetch()

  initialize: ->
    @selected = []
    _.bindAll @, 'searchCollection', 'render'
    @collection.on 'all', @render, @
    @collection.on "removed-filter:#{@options.filterName}_filter", @removedFilter, @
    super
    @

  context: ->
    collection: @collection
    selected: @selected
    filterName: @options.filterName
    fixedFilters: @options.fixedFilters

  render: ->
    if @collection.facets
      super

  removedFilter: ->
    @selected = []

@IuguUI.SearchFilter = IuguUI.SearchFilter

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iugu-ux-0.8.8 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee
iugu-ux-0.8.7 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee
iugu-ux-0.8.6 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee
iugu-ux-0.8.5 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee