Skip to content

Commit

Permalink
SDK: Commands: Ensure we're using the right window object
Browse files Browse the repository at this point in the history
(integrated from master branch change 9.2.1-270-ga334147 by Nathan Rijksen <[email protected]>)
  • Loading branch information
Naatan committed Sep 14, 2015
1 parent 69dac1f commit 2bfabf2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/chrome/komodo/content/sdk/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const {Cc, Ci, Cu} = require("chrome");
const $ = require("ko/dom");
const prefs = ko.prefs;
const keybinds = require("ko/keybindings");
const _window = require("ko/windows").getMain();

const log = require("ko/logging").getLogger("ko-commands");
//log.setLevel(require("ko/logging").LOG_DEBUG);
Expand All @@ -22,7 +22,7 @@
*/
var init = () =>
{
window.controllers.appendController(controller);
_window.controllers.appendController(controller);
}

/**
Expand Down Expand Up @@ -72,18 +72,21 @@
if (document.getElementById(commandName))
throw new this.exceptionAlreadyUsed;

var commandNode = $("<command/>");
var commandNode = $("<command/>", _window);
commandNode.attr({
id: commandName,
key: "key_" + commandName,
onCommand: "ko.commands.doCommandAsync('"+commandName+"', event)",
desc: opts.label || commandName
});
$("#allcommands").append(commandNode);
$("#allcommands", _window).append(commandNode);

log.debug(("defaultBind" in opts));
if (("defaultBind" in opts) && opts.defaultBind)
{
var keybinds = require("ko/keybindings");
keybinds.register(commandName, opts.defaultBind, opts.forceBind);
}

local.registered[commandName] = {
command: command,
Expand All @@ -109,9 +112,11 @@

var opts = local.registered[commandName].opts;
var label = local.registered[commandName].opts.label || commandName;

var keybinds = require("ko/keybindings");
keybinds.unregister(commandName,label);

$("#"+commandName).remove();
$("#"+commandName, _window).remove();
delete local.registered[commandName];
}

Expand Down

0 comments on commit 2bfabf2

Please sign in to comment.