From 6e22507d69434fde9b23c1f08f727ca78d0d490d Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 14 Feb 2011 17:57:06 -0500 Subject: [PATCH] Minor fixes/cleanup for last commit. --- common/content/commandline.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/common/content/commandline.js b/common/content/commandline.js index 74b203fc..3ea1aeab 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -260,20 +260,15 @@ var CommandWidgets = Class("CommandWidgets", { ["viewable", "complete"].indexOf(elem.contentDocument.readyState) >= 0; }, - _whenReady: function _whenReady(id) { + _whenReady: function _whenReady(id, init) { let elem = document.getElementById(id); - - util.waitFor(bind(this._ready, this, elem)); - - return elem; - }, - - completionList: Class.memoize(function () { - let elem = document.getElementById(elem); while (!this._ready(elem)) yield 10; + + if (init) + init.call(this, elem); yield elem; - }, true), + }, completionContainer: Class.memoize(function () this.completionList.parentNode), @@ -287,16 +282,11 @@ var CommandWidgets = Class("CommandWidgets", { return document.getElementById("dactyl-contextmenu"); }), - multilineOutput: Class.memoize(function () { - let elem = document.getElementById("dactyl-multiline-output"); - while (!this._ready(elem)) - yield 10; - + multilineOutput: Class.memoize(function () this._whenReady("dactyl-multiline-output", function (elem) { elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true); elem.contentDocument.documentElement.id = "dactyl-multiline-output-top"; elem.contentDocument.body.id = "dactyl-multiline-output-content"; - yield elem; - }, true), + }), true), multilineInput: Class.memoize(function () document.getElementById("dactyl-multiline-input")), @@ -581,7 +571,9 @@ var CommandLine = Module("commandline", { get completionList() { let node = this.widgets.active.commandline; if (!node.completionList) { - let elem = this.widgets._whenReady("dactyl-completions-" + node.id); + let elem = document.getElementById("dactyl-completions-" + node.id); + util.waitFor(bind(this.widgets._ready, null, elem)); + node.completionList = ItemList(elem.id); } return node.completionList;