summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-03-07 19:18:09 -0500
committerKris Maglione <maglione.k@gmail.com>2011-03-07 19:18:09 -0500
commitcd4c0a772278e9aada37229a214b2a7dcaba4c48 (patch)
tree3613532128d1f1063b50b44a2c1fefc9a6c9b001 /common
parent274091eb792619eb7ce873e6cf32037527838296 (diff)
downloadpentadactyl-cd4c0a772278e9aada37229a214b2a7dcaba4c48.tar.gz
Localizify sanitizer descriptions.
Diffstat (limited to 'common')
-rw-r--r--common/modules/base.jsm9
-rw-r--r--common/modules/overlay.jsm2
-rw-r--r--common/modules/sanitizer.jsm20
3 files changed, 20 insertions, 11 deletions
diff --git a/common/modules/base.jsm b/common/modules/base.jsm
index 9c2a8ede..1d8b8bc7 100644
--- a/common/modules/base.jsm
+++ b/common/modules/base.jsm
@@ -207,8 +207,8 @@ defineModule("base", {
"Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "XPCSafeJSObjectWrapper",
"array", "bind", "call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
"deprecated", "endModule", "forEach", "isArray", "isGenerator", "isinstance", "isObject",
- "isString", "isSubclass", "iter", "iterAll", "keys", "memoize", "octal", "properties",
- "require", "set", "update", "values", "withCallerGlobal"
+ "isString", "isSubclass", "iter", "iterAll", "iterOwnProperties","keys", "memoize", "octal",
+ "properties", "require", "set", "update", "values", "withCallerGlobal"
],
use: ["config", "services", "util"]
}, this);
@@ -279,6 +279,11 @@ function properties(obj, prototypes, debugger_) {
}
}
+function iterOwnProperties(obj) {
+ for (let prop in properties(obj))
+ yield [prop, Object.getOwnPropertyDescriptor(obj, prop)];
+}
+
function deprecated(alternative, fn) {
if (isObject(fn))
return Class.Property(iter(fn).map(function ([k, v]) [k, callable(v) ? deprecated(alternative, v) : v])
diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm
index 848007c9..ea626b4c 100644
--- a/common/modules/overlay.jsm
+++ b/common/modules/overlay.jsm
@@ -9,7 +9,7 @@ try {
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("overlay", {
exports: ["ModuleBase"],
- require: ["config", "sanitizer", "services", "util"]
+ require: ["config", "services", "util"]
}, this);
/**
diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm
index 9ba58517..f714205d 100644
--- a/common/modules/sanitizer.jsm
+++ b/common/modules/sanitizer.jsm
@@ -17,8 +17,7 @@ try {
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("sanitizer", {
exports: ["Range", "Sanitizer", "sanitizer"],
- require: ["prefs", "services", "storage", "template", "util"],
- use: ["messages"]
+ require: ["messages", "prefs", "services", "storage", "template", "util"],
}, this);
let tmp = {};
@@ -36,15 +35,18 @@ update(Range.prototype, {
get native() this.isEternity ? null : [range.min || 0, range.max == null ? Number.MAX_VALUE : range.max]
});
-var Item = Class("Item", {
- init: function (name) {
+var Item = Class("SanitizeItem", {
+ init: function (name, params) {
this.name = name;
+ this.description = params.description;
},
// Hack for completion:
"0": Class.Property({ get: function () this.name }),
"1": Class.Property({ get: function () this.description }),
+ description: Messages.Localized(""),
+
get cpdPref() (this.builtin ? "" : Item.PREFIX) + Item.BRANCH + Sanitizer.argToPref(this.name),
get shutdownPref() (this.builtin ? "" : Item.PREFIX) + Item.SHUTDOWN_BRANCH + Sanitizer.argToPref(this.name),
get cpd() prefs.get(this.cpdPref),
@@ -231,10 +233,12 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
},
addItem: function addItem(name, params) {
- this.itemMap[name] = update(this.itemMap[name] || Item(name),
- iter.toObject([k, v]
- for ([k, v] in Iterator(params))
- if (!callable(v))));
+ let item = this.itemMap[name] || Item(name, params);
+ this.itemMap[name] = item;
+
+ for (let [k, prop] in iterOwnProperties(params))
+ if (!("value" in prop) || !callable(prop.value) && !(k in item))
+ Object.defineProperty(item, k, prop);
let names = set([name].concat(params.contains || []).map(function (e) "clear-" + e));
if (params.action)