aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/vomnibar.coffee
blob: 0d5197a56e1c1ac3212476ed7def61bc0842994a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
# This wraps the vomnibar iframe, which we inject into the page to provide the vomnibar.
#
Vomnibar =
  vomnibarUI: null

  activate: -> @open {completer:"omni"}
  activateInNewTab: -> @open {
    completer: "omni"
    selectFirst: false
    newTab: true
  }
  activateTabSelection: -> @open {
    completer: "tabs"
    selectFirst: true
  }
  activateBookmarks: -> @open {
    completer: "bookmarks"
    selectFirst: true
  }
  activateBookmarksInNewTab: -> @open {
    completer: "bookmarks"
    selectFirst: true
    newTab: true
  }
  activateEditUrl: -> @open {
    completer: "omni"
    selectFirst: false
    query: window.location.href
  }
  activateEditUrlInNewTab: -> @open {
    completer: "omni"
    selectFirst: false
    query: window.location.href
    newTab: true
  }

  init: ->
    unless @vomnibarUI?
      @vomnibarUI = new UIComponent "pages/vomnibar.html", "vomnibarFrame", =>
        @vomnibarUI.hide()

  # This function opens the vomnibar. It accepts options, a map with the values:
  #   completer   - The completer to fetch results from.
  #   query       - Optional. Text to prefill the Vomnibar with.
  #   selectFirst - Optional, boolean. Whether to select the first entry.
  #   newTab      - Optional, boolean. Whether to open the result in a new tab.
  open: (options) -> @vomnibarUI.activate options

root = exports ? window
root.Vomnibar = Vomnibar