X-Git-Url: https://git.donarmstrong.com/dactyl.git?a=blobdiff_plain;f=common%2Fcontent%2Fbrowser.js;h=cee3adbc67cc62cf42db6c15ff89f6929bd3143f;hb=9044153cb63835e39b9de8ec4ade237c03e3888a;hp=5a6ba5ef15a599c84f4a2e44acbfa9fa81e3271e;hpb=70740024f9c028c1fd63e1a1850ab062ff956054;p=dactyl.git diff --git a/common/content/browser.js b/common/content/browser.js index 5a6ba5e..cee3adb 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -4,7 +4,7 @@ // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -"use strict"; +/* use strict */ /** @scope modules */ @@ -13,8 +13,8 @@ */ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { init: function init() { - this.cleanupProgressListener = util.overlayObject(window.XULBrowserWindow, - this.progressListener); + this.cleanupProgressListener = overlay.overlayObject(window.XULBrowserWindow, + this.progressListener); util.addObserver(this); }, @@ -148,13 +148,16 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), let win = webProgress.DOMWindow; if (win && uri) { - let oldURI = win.document.dactylURI; - if (win.document.dactylLoadIdx === webProgress.loadedTransIndex + Buffer(win).updateZoom(); + + let oldURI = overlay.getData(win.document)["uri"]; + if (overlay.getData(win.document)["load-idx"] === webProgress.loadedTransIndex || !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, "")) for (let frame in values(buffer.allFrames(win))) - frame.document.dactylFocusAllowed = false; - win.document.dactylURI = uri.spec; - win.document.dactylLoadIdx = webProgress.loadedTransIndex; + overlay.setData(frame.document, "focus-allowed", false); + + overlay.setData(win.document, "uri", uri.spec); + overlay.setData(win.document, "load-idx", webProgress.loadedTransIndex); } // Workaround for bugs 591425 and 606877, dactyl bug #81 @@ -207,18 +210,39 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { argCount: "0" }); }, mappings: function initMappings(dactyl, modules, window) { - // opening websites - mappings.add([modes.NORMAL], - ["o"], "Open one or more URLs", - function () { CommandExMode().open("open "); }); + let openModes = array.toObject([ + [dactyl.CURRENT_TAB, ""], + [dactyl.NEW_TAB, "tab"], + [dactyl.NEW_BACKGROUND_TAB, "background tab"], + [dactyl.NEW_WINDOW, "win"] + ]); + + function open(mode, args) { + if (dactyl.forceTarget in openModes) + mode = openModes[dactyl.forceTarget]; + + CommandExMode().open(mode + "open " + (args || "")) + } function decode(uri) util.losslessDecodeURI(uri) .replace(/%20(?!(?:%20)*$)/g, " ") .replace(RegExp(options["urlseparator"], "g"), encodeURIComponent); + mappings.add([modes.NORMAL], + ["o"], "Open one or more URLs", + function () { open(""); }); + mappings.add([modes.NORMAL], ["O"], "Open one or more URLs, based on current location", - function () { CommandExMode().open("open " + decode(buffer.uri.spec)); }); + function () { open("", decode(buffer.uri.spec)); }); + + mappings.add([modes.NORMAL], ["s"], + "Open a search prompt", + function () { open("", options["defsearch"] + " "); }); + + mappings.add([modes.NORMAL], ["S"], + "Open a search prompt for a new tab", + function () { open("tab", options["defsearch"] + " "); }); mappings.add([modes.NORMAL], ["t"], "Open one or more URLs in a new tab", @@ -226,15 +250,15 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), mappings.add([modes.NORMAL], ["T"], "Open one or more URLs in a new tab, based on current location", - function () { CommandExMode().open("tabopen " + decode(buffer.uri.spec)); }); + function () { open("tab", decode(buffer.uri.spec)); }); mappings.add([modes.NORMAL], ["w"], "Open one or more URLs in a new window", - function () { CommandExMode().open("winopen "); }); + function () { open("win"); }); mappings.add([modes.NORMAL], ["W"], "Open one or more URLs in a new window, based on current location", - function () { CommandExMode().open("winopen " + decode(buffer.uri.spec)); }); + function () { open("win", decode(buffer.uri.spec)); }); mappings.add([modes.NORMAL], ["", "~"], "Open home directory",