From d37e8159ed9aaeff35e7929047ce71007ebb4964 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 19 Feb 2011 22:02:01 -0500 Subject: [PATCH] Make Teledactyl minimally functional, albeit with quite a lot of errors on the console. --- common/content/buffer.js | 84 ++++----- common/content/dactyl.js | 12 +- common/content/mappings.js | 4 +- common/content/statusline.js | 11 +- common/content/tabs.js | 10 +- common/modules/addons.jsm | 2 +- common/modules/base.jsm | 5 +- common/modules/config.jsm | 6 +- common/modules/finder.jsm | 8 +- common/modules/options.jsm | 5 +- common/modules/overlay.jsm | 99 +++++------ common/modules/sanitizer.jsm | 17 +- common/modules/services.jsm | 11 +- common/modules/util.jsm | 3 + common/skin/dactyl.css | 5 +- pentadactyl/chrome.manifest | 1 - pentadactyl/content/config.js | 3 +- teledactyl/Donors | 3 - teledactyl/NEWS | 64 ------- teledactyl/chrome.manifest | 20 +-- teledactyl/content/compose/compose.js | 147 +++++++--------- teledactyl/content/config.js | 234 +++++++++++++++----------- teledactyl/content/mail.js | 31 ++-- 23 files changed, 373 insertions(+), 412 deletions(-) delete mode 100644 teledactyl/Donors diff --git a/common/content/buffer.js b/common/content/buffer.js index ff1a7831..73d0e3b3 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -1523,7 +1523,7 @@ var Buffer = Module("buffer", { "Go to the root of the website", function () { buffer.climbUrlPath(-1); }); - mappings.add(modes.COMMAND, [".", ""], + mappings.add([modes.COMMAND], [".", ""], "Repeat the last key event", function (args) { if (mappings.repeat) { @@ -1533,54 +1533,54 @@ var Buffer = Module("buffer", { }, { count: true }); - mappings.add(modes.COMMAND, ["i", ""], + mappings.add([modes.COMMAND], ["i", ""], "Start caret mode", function () { modes.push(modes.CARET); }); - mappings.add(modes.COMMAND, [""], + mappings.add([modes.COMMAND], [""], "Stop loading the current web page", function () { ex.stop(); }); // scrolling - mappings.add(modes.COMMAND, ["j", "", "", ""], + mappings.add([modes.COMMAND], ["j", "", "", ""], "Scroll document down", function (args) { buffer.scrollVertical("lines", Math.max(args.count, 1)); }, { count: true }); - mappings.add(modes.COMMAND, ["k", "", "", ""], + mappings.add([modes.COMMAND], ["k", "", "", ""], "Scroll document up", function (args) { buffer.scrollVertical("lines", -Math.max(args.count, 1)); }, { count: true }); - mappings.add(modes.COMMAND, dactyl.has("mail") ? ["h", ""] : ["h", "", ""], + mappings.add([modes.COMMAND], dactyl.has("mail") ? ["h", ""] : ["h", "", ""], "Scroll document to the left", function (args) { buffer.scrollHorizontal("columns", -Math.max(args.count, 1)); }, { count: true }); - mappings.add(modes.COMMAND, dactyl.has("mail") ? ["l", ""] : ["l", "", ""], + mappings.add([modes.COMMAND], dactyl.has("mail") ? ["l", ""] : ["l", "", ""], "Scroll document to the right", function (args) { buffer.scrollHorizontal("columns", Math.max(args.count, 1)); }, { count: true }); - mappings.add(modes.COMMAND, ["0", "^", ""], + mappings.add([modes.COMMAND], ["0", "^", ""], "Scroll to the absolute left of the document", function () { buffer.scrollToPercent(0, null); }); - mappings.add(modes.COMMAND, ["$", ""], + mappings.add([modes.COMMAND], ["$", ""], "Scroll to the absolute right of the document", function () { buffer.scrollToPercent(100, null); }); - mappings.add(modes.COMMAND, ["gg", ""], + mappings.add([modes.COMMAND], ["gg", ""], "Go to the top of the document", function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 0); }, { count: true }); - mappings.add(modes.COMMAND, ["G", ""], + mappings.add([modes.COMMAND], ["G", ""], "Go to the end of the document", function (args) { buffer.scrollToPercent(null, args.count != null ? args.count : 100); }, { count: true }); - mappings.add(modes.COMMAND, ["%", ""], + mappings.add([modes.COMMAND], ["%", ""], "Scroll to {count} percent of the document", function (args) { dactyl.assert(args.count > 0 && args.count <= 100); @@ -1588,59 +1588,59 @@ var Buffer = Module("buffer", { }, { count: true }); - mappings.add(modes.COMMAND, ["", ""], + mappings.add([modes.COMMAND], ["", ""], "Scroll window downwards in the buffer", function (args) { buffer._scrollByScrollSize(args.count, true); }, { count: true }); - mappings.add(modes.COMMAND, ["", ""], + mappings.add([modes.COMMAND], ["", ""], "Scroll window upwards in the buffer", function (args) { buffer._scrollByScrollSize(args.count, false); }, { count: true }); - mappings.add(modes.COMMAND, ["", "", "", ""], + mappings.add([modes.COMMAND], ["", "", "", ""], "Scroll up a full page", function (args) { buffer.scrollVertical("pages", -Math.max(args.count, 1)); }, { count: true }); - mappings.add(modes.COMMAND, ["", "", "", ""], + mappings.add([modes.COMMAND], ["", "", "", ""], "Scroll down a full page", function (args) { buffer.scrollVertical("pages", Math.max(args.count, 1)); }, { count: true }); - mappings.add(modes.COMMAND, ["]f", ""], + mappings.add([modes.COMMAND], ["]f", ""], "Focus next frame", function (args) { buffer.shiftFrameFocus(Math.max(args.count, 1)); }, { count: true }); - mappings.add(modes.COMMAND, ["[f", ""], + mappings.add([modes.COMMAND], ["[f", ""], "Focus previous frame", function (args) { buffer.shiftFrameFocus(-Math.max(args.count, 1)); }, { count: true }); - mappings.add(modes.COMMAND, ["]]", ""], + mappings.add([modes.COMMAND], ["]]", ""], "Follow the link labeled 'next' or '>' if it exists", function (args) { buffer.findLink("next", options["nextpattern"], (args.count || 1) - 1, true); }, { count: true }); - mappings.add(modes.COMMAND, ["[[", ""], + mappings.add([modes.COMMAND], ["[[", ""], "Follow the link labeled 'prev', 'previous' or '<' if it exists", function (args) { buffer.findLink("previous", options["previouspattern"], (args.count || 1) - 1, true); }, { count: true }); - mappings.add(modes.COMMAND, ["gf", ""], + mappings.add([modes.COMMAND], ["gf", ""], "Toggle between rendered and source view", function () { buffer.viewSource(null, false); }); - mappings.add(modes.COMMAND, ["gF", ""], + mappings.add([modes.COMMAND], ["gF", ""], "View source with an external editor", function () { buffer.viewSource(null, true); }); - mappings.add(modes.COMMAND, ["gi", ""], + mappings.add([modes.COMMAND], ["gi", ""], "Focus last used input field", function (args) { let elem = buffer.lastInputField; @@ -1672,15 +1672,15 @@ var Buffer = Module("buffer", { }, { count: true }); - mappings.add(modes.COMMAND, ["gP"], - "Open (put) a URL based on the current clipboard contents in a new buffer", + mappings.add([modes.COMMAND], ["gP"], + "Open (]put) a URL based on the current clipboard contents in a new buffer", function () { let url = dactyl.clipboardRead(); dactyl.assert(url, "No clipboard data"); dactyl.open(url, { from: "paste", where: dactyl.NEW_TAB, background: true }); }); - mappings.add(modes.COMMAND, ["p", "", ""], + mappings.add([modes.COMMAND], ["p", "", ""], "Open (put) a URL based on the current clipboard contents in the current buffer", function () { let url = dactyl.clipboardRead(); @@ -1688,7 +1688,7 @@ var Buffer = Module("buffer", { dactyl.open(url); }); - mappings.add(modes.COMMAND, ["P", ""], + mappings.add([modes.COMMAND], ["P", ""], "Open (put) a URL based on the current clipboard contents in a new buffer", function () { let url = dactyl.clipboardRead(); @@ -1697,16 +1697,16 @@ var Buffer = Module("buffer", { }); // reloading - mappings.add(modes.COMMAND, ["r", ""], + mappings.add([modes.COMMAND], ["r", ""], "Reload the current web page", function () { tabs.reload(tabs.getTab(), false); }); - mappings.add(modes.COMMAND, ["R", ""], + mappings.add([modes.COMMAND], ["R", ""], "Reload while skipping the cache", function () { tabs.reload(tabs.getTab(), true); }); // yanking - mappings.add(modes.COMMAND, ["Y", ""], + mappings.add([modes.COMMAND], ["Y", ""], "Copy selected text or current word", function () { let sel = buffer.currentWord; @@ -1715,62 +1715,62 @@ var Buffer = Module("buffer", { }); // zooming - mappings.add(modes.COMMAND, ["zi", "+", ""], + mappings.add([modes.COMMAND], ["zi", "+", ""], "Enlarge text zoom of current web page", function (args) { buffer.zoomIn(Math.max(args.count, 1), false); }, { count: true }); - mappings.add(modes.COMMAND, ["zm", ""], + mappings.add([modes.COMMAND], ["zm", ""], "Enlarge text zoom of current web page by a larger amount", function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, false); }, { count: true }); - mappings.add(modes.COMMAND, ["zo", "-", ""], + mappings.add([modes.COMMAND], ["zo", "-", ""], "Reduce text zoom of current web page", function (args) { buffer.zoomOut(Math.max(args.count, 1), false); }, { count: true }); - mappings.add(modes.COMMAND, ["zr", ""], + mappings.add([modes.COMMAND], ["zr", ""], "Reduce text zoom of current web page by a larger amount", function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, false); }, { count: true }); - mappings.add(modes.COMMAND, ["zz", ""], + mappings.add([modes.COMMAND], ["zz", ""], "Set text zoom value of current web page", function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, false); }, { count: true }); - mappings.add(modes.COMMAND, ["ZI", "zI", ""], + mappings.add([modes.COMMAND], ["ZI", "zI", ""], "Enlarge full zoom of current web page", function (args) { buffer.zoomIn(Math.max(args.count, 1), true); }, { count: true }); - mappings.add(modes.COMMAND, ["ZM", "zM", ""], + mappings.add([modes.COMMAND], ["ZM", "zM", ""], "Enlarge full zoom of current web page by a larger amount", function (args) { buffer.zoomIn(Math.max(args.count, 1) * 3, true); }, { count: true }); - mappings.add(modes.COMMAND, ["ZO", "zO", ""], + mappings.add([modes.COMMAND], ["ZO", "zO", ""], "Reduce full zoom of current web page", function (args) { buffer.zoomOut(Math.max(args.count, 1), true); }, { count: true }); - mappings.add(modes.COMMAND, ["ZR", "zR", ""], + mappings.add([modes.COMMAND], ["ZR", "zR", ""], "Reduce full zoom of current web page by a larger amount", function (args) { buffer.zoomOut(Math.max(args.count, 1) * 3, true); }, { count: true }); - mappings.add(modes.COMMAND, ["zZ", ""], + mappings.add([modes.COMMAND], ["zZ", ""], "Set full zoom value of current web page", function (args) { buffer.setZoom(args.count > 1 ? args.count : 100, true); }, { count: true }); // page info - mappings.add(modes.COMMAND, ["", ""], + mappings.add([modes.COMMAND], ["", ""], "Print the current file name", function () { buffer.showPageInfo(false); }); - mappings.add(modes.COMMAND, ["g", ""], + mappings.add([modes.COMMAND], ["g", ""], "Print file information", function () { buffer.showPageInfo(true); }); }, diff --git a/common/content/dactyl.js b/common/content/dactyl.js index f1152a72..470ae96d 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1193,7 +1193,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (urls.length == 0) return; - let browser = config.browser; + let browser = config.tabbrowser; function open(urls, where) { try { let url = Array.concat(urls)[0]; @@ -1214,7 +1214,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { case dactyl.NEW_WINDOW: let win = window.openDialog(document.documentURI, "_blank", "chrome,all,dialog=no"); util.waitFor(function () win.document.readyState === "complete"); - browser = win.getBrowser(); + browser = win.dactyl && win.dactyl.modules.config.tabbrowser || win.getBrowser(); // FALLTHROUGH case dactyl.CURRENT_TAB: browser.loadURIWithFlags(url, flags, null, null, postdata); @@ -1278,12 +1278,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { return url.replace(/\s+/g, ""); // Check for a matching search keyword. - let searchURL = bookmarks.getSearchURL(url, false); + let searchURL = loaded.bookmarks && bookmarks.getSearchURL(url, false); if (searchURL) return searchURL; // If it looks like URL-ish (foo.com/bar), let Gecko figure it out. - if (this.urlish.test(url)) + if (this.urlish.test(url) || !loaded.bookmarks) return util.createURI(url).spec; // Pass it off to the default search engine or, failing @@ -1626,9 +1626,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { document.title = document.title.replace(RegExp("(.*)" + util.regexp.escape(old)), "$1" + current); } - // TODO: remove this FF3.5 test when we no longer support 3.0 - // : make this a config feature - if (services.privateBrowsing) { + if (services.has("privateBrowsing")) { let oldValue = win.getAttribute("titlemodifier_normal"); let suffix = win.getAttribute("titlemodifier_privatebrowsing").substr(oldValue.length); diff --git a/common/content/mappings.js b/common/content/mappings.js index 42570054..305ffc6c 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -30,9 +30,9 @@ */ var Map = Class("Map", { init: function (modes, keys, description, action, extraInfo) { - modes = Array.concat(modes).map(function (m) isObject(m) ? m.mask : m); + modes = Array.concat(modes); if (!modes.every(util.identity)) - throw Error("Invalid modes"); + throw TypeError("Invalid modes: " + modes); this.id = ++Map.id; this.modes = modes; diff --git a/common/content/statusline.js b/common/content/statusline.js index cff302c0..209c88b3 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -9,7 +9,7 @@ /** @scope modules */ var StatusLine = Module("statusline", { - init: function () { + init: function init() { this._statusLine = document.getElementById("status-bar"); this.statusBar = document.getElementById("addon-bar") || this._statusLine; this.statusBar.collapsed = true; @@ -23,6 +23,8 @@ var StatusLine = Module("statusline", { #addon-bar > xul|toolbarspring { visibility: collapse; } ]]>); + util.overlayWindow(window, { append: <> }); + highlight.loadCSS(util.compileMacro(