diff --git a/common/content/autocommands.js b/common/content/autocommands.js index 8aad6061..919ab2a3 100644 --- a/common/content/autocommands.js +++ b/common/content/autocommands.js @@ -110,7 +110,7 @@ const AutoCommands = Module("autocommands", { * @param {Object} args The args to pass to each autocommand. */ trigger: function (event, args) { - if (options.get("eventignore").has("all", event)) + if (options.get("eventignore").has(event)) return; let autoCmds = this._store.filter(function (autoCmd) autoCmd.event == event); @@ -269,7 +269,8 @@ const AutoCommands = Module("autocommands", { "List of autocommand event names which should be ignored", "stringlist", "", { - completer: function () Iterator(update({ all: "All Events" }, config.autocommands)) + completer: function () Iterator(update({ all: "All Events" }, config.autocommands)), + has: Option.has.toggleAll }); } }); diff --git a/common/content/dactyl.js b/common/content/dactyl.js index e1bbe6b7..1ea01244 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -797,9 +797,9 @@ const Dactyl = Module("dactyl", { : params.where == dactyl.NEW_BACKGROUND_TAB; if (params.from && dactyl.has("tabs")) { - if (!params.where && options.get("newtab").has("all", params.from)) + if (!params.where && options.get("newtab").has(params.from)) where = dactyl.NEW_TAB; - background ^= !options.get("activate").has("all", params.from); + background ^= !options.get("activate").has(params.from); } if (urls.length == 0) diff --git a/common/content/options.js b/common/content/options.js index 7d51d6a6..7f05e8fe 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -376,6 +376,12 @@ const Option = Class("Option", { */ SCOPE_BOTH: 3, + has: { + toggleAll: function toggleAll() toggleAll.supercall(this, "all") + ? Array.some(arguments, function (val) this.value.indexOf(val) === -1, this) + : toggleAll.superapply(this, arguments), + }, + parseRegex: function (value, result, flags) { let [, bang, val] = /^(!?)(.*)/.exec(value); let re = RegExp(Option.dequote(val), flags); diff --git a/common/content/tabs.js b/common/content/tabs.js index 3d6f552c..34d037be 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -784,7 +784,7 @@ const Tabs = Module("tabs", { let tab = tabs.getTab(); let activate = args.bang ? true : false; - if (options.get("activate").has("tabopen", "all")) + if (options.get("activate").has("tabopen")) activate = !activate; for (let i in util.range(0, Math.max(1, args.count))) @@ -1010,6 +1010,7 @@ const Tabs = Module("tabs", { if (config.hasTabbrowser) { let activateGroups = [ + ["all", "Activate everything"], ["addons", ":addo[ns] command"], ["bookmarks", "Tabs loaded from bookmarks", "loadBookmarksInBackground"], ["diverted", "Links with targets set to new tabs", "loadDivertedInBackground"], @@ -1027,6 +1028,7 @@ const Tabs = Module("tabs", { "stringlist", [g[0] for (g in values(activateGroups)) if (!g[2] || !options.getPref("browser.tabs." + g[2]))].join(","), { completer: function (context) activateGroups, + has: Option.has.toggleAll, setter: function (newValues) { let valueSet = set(newValues); for (let group in values(activateGroups)) @@ -1050,7 +1052,8 @@ const Tabs = Module("tabs", { ["help", ":h[elp] command"], ["javascript", ":javascript! or :js! command"], ["prefs", ":pref[erences]! or :prefs! command"] - ] + ], + has: Option.has.toggleAll }); // TODO: Is this really applicable to Melodactyl? diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm index c53ad416..c43d57b3 100644 --- a/common/modules/sanitizer.jsm +++ b/common/modules/sanitizer.jsm @@ -228,13 +228,14 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR let items = args.slice(); if (args.bang) { dactyl.assert(args.length == 0, "E488: Trailing characters"); - items = modules.options.get("sanitizeitems").values; + items = Object.keys(sanitizer.itemDescriptions).filter( + function (k) modules.options.get("sanitizeitems").has(k)); } else dactyl.assert(modules.options.get("sanitizeitems").validator(items), "Valid items required"); - if (items[0] == "all") - items = Object.keys(sanitizer.itemDescriptions); + if (items.indexOf("all") >= 0) + items = Object.keys(sanitizer.itemDescriptions).filter(function (k) items.indexOf(k) === -1); sanitizer.range = range; sanitizer.ignoreTimespan = range.min == null; @@ -305,9 +306,9 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR "stringlist", "all", { completer: function (value) Iterator(sanitizer.itemDescriptions), + has: modules.Option.has.toggleAll, validator: function (values) values.length && - values.every(function (val) set.has(sanitizer.itemDescriptions, val)) && - (values.length == 1 || !values.some(function (val) val == "all")) + values.every(function (val) val === "all" || set.has(sanitizer.itemDescriptions, val)) }); options.add(["sanitizetimespan", "sts"],