]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/dactyl.js
Import r6948 from upstream hg supporting Firefox up to 24.*
[dactyl.git] / common / content / dactyl.js
index 02ce9bd177eec85c419f7875c35bdd8caac1e2be..64aa91358d46886bd9cbe3e492cf8cb991a054df 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
 // Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
 //
 // This work is licensed for reuse under an MIT license. Details are
 // given in the LICENSE.txt file included with this file.
@@ -83,7 +83,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
         }
     },
 
-
     observers: {
         "dactyl-cleanup": function dactyl_cleanup(subject, reason) {
             let modules = dactyl.modules;
@@ -236,8 +235,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
             });
     },
 
-    triggerObserver: function triggerObserver(type) {
-        return this.applyTriggerObserver(type, Array.slice(arguments, 1));
+    triggerObserver: function triggerObserver(type, ...args) {
+        return this.applyTriggerObserver(type, args);
     },
 
     addUsageCommand: function (params) {
@@ -524,10 +523,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
      * Acts like the Function builtin, but the code executes in the
      * userContext global.
      */
-    userFunc: function userFunc() {
+    userFunc: function userFunc(...args) {
         return this.userEval(
-            "(function userFunction(" + Array.slice(arguments, 0, -1).join(", ") + ")" +
-            " { " + arguments[arguments.length - 1] + " })");
+            "(function userFunction(" + args.slice(0, -1).join(", ") + ")" +
+            " { " + args.pop() + " })");
     },
 
     /**
@@ -600,7 +599,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                     if (win.frameElement)
                         win.frameElement.blur();
                     // Grr.
-                    if (content.document.activeElement instanceof HTMLIFrameElement)
+                    if (content.document.activeElement instanceof Ci.nsIDOMHTMLIFrameElement)
                         content.document.activeElement.blur();
                 });
             }
@@ -682,7 +681,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
             tag = function (map) [
                 let (c = obj.modes[0].char) c ? c + "_" : "",
                 map
-            ]
+            ];
             link = function (map) {
                 let [, mode, name, extra] = /^(?:(.)_)?(?:<([^>]+)>)?(.*)$/.exec(map);
                 let k = ["k", {}, extra];
@@ -710,7 +709,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
         let description = ["description", {},
             obj.description ? ["p", {}, template.linkifyHelp(obj.description.replace(/\.?$/, "."), true)] : "",
             extraHelp ? extraHelp : "",
-            !(extraHelp || obj.description) ? ["p", {}, /*L*/ "Sorry, no help available."] : ""]
+            !(extraHelp || obj.description) ? ["p", {}, /*L*/ "Sorry, no help available."] : ""];
 
         res.push(
             ["item", {},
@@ -1117,11 +1116,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
      * @param {function} func The function to call
      * @param {object} self The 'this' object for the function.
      */
-    trapErrors: function trapErrors(func, self) {
+    trapErrors: function trapErrors(func, self, ...args) {
         try {
             if (isString(func))
                 func = self[func];
-            return func.apply(self || this, Array.slice(arguments, 2));
+            return func.apply(self || this, args);
         }
         catch (e) {
             try {
@@ -1200,7 +1199,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                     dactyl.reportError(e, true);
                 }
             });
-        }
+        };
     },
 
     /**
@@ -1404,10 +1403,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                         groups.every(function (g) !g.validator || g.validator(val))
             });
 
-        options.add(["helpfile", "hf"],
-            "Name of the main help file",
-            "string", "intro");
-
         options.add(["loadplugins", "lpl"],
             "A regexp list that defines which plugins are loaded at startup and via :loadplugins",
             "regexplist", "'\\.(js|" + config.fileExtension + ")$'");
@@ -1829,7 +1824,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                     commandline.commandOutput([
                         ["div", {}, [config.appName, " ", config.version, date, " running on: "].join("")],
                         ["div", {}, [window.navigator.userAgent].join("")]
-                    ])
+                    ]);
                 }
             }, {
                 argCount: "0",
@@ -2003,4 +1998,4 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
     }
 });
 
-// vim: set fdm=marker sw=4 ts=4 et:
+// vim: set fdm=marker sw=4 sts=4 ts=8 et: