 _ = require 'underscore'
 _s = require 'underscore.string'
 Backbone = require 'backbone'
+request = require 'superagent'
 sd = require('sharify').data
 Search = require './collections/search.coffee'
 mediator = require '../../lib/mediator.coffee'

  indicateLoading: ->
    @renderFeedback()
    @$el.addClass 'is-loading'

  concealLoading: ->
    @$el.removeClass 'is-loading'

    @search = new Search restrictType: @restrictType, mode: @mode, fairId: @fairId, size: @limit, agg: @enableAggregations

    @on 'search:start', @indicateLoading
    @on 'search:start', @recordPerformanceMeasurementStart if @shouldMeasurePerformance()
    @on 'search:complete', @concealLoading
    @on 'search:complete', @maybeHighlight
    @on 'search:complete', @displayFeedback
    @on 'search:complete', @reportPerformanceMeasurement if @shouldMeasurePerformance()
    @on 'search:opened', @displaySuggestions
    @on 'search:closed', @hideSuggestions
    @on 'search:cursorchanged', @ensureResult
