Sha256: 9b4539902526dd2f98a3cc899b207eae7febbd302501ce40b0120ada0efef9cc

Contents?: true

Size: 1.15 KB

Versions: 55

Compression:

Stored size: 1.15 KB

Contents

class Tenon.features.QuickSearch
  constructor: ->
    @$content = $('.toolbox #quick-search-container')
    @$toggle = $('#quick-search-toggle')
    @openClass = 'open'
    @$field = $('#quick-search')

    # listeners
    $(document).on('keyup', '#quick-search', $.debounce(500, @_submitSearch))

    @$toggle.on('click', @toggleNav)
    # $(document).on('click', '.nav-holder.mobile-open a', @_closeNav)

  _submitSearch: (e) =>
    @$list = $(@$field.data('record-list'))
    params = {q: @$field.val()}
    new Tenon.features.RecordList(@$list, params: params, clear: true)

  toggleNav: (e) =>
    e.preventDefault()
    @$toggle.find('i').toggleClass('fa-search fa-times')
    if @$toggle.hasClass(@openClass)
      @_closeNav()
    else
      @_openNav()

  _closeNav: () =>
    @$field.val('').keyup() # clear quick search and submit it when closing the toolbox
    @$toggle.removeClass(@openClass)
    $('header').css('border-bottom-width', '1px')
    @$content.removeClass(@openClass)

  _openNav: () =>
    @$toggle.addClass(@openClass)
    $('header').css('border-bottom-width', '0px')
    @$content.addClass(@openClass)
    @$content.find('input')[0].focus()

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
tenon-1.0.55 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.54 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.53 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.52 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.51 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.50 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.49 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.48 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.47 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.46 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.45 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.44 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.43 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.42 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.41 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.40 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.39 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.38 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.37 app/assets/javascripts/tenon/features/quick_search.js.coffee
tenon-1.0.36 app/assets/javascripts/tenon/features/quick_search.js.coffee