]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/events.js
Import r6923 from upstream hg supporting Firefox up to 22.0a1
[dactyl.git] / common / content / events.js
index ac846d8ce1cb38cab38a91e81e9dfe02fe6937dc..98dc0281f512df5362a4c5f6528498d3576c68c2 100644 (file)
@@ -1,10 +1,10 @@
 // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
 // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2011 by Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
 //
 // 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 */
 
@@ -102,17 +102,14 @@ var Events = Module("events", {
     init: function () {
         this.keyEvents = [];
 
-        XML.ignoreWhitespace = true;
         overlay.overlayWindow(window, {
-            append: <e4x xmlns={XUL}>
-                <window id={document.documentElement.id}>
-                    <!-- http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands -->
-                    <commandset id="dactyl-onfocus" commandupdater="true" events="focus"
-                                oncommandupdate="dactyl.modules.events.onFocusChange(event);"/>
-                    <commandset id="dactyl-onselect" commandupdater="true" events="select"
-                                oncommandupdate="dactyl.modules.events.onSelectionChange(event);"/>
-                </window>
-            </e4x>.elements()
+            append: [
+                ["window", { id: document.documentElement.id, xmlns: "xul" },
+                    // http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands
+                    ["commandset", { id: "dactyl-onfocus", commandupdater: "true", events: "focus",
+                                     commandupdate: this.closure.onFocusChange }],
+                    ["commandset", { id: "dactyl-onselect", commandupdater: "true", events: "select",
+                                     commandupdate: this.closure.onSelectionChange }]]]
         });
 
         this._fullscreen = window.fullScreen;
@@ -664,13 +661,15 @@ var Events = Module("events", {
             let duringFeed = this.duringFeed || [];
             this.duringFeed = [];
             try {
-                if (DOM.Event.feedingEvent)
-                    for (let [k, v] in Iterator(DOM.Event.feedingEvent))
+                let ourEvent = DOM.Event.feedingEvent;
+                DOM.Event.feedingEvent = null;
+                if (ourEvent)
+                    for (let [k, v] in Iterator(ourEvent))
                         if (!(k in event))
                             event[k] = v;
-                DOM.Event.feedingEvent = null;
 
-                let key = DOM.Event.stringify(event);
+                let key = DOM.Event.stringify(ourEvent || event);
+                event.dactylString = key;
 
                 // Hack to deal with <BS> and so forth not dispatching input
                 // events
@@ -983,7 +982,7 @@ var Events = Module("events", {
         });
     },
 
-    commands: function () {
+    commands: function initCommands() {
         commands.add(["delmac[ros]"],
             "Delete macros",
             function (args) {
@@ -1009,13 +1008,13 @@ var Events = Module("events", {
                 completer: function (context) completion.macro(context)
             });
     },
-    completion: function () {
+    completion: function initCompletion() {
         completion.macro = function macro(context) {
             context.title = ["Macro", "Keys"];
             context.completions = [item for (item in events.getMacros())];
         };
     },
-    mappings: function () {
+    mappings: function initMappings() {
 
         mappings.add([modes.MAIN],
             ["<A-b>", "<pass-next-key-builtin>"], "Process the next key as a builtin mapping",
@@ -1097,7 +1096,7 @@ var Events = Module("events", {
             },
             { count: true });
     },
-    options: function () {
+    options: function initOptions() {
         const Hive = Class("Hive", {
             init: function init(values, map) {
                 this.name = "passkeys:" + map;