mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-09 08:54:13 +01:00
Take focus from elements when they collapse. Small naming fix for Doug's sake. Closes issue #36.
--HG-- extra : rebase_source : aa0f776bafdeddc8a8b45ca3430de18ab535babc
This commit is contained in:
@@ -271,10 +271,6 @@ const AutoCommands = Module("autocommands", {
|
|||||||
{
|
{
|
||||||
completer: function () Iterator(update({ all: "All Events" }, config.autocommands))
|
completer: function () Iterator(update({ all: "All Events" }, config.autocommands))
|
||||||
});
|
});
|
||||||
|
|
||||||
options.add(["strictfocus", "sf"],
|
|
||||||
"Prevent scripts from focusing input elements without user intervention",
|
|
||||||
"boolean", true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1222,6 +1222,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
for (let [, group] in Iterator(groups))
|
for (let [, group] in Iterator(groups))
|
||||||
if (!group.feature || dactyl.has(group.feature))
|
if (!group.feature || dactyl.has(group.feature))
|
||||||
group.setter(value);
|
group.setter(value);
|
||||||
|
events.checkFocus();
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
completer: function (context) {
|
completer: function (context) {
|
||||||
@@ -1715,12 +1716,13 @@ const Dactyl = Module("dactyl", {
|
|||||||
"./*[@toolbarname=" + util.escapeString(name, "'") + "]",
|
"./*[@toolbarname=" + util.escapeString(name, "'") + "]",
|
||||||
document, toolbox).snapshotItem(0);
|
document, toolbox).snapshotItem(0);
|
||||||
|
|
||||||
let tbcmd = function (names, desc, action, filter) {
|
let toolbarCommand = function (names, desc, action, filter) {
|
||||||
commands.add(names, desc,
|
commands.add(names, desc,
|
||||||
function (args) {
|
function (args) {
|
||||||
let toolbar = findToolbar(args[0] || "");
|
let toolbar = findToolbar(args[0] || "");
|
||||||
dactyl.assert(toolbar, "E474: Invalid argument");
|
dactyl.assert(toolbar, "E474: Invalid argument");
|
||||||
action(toolbar);
|
action(toolbar);
|
||||||
|
events.checkFocus();
|
||||||
}, {
|
}, {
|
||||||
argcount: "1",
|
argcount: "1",
|
||||||
completer: function (context) {
|
completer: function (context) {
|
||||||
@@ -1732,13 +1734,13 @@ const Dactyl = Module("dactyl", {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
tbcmd(["toolbars[how]", "tbs[how]"], "Show the named toolbar",
|
toolbarCommand(["toolbars[how]", "tbs[how]"], "Show the named toolbar",
|
||||||
function (toolbar) toolbar.collapsed = false,
|
function (toolbar) toolbar.collapsed = false,
|
||||||
function (item) item.item.collapsed);
|
function (item) item.item.collapsed);
|
||||||
tbcmd(["toolbarh[ide]", "tbh[ide]"], "Hide the named toolbar",
|
toolbarCommand(["toolbarh[ide]", "tbh[ide]"], "Hide the named toolbar",
|
||||||
function (toolbar) toolbar.collapsed = true,
|
function (toolbar) toolbar.collapsed = true,
|
||||||
function (item) !item.item.collapsed);
|
function (item) !item.item.collapsed);
|
||||||
tbcmd(["toolbart[oggle]", "tbt[oggle]"], "Toggle the named toolbar",
|
toolbarCommand(["toolbart[oggle]", "tbt[oggle]"], "Toggle the named toolbar",
|
||||||
function (toolbar) toolbar.collapsed = !toolbar.collapsed);
|
function (toolbar) toolbar.collapsed = !toolbar.collapsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -693,6 +693,21 @@ const Events = Module("events", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures that the currently focused element is visible and blurs
|
||||||
|
* it if it's not.
|
||||||
|
*/
|
||||||
|
checkFocus: function () {
|
||||||
|
if (dactyl.focus) {
|
||||||
|
let rect = dactyl.focus.getBoundingClientRect();
|
||||||
|
if (!rect.width || !rect.height) {
|
||||||
|
dactyl.focus.blur();
|
||||||
|
// onFocusChange needs to die.
|
||||||
|
this.onFocusChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// TODO: Merge with onFocusChange
|
// TODO: Merge with onFocusChange
|
||||||
onFocus: function (event) {
|
onFocus: function (event) {
|
||||||
let elem = event.originalTarget;
|
let elem = event.originalTarget;
|
||||||
@@ -1157,6 +1172,11 @@ const Events = Module("events", {
|
|||||||
},
|
},
|
||||||
{ arg: true, count: true });
|
{ arg: true, count: true });
|
||||||
},
|
},
|
||||||
|
options: function () {
|
||||||
|
options.add(["strictfocus", "sf"],
|
||||||
|
"Prevent scripts from focusing input elements without user intervention",
|
||||||
|
"boolean", true);
|
||||||
|
},
|
||||||
sanitizer: function () {
|
sanitizer: function () {
|
||||||
sanitizer.addItem("macros", {
|
sanitizer.addItem("macros", {
|
||||||
description: "Saved macros",
|
description: "Saved macros",
|
||||||
|
|||||||
Reference in New Issue
Block a user