mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-09 10:24:11 +01:00
Fix toolbar commands for the Navbar.
This commit is contained in:
@@ -1224,8 +1224,14 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
get windows() { return [w for (w of overlay.windows)]; }
|
get windows() { return [w for (w of overlay.windows)]; }
|
||||||
|
|
||||||
}, {
|
}, {
|
||||||
toolbarHidden: function toolbarHidden(elem) "true" == (elem.getAttribute("autohide") ||
|
isToolbarHidden: function isToolbarHidden(toolbar) {
|
||||||
elem.getAttribute("collapsed"))
|
return toolbar.getAttribute("autohide") == "true" ||
|
||||||
|
toolbar.getAttribute("collapsed") == "true";
|
||||||
|
},
|
||||||
|
getToolbarName: function getToolbarName(toolbar) {
|
||||||
|
return toolbar.getAttribute("aria-label") ||
|
||||||
|
toolbar.getAttribute("toolbarname");
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
cache: function initCache() {
|
cache: function initCache() {
|
||||||
cache.register("help/plugins.xml", () => {
|
cache.register("help/plugins.xml", () => {
|
||||||
@@ -1404,7 +1410,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
// FIXME: cleanup
|
// FIXME: cleanup
|
||||||
cleanupValue: config.cleanups.guioptions ||
|
cleanupValue: config.cleanups.guioptions ||
|
||||||
"rb" + [k for ([k, v] of iter(groups[1].opts))
|
"rb" + [k for ([k, v] of iter(groups[1].opts))
|
||||||
if (!Dactyl.toolbarHidden(document.getElementById(v[1][0])))].join(""),
|
if (!Dactyl.isToolbarHidden(document.getElementById(v[1][0])))].join(""),
|
||||||
|
|
||||||
values: Ary(groups).map(g => [[k, v[0]] for ([k, v] of iter(g.opts))])
|
values: Ary(groups).map(g => [[k, v[0]] for ([k, v] of iter(g.opts))])
|
||||||
.flatten(),
|
.flatten(),
|
||||||
@@ -1675,19 +1681,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
options: startupOptions
|
options: startupOptions
|
||||||
});
|
});
|
||||||
|
|
||||||
function findToolbar(name) {
|
if (config.toolbars.length) {
|
||||||
return DOM.XPath(
|
|
||||||
"//*[@toolbarname=" + util.escapeString(name, "'") + " or " +
|
|
||||||
"@toolbarname=" + util.escapeString(name.trim(), "'") + "]",
|
|
||||||
document).snapshotItem(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
var toolbox = document.getElementById("navigator-toolbox");
|
|
||||||
if (toolbox) {
|
|
||||||
let toolbarCommand = 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 name = args[0].trim();
|
||||||
|
let toolbar = config.toolbars.find(t => Dactyl.getToolbarName(t) === name);
|
||||||
dactyl.assert(toolbar, _("error.invalidArgument"));
|
dactyl.assert(toolbar, _("error.invalidArgument"));
|
||||||
action(toolbar);
|
action(toolbar);
|
||||||
events.checkFocus();
|
events.checkFocus();
|
||||||
@@ -1702,14 +1701,17 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
toolbarCommand(["toolbars[how]", "tbs[how]"], "Show the named toolbar",
|
toolbarCommand(["toolbars[how]", "tbs[how]"],
|
||||||
toolbar => dactyl.setNodeVisible(toolbar, true),
|
"Show the named toolbar",
|
||||||
({ item }) => Dactyl.toolbarHidden(item));
|
toolbar => dactyl.setNodeVisible(toolbar, true),
|
||||||
toolbarCommand(["toolbarh[ide]", "tbh[ide]"], "Hide the named toolbar",
|
({ item }) => Dactyl.isToolbarHidden(item));
|
||||||
toolbar => dactyl.setNodeVisible(toolbar, false),
|
toolbarCommand(["toolbarh[ide]", "tbh[ide]"],
|
||||||
({ item }) => !Dactyl.toolbarHidden(item));
|
"Hide the named toolbar",
|
||||||
toolbarCommand(["toolbart[oggle]", "tbt[oggle]"], "Toggle the named toolbar",
|
toolbar => dactyl.setNodeVisible(toolbar, false),
|
||||||
toolbar => dactyl.setNodeVisible(toolbar, Dactyl.toolbarHidden(toolbar)));
|
({ item }) => !Dactyl.isToolbarHidden(item));
|
||||||
|
toolbarCommand(["toolbart[oggle]", "tbt[oggle]"],
|
||||||
|
"Toggle the named toolbar",
|
||||||
|
toolbar => dactyl.setNodeVisible(toolbar, Dactyl.isToolbarHidden(toolbar)));
|
||||||
}
|
}
|
||||||
|
|
||||||
commands.add(["time"],
|
commands.add(["time"],
|
||||||
@@ -1870,11 +1872,13 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
context.generate = () => dactyl.menuItems;
|
context.generate = () => dactyl.menuItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
var toolbox = document.getElementById("navigator-toolbox");
|
|
||||||
completion.toolbar = function toolbar(context) {
|
completion.toolbar = function toolbar(context) {
|
||||||
context.title = ["Toolbar"];
|
context.title = ["Toolbar"];
|
||||||
context.keys = { text: function (item) item.getAttribute("toolbarname"), description: function () "" };
|
context.keys = {
|
||||||
context.completions = DOM.XPath("//*[@toolbarname]", document);
|
text: Dactyl.getToolbarName,
|
||||||
|
description: function () ""
|
||||||
|
};
|
||||||
|
context.completions = config.toolbars;
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.window = function window(context) {
|
completion.window = function window(context) {
|
||||||
|
|||||||
@@ -603,6 +603,8 @@ var ConfigBase = Class("ConfigBase", {
|
|||||||
|
|
||||||
sidebars: {},
|
sidebars: {},
|
||||||
|
|
||||||
|
toolbars: [],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @property {string} The default highlighting rules.
|
* @property {string} The default highlighting rules.
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ var Config = Module("config", ConfigBase, {
|
|||||||
() => { modules.buffer.viewSelectionSource(); }]
|
() => { modules.buffer.viewSelectionSource(); }]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get toolbars() {
|
||||||
|
let navbar = window.document.getElementById("nav-bar");
|
||||||
|
return window.getTogglableToolbars().concat(navbar);
|
||||||
|
},
|
||||||
|
|
||||||
removeTab: function removeTab(tab) {
|
removeTab: function removeTab(tab) {
|
||||||
if (window.gInPrintPreviewMode)
|
if (window.gInPrintPreviewMode)
|
||||||
window.PrintUtils.exitPrintPreview();
|
window.PrintUtils.exitPrintPreview();
|
||||||
|
|||||||
Reference in New Issue
Block a user