       result = @results[index]
       @result_callback.apply(null, [result])
 
-  cloneModal: (selector) ->
-    new_modal_id = "quickjump"+new Date().getTime()
-    new_modal = $(selector).clone()
-    new_modal.attr("id", new_modal_id)
-    $("body").append(new_modal)
-    "##{new_modal_id}"
-
   getActiveResult: ->
     if @active_result?
       all = $(@selector+" .result")

  requestComplete: (query, request) ->
    results = eval(request.responseText)
    this.setResults(query, results)

  renderResults: (query) ->
    out = ""
    index = 0
    phrases = query.replace(/^\s+|\s+$/g, '').split(' ')
    template = '<a class="result" data-result-index="%{index}" href="%{url}"><div class=title><i class="icon-%{type}"></i> <span>%{title}</span></div></a>'

    for result in @results[0...@MAX_RESULTS]
      t = this.highlight(result.title, phrases)
      out += template.toString().replace("%{title}", t).replace("%{type}", result.type).replace("%{url}", result.url).replace("%{index}", index)
      index += 1

    $(@selector+" .results").html(out)
    self = this
    $(@selector+" .results a.result").bind "click", (event) ->
      self.activateResult(this)
      event.preventDefault()
      false

  setOrRequestResults: (query) ->
    stored_results = @dictionary.getResultsFor(query)

  KEY_DOWN: 40
  KEY_ENTER: 13
  KEY_ESC: 27

  constructor: (@parent, @selector, @result_callback) ->
    @active_result = null
    self = this
