mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 23:37:59 +01:00
Minor cleanup.
This commit is contained in:
@@ -1124,7 +1124,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
|
|
||||||
let loadplugins = options.get("loadplugins");
|
let loadplugins = options.get("loadplugins");
|
||||||
if (args)
|
if (args)
|
||||||
loadplugins = { __proto__: loadplugins, value: args.map(Option.parseRegexp) }
|
loadplugins = { __proto__: loadplugins, value: args.map(Option.parseRegexp) };
|
||||||
|
|
||||||
dir.readDirectory(true).forEach(function (file) {
|
dir.readDirectory(true).forEach(function (file) {
|
||||||
if (file.isFile() && loadplugins.getKey(file.path)
|
if (file.isFile() && loadplugins.getKey(file.path)
|
||||||
|
|||||||
@@ -732,8 +732,7 @@ var Events = Module("events", {
|
|||||||
* @param {Object} opts The pseudo-event. @optional
|
* @param {Object} opts The pseudo-event. @optional
|
||||||
*/
|
*/
|
||||||
create: function (doc, type, opts) {
|
create: function (doc, type, opts) {
|
||||||
opts = opts || {};
|
const DEFAULTS = {
|
||||||
var DEFAULTS = {
|
|
||||||
HTML: {
|
HTML: {
|
||||||
type: type, bubbles: true, cancelable: false
|
type: type, bubbles: true, cancelable: false
|
||||||
},
|
},
|
||||||
@@ -756,22 +755,31 @@ var Events = Module("events", {
|
|||||||
relatedTarget: null
|
relatedTarget: null
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const TYPES = {
|
|
||||||
change: "", "dactyl-input": "", input: "", submit: "",
|
opts = opts || {};
|
||||||
click: "Mouse", mousedown: "Mouse", mouseup: "Mouse",
|
|
||||||
mouseover: "Mouse", mouseout: "Mouse",
|
var t = this._create_types[type];
|
||||||
keypress: "Key", keyup: "Key", keydown: "Key"
|
|
||||||
};
|
|
||||||
var t = TYPES[type];
|
|
||||||
var evt = doc.createEvent((t || "HTML") + "Events");
|
var evt = doc.createEvent((t || "HTML") + "Events");
|
||||||
|
|
||||||
let defaults = DEFAULTS[t || "HTML"];
|
let defaults = DEFAULTS[t || "HTML"];
|
||||||
evt["init" + t + "Event"].apply(evt, Object.keys(defaults)
|
|
||||||
.map(function (k) k in opts ? opts[k]
|
let args = Object.keys(defaults)
|
||||||
: defaults[k]));
|
.map(function (k) k in opts ? opts[k] : defaults[k]);
|
||||||
|
|
||||||
|
evt["init" + t + "Event"].apply(evt, args);
|
||||||
return evt;
|
return evt;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_create_types: Class.memoize(function () iter(
|
||||||
|
{
|
||||||
|
Mouse: "click mousedown mouseout mouseover mouseup",
|
||||||
|
Key: "keydown keypress keyup",
|
||||||
|
"": "change dactyl-input input submit"
|
||||||
|
}
|
||||||
|
).map(function ([k, v]) v.split(" ").map(function (v) [v, k]))
|
||||||
|
.flatten()
|
||||||
|
.toObject()),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a user-input string of keys into a canonical
|
* Converts a user-input string of keys into a canonical
|
||||||
* representation.
|
* representation.
|
||||||
|
|||||||
Reference in New Issue
Block a user