1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-13 23:15:46 +01:00

Get rid of horrible coalesced event handlers in commandline.js.

--HG--
branch : key-processing
This commit is contained in:
Kris Maglione
2011-01-24 12:50:08 -05:00
parent 56777f59c3
commit 9786171520
10 changed files with 181 additions and 206 deletions

View File

@@ -233,23 +233,15 @@ var Addon = Class("Addon", {
}
});
["cancelUninstall", "findUpdates", "getResourceURI", "hasResource",
"isCompatibleWith", "uninstall"].forEach(function (prop) {
Addon.prototype[prop] = function proxy() this.addon[prop].apply(this.addon, arguments);
});
["aboutURL", "appDisabled", "applyBackgroundUpdates", "blocklistState",
"contributors", "creator", "description", "developers", "homepageURL",
"iconURL", "id", "install", "installDate", "isActive", "isCompatible",
"isPlatformCompatible", "name", "operationsRequiringRestart",
"optionsURL", "pendingOperations", "pendingUpgrade", "permissions",
"providesUpdatesSecurely", "releaseNotesURI", "scope", "screenshots",
"size", "sourceURI", "translators", "type", "updateDate",
"userDisabled", "version"].forEach(function (prop) {
Object.defineProperty(Addon.prototype, prop, {
get: function get_proxy() this.addon[prop],
set: function set_proxy(val) this.addon[prop] = val
});
iter.forEach(properties(config.addon), function (prop) {
let desc = Object.getOwnPropertyDescriptor(config.addon, prop);
if (callable(desc.value))
Addon.prototype[prop] = function proxy() this.addon[prop].apply(this.addon, arguments);
else
Object.defineProperty(Addon.prototype, prop, {
get: function get_proxy() this.addon[prop],
set: function set_proxy(val) this.addon[prop] = val
});
});
var AddonList = Class("AddonList", {

View File

@@ -188,10 +188,17 @@ var Highlights = Module("Highlight", {
* @param {Node} node
* @param {string} group
*/
highlightNode: function (node, group) {
highlightNode: function (node, group, applyBindings) {
node.setAttributeNS(NS.uri, "highlight", group);
for each (let h in group.split(" "))
this.loaded[h] = true;
let groups = group.split(" ");
for each (let group in groups)
this.loaded[group] = true;
if (applyBindings)
for each (let group in groups)
if (group in template.bindings)
template.bindings[group](node, applyBindings);
},
/**

View File

@@ -270,9 +270,11 @@ var Overlay = Module("Overlay", {
modules.events.addSessionListener(window, "unload", function onUnload() {
window.removeEventListener("unload", onUnload.wrapped, false);
for (let [, mod] in iter(modules))
if (mod instanceof ModuleBase && "destroy" in mod)
util.trapErrors(mod.destroy, mod);
for (let prop in properties(modules)) {
let desc = Object.getOwnPropertyDescriptor(modules, prop);
if (desc.value instanceof ModuleBase && "destroy" in desc.value)
util.trapErrors(desc.value.destroy, desc.value);
}
}, false);
}
}));

View File

@@ -131,6 +131,16 @@ var Template = Module("Template", {
update: function update() {
this.collapsed = !this.commandAllowed;
}
}),
Events: Class("Events", Binding, {
init: function init(node, params) {
init.supercall(this, node);
let obj = params.eventTarget;
for (let [event, handler] in Iterator(obj[this.getAttribute("events") || "events"]))
node.addEventListener(event, obj.closure(handler), false);
}
})
},

View File

@@ -1602,19 +1602,17 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
case "element":
let domnode = doc.createElementNS(node.namespace(), node.localName());
for each (let attr in node.@*::*)
if (attr.name() != "highlight")
domnode.setAttributeNS(attr.namespace(), attr.localName(), String(attr));
for each (let child in node.*::*)
domnode.appendChild(xmlToDom(child, doc, nodes));
if (nodes && node.@key)
nodes[node.@key] = domnode;
for each (let attr in node.@*::*)
if (attr.name() != "highlight")
domnode.setAttributeNS(attr.namespace(), attr.localName(), String(attr));
else {
highlight.highlightNode(domnode, String(attr));
if (attr in template.bindings)
template.bindings[attr](domnode, nodes);
}
if (node.@highlight)
highlight.highlightNode(domnode, String(node.@highlight), nodes || true);
return domnode;
default:
return null;