1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-04 08:25:46 +01:00

Make "all" toggle other items in "activate", "eventignore", "newtab", and "sanitizeitems".

This commit is contained in:
Kris Maglione
2010-10-12 14:29:11 -04:00
parent 2e3f47b19e
commit 4351bb675b
5 changed files with 22 additions and 11 deletions

View File

@@ -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
});
}
});

View File

@@ -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)

View File

@@ -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);

View File

@@ -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?

View File

@@ -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"],