mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-27 15:45:48 +01:00
Make "all" toggle other items in "activate", "eventignore", "newtab", and "sanitizeitems".
This commit is contained in:
@@ -110,7 +110,7 @@ const AutoCommands = Module("autocommands", {
|
|||||||
* @param {Object} args The args to pass to each autocommand.
|
* @param {Object} args The args to pass to each autocommand.
|
||||||
*/
|
*/
|
||||||
trigger: function (event, args) {
|
trigger: function (event, args) {
|
||||||
if (options.get("eventignore").has("all", event))
|
if (options.get("eventignore").has(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let autoCmds = this._store.filter(function (autoCmd) autoCmd.event == event);
|
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",
|
"List of autocommand event names which should be ignored",
|
||||||
"stringlist", "",
|
"stringlist", "",
|
||||||
{
|
{
|
||||||
completer: function () Iterator(update({ all: "All Events" }, config.autocommands))
|
completer: function () Iterator(update({ all: "All Events" }, config.autocommands)),
|
||||||
|
has: Option.has.toggleAll
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -797,9 +797,9 @@ const Dactyl = Module("dactyl", {
|
|||||||
: params.where == dactyl.NEW_BACKGROUND_TAB;
|
: params.where == dactyl.NEW_BACKGROUND_TAB;
|
||||||
|
|
||||||
if (params.from && dactyl.has("tabs")) {
|
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;
|
where = dactyl.NEW_TAB;
|
||||||
background ^= !options.get("activate").has("all", params.from);
|
background ^= !options.get("activate").has(params.from);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (urls.length == 0)
|
if (urls.length == 0)
|
||||||
|
|||||||
@@ -376,6 +376,12 @@ const Option = Class("Option", {
|
|||||||
*/
|
*/
|
||||||
SCOPE_BOTH: 3,
|
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) {
|
parseRegex: function (value, result, flags) {
|
||||||
let [, bang, val] = /^(!?)(.*)/.exec(value);
|
let [, bang, val] = /^(!?)(.*)/.exec(value);
|
||||||
let re = RegExp(Option.dequote(val), flags);
|
let re = RegExp(Option.dequote(val), flags);
|
||||||
|
|||||||
@@ -784,7 +784,7 @@ const Tabs = Module("tabs", {
|
|||||||
let tab = tabs.getTab();
|
let tab = tabs.getTab();
|
||||||
|
|
||||||
let activate = args.bang ? true : false;
|
let activate = args.bang ? true : false;
|
||||||
if (options.get("activate").has("tabopen", "all"))
|
if (options.get("activate").has("tabopen"))
|
||||||
activate = !activate;
|
activate = !activate;
|
||||||
|
|
||||||
for (let i in util.range(0, Math.max(1, args.count)))
|
for (let i in util.range(0, Math.max(1, args.count)))
|
||||||
@@ -1010,6 +1010,7 @@ const Tabs = Module("tabs", {
|
|||||||
|
|
||||||
if (config.hasTabbrowser) {
|
if (config.hasTabbrowser) {
|
||||||
let activateGroups = [
|
let activateGroups = [
|
||||||
|
["all", "Activate everything"],
|
||||||
["addons", ":addo[ns] command"],
|
["addons", ":addo[ns] command"],
|
||||||
["bookmarks", "Tabs loaded from bookmarks", "loadBookmarksInBackground"],
|
["bookmarks", "Tabs loaded from bookmarks", "loadBookmarksInBackground"],
|
||||||
["diverted", "Links with targets set to new tabs", "loadDivertedInBackground"],
|
["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(","),
|
"stringlist", [g[0] for (g in values(activateGroups)) if (!g[2] || !options.getPref("browser.tabs." + g[2]))].join(","),
|
||||||
{
|
{
|
||||||
completer: function (context) activateGroups,
|
completer: function (context) activateGroups,
|
||||||
|
has: Option.has.toggleAll,
|
||||||
setter: function (newValues) {
|
setter: function (newValues) {
|
||||||
let valueSet = set(newValues);
|
let valueSet = set(newValues);
|
||||||
for (let group in values(activateGroups))
|
for (let group in values(activateGroups))
|
||||||
@@ -1050,7 +1052,8 @@ const Tabs = Module("tabs", {
|
|||||||
["help", ":h[elp] command"],
|
["help", ":h[elp] command"],
|
||||||
["javascript", ":javascript! or :js! command"],
|
["javascript", ":javascript! or :js! command"],
|
||||||
["prefs", ":pref[erences]! or :prefs! command"]
|
["prefs", ":pref[erences]! or :prefs! command"]
|
||||||
]
|
],
|
||||||
|
has: Option.has.toggleAll
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Is this really applicable to Melodactyl?
|
// TODO: Is this really applicable to Melodactyl?
|
||||||
|
|||||||
@@ -228,13 +228,14 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
|||||||
let items = args.slice();
|
let items = args.slice();
|
||||||
if (args.bang) {
|
if (args.bang) {
|
||||||
dactyl.assert(args.length == 0, "E488: Trailing characters");
|
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
|
else
|
||||||
dactyl.assert(modules.options.get("sanitizeitems").validator(items), "Valid items required");
|
dactyl.assert(modules.options.get("sanitizeitems").validator(items), "Valid items required");
|
||||||
|
|
||||||
if (items[0] == "all")
|
if (items.indexOf("all") >= 0)
|
||||||
items = Object.keys(sanitizer.itemDescriptions);
|
items = Object.keys(sanitizer.itemDescriptions).filter(function (k) items.indexOf(k) === -1);
|
||||||
|
|
||||||
sanitizer.range = range;
|
sanitizer.range = range;
|
||||||
sanitizer.ignoreTimespan = range.min == null;
|
sanitizer.ignoreTimespan = range.min == null;
|
||||||
@@ -305,9 +306,9 @@ const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakR
|
|||||||
"stringlist", "all",
|
"stringlist", "all",
|
||||||
{
|
{
|
||||||
completer: function (value) Iterator(sanitizer.itemDescriptions),
|
completer: function (value) Iterator(sanitizer.itemDescriptions),
|
||||||
|
has: modules.Option.has.toggleAll,
|
||||||
validator: function (values) values.length &&
|
validator: function (values) values.length &&
|
||||||
values.every(function (val) set.has(sanitizer.itemDescriptions, val)) &&
|
values.every(function (val) val === "all" || set.has(sanitizer.itemDescriptions, val))
|
||||||
(values.length == 1 || !values.some(function (val) val == "all"))
|
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["sanitizetimespan", "sts"],
|
options.add(["sanitizetimespan", "sts"],
|
||||||
|
|||||||
Reference in New Issue
Block a user