// Generated by CoffeeScript 1.9.1
(function() {
  var Vomnibar, root;

  Vomnibar = {
    vomnibarUI: null,
    activate: function(sourceFrameId) {
      return this.open(sourceFrameId, {
        completer: "omni"
      });
    },
    activateInNewTab: function(sourceFrameId) {
      return this.open(sourceFrameId, {
        completer: "omni",
        selectFirst: false,
        newTab: true
      });
    },
    activateTabSelection: function(sourceFrameId) {
      return this.open(sourceFrameId, {
        completer: "tabs",
        selectFirst: true
      });
    },
    activateBookmarks: function(sourceFrameId) {
      return this.open(sourceFrameId, {
        completer: "bookmarks",
        selectFirst: true
      });
    },
    activateBookmarksInNewTab: function(sourceFrameId) {
      return this.open(sourceFrameId, {
        completer: "bookmarks",
        selectFirst: true,
        newTab: true
      });
    },
    activateEditUrl: function(sourceFrameId) {
      return this.open(sourceFrameId, {
        completer: "omni",
        selectFirst: false,
        query: window.location.href
      });
    },
    activateEditUrlInNewTab: function(sourceFrameId) {
      return this.open(sourceFrameId, {
        completer: "omni",
        selectFirst: false,
        query: window.location.href,
        newTab: true
      });
    },
    init: function() {
      if (this.vomnibarUI == null) {
        this.vomnibarUI = new UIComponent("pages/vomnibar.html", "vomnibarFrame", (function(_this) {
          return function(event) {
            if (event.data === "hide") {
              return _this.vomnibarUI.hide();
            }
          };
        })(this));
        return window.addEventListener("focus", (function(_this) {
          return function(event) {
            if (event.target === window) {
              _this.vomnibarUI.postMessage("hidden");
            }
            return true;
          };
        })(this));
      }
    },
    open: function(sourceFrameId, options) {
      return this.vomnibarUI.activate(extend(options, {
        sourceFrameId: sourceFrameId
      }));
    }
  };

  root = typeof exports !== "undefined" && exports !== null ? exports : window;

  root.Vomnibar = Vomnibar;

}).call(this);
