Sha256: 17490cdee6f6334875df3101f1b22037fdd88f572e4a38835a4376808af6d0be

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

class IuguUI.SearchFilter extends IuguUI.Base

  layout: "iugu-ui-search-filter"

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

  events:
    'click [data-action=search-filter-button]': 'searchCollection'

  searchCollection: (e) ->
    e.preventDefault()
    @handleEvent "facet:click" 
    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.goTo(1)

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

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

  render: ->
    super

  removedFilter: ->
    @selected = []

@IuguUI.SearchFilter = IuguUI.SearchFilter

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
iugu-ux-0.9.5 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee
iugu-ux-0.9.4 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee
iugu-ux-0.9.3 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee
iugu-ux-0.9.2 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee
iugu-ux-0.9.1 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee
iugu-ux-0.9.0 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee
iugu-ux-0.8.9 vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee