Sha256: f0864b89cd8cdda3e63d43c72b9efdd34dc1d87762f6c93a3bcd92af1a117194

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

# -----------------------------------------------------------------------------
# LIST SEARCH
# -----------------------------------------------------------------------------

@listSearch =

  # PRIVATE ===============================================

  _bind_search: ->
    @$search       =$ "<div class='search'></div>"
    @$searchIcon   =$ "<a href='#' class='icon'></a>"
    @$searchInput  =$ "<input type='text' placeholder='Search...' />"
    @$searchCancel =$ "<a href='#' class='cancel'>Cancel</a>"

    @$header.append(@$search)
    @$search.append(@$searchIcon)
    @$search.append(@$searchInput)
    @$search.append(@$searchCancel)

    @$searchInput.on 'keyup', (e) =>
      if e.keyCode == 27 # esc
        return @_on_search_cancel()

      if e.keyCode == 13 # enter
        return @_on_search()

    @$searchIcon.on   'click', (e) => e.preventDefault() ; @_on_search_show()
    @$searchCancel.on 'click', (e) => e.preventDefault() ; @_on_search_cancel()


  # EVENTS ================================================

  _on_search: ->
    query = @$searchInput.val()
    @showSpinner()
    @config.arrayStore.search(query)


  _on_search_show: ->
    @$el.addClass('list-search')
    @$searchInput.focus()
    @$search.show()


  _on_search_cancel: ->
    @$el.removeClass('list-search')
    @$searchInput.val('')
    @showSpinner()
    @config.arrayStore.reset()




Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chr-0.3.5 app/assets/javascripts/chr/core/list_search.coffee