diff --git a/common/content/liberator.js b/common/content/liberator.js index 72be4aae..df52e323 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -321,6 +321,8 @@ const liberator = (function () //{{{ ////////////////////// COMMANDS //////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ + var toolbox; + registerObserver("load_commands", function () { commands.add(["addo[ns]"], @@ -644,6 +646,45 @@ const liberator = (function () //{{{ function () { liberator.restart(); }, { argCount: "0" }); + toolbox = document.getElementById("navigator-toolbox"); + if (toolbox) + { + function findToolbar(name) buffer.evaluateXPath( + "./*[@toolbarname=" + util.escapeString(name, "'") + "]", + document, toolbox).snapshotItem(0); + + let tbcmd = function (names, desc, action, filter) + { + commands.add(names, desc, + function (args) + { + let toolbar = findToolbar(args[0]); + if (!toolbar) + return void liberator.echoerr("E474: Invalid argument"); + action(toolbar); + }, + { + argcount: "1", + completer: function (context) + { + completion.toolbar(context) + if (filter) + context.filters.push(filter); + }, + literal: 0 + }); + } + + tbcmd(["toolbarshow", "tbshow"], "Show the named toolbar", + function (toolbar) toolbar.collapsed = false, + function (item) item.item.collapsed); + tbcmd(["toolbarhide", "tbhide"], "Hide the named toolbar", + function (toolbar) toolbar.collapsed = true, + function (item) !item.item.collapsed); + tbcmd(["toolbartoggle", "tbtoggle"], "Toggle the named toolbar", + function (toolbar) toolbar.collapsed = !toolbar.collapsed); + } + commands.add(["time"], "Profile a piece of code or run a command multiple times", function (args) @@ -805,6 +846,12 @@ const liberator = (function () //{{{ context.keys = { text: "fullMenuPath", description: function (item) item.getAttribute("label") }; context.completions = liberator.menuItems; }; + + completion.toolbar = function toolbar(context) { + context.title = ["Toolbar"]; + context.keys = { text: function (item) item.getAttribute("toolbarname"), description: function () "" }; + context.completions = buffer.evaluateXPath("./*[@toolbarname]", document, toolbox); + } }); /////////////////////////////////////////////////////////////////////////////}}} diff --git a/common/content/util.js b/common/content/util.js index b014da49..f9a0ec77 100644 --- a/common/content/util.js +++ b/common/content/util.js @@ -463,7 +463,7 @@ const util = { //{{{ [XHTML, 'html'], [XUL, 'xul'] ]); - if (object instanceof Node && !(object instanceof Document)) + if (object instanceof Element) { let elem = object; if (elem.nodeType == elem.TEXT_NODE) diff --git a/vimperator/NEWS b/vimperator/NEWS index ec5a5188..05350418 100644 --- a/vimperator/NEWS +++ b/vimperator/NEWS @@ -16,6 +16,7 @@ * IMPORTANT: shifted key notation now matches Vim's behaviour. E.g. and are equivalent, to map the uppercase character use . + * add [c]:toolbaropen[c], [c]:toolbarclose[c], and [c]:toolbartoggle[c] * make [c]:open[c] behavior match that of [c]:tabopen[c] and [c]:winopen[c] when no argument is specified * add extension related commands - [c]:extadd[c], [c]:extdelete[c], diff --git a/vimperator/locale/en-US/gui.txt b/vimperator/locale/en-US/gui.txt index 9598aa19..90e0f50e 100644 --- a/vimperator/locale/en-US/gui.txt +++ b/vimperator/locale/en-US/gui.txt @@ -140,4 +140,23 @@ standard Firefox View->Sidebar menu. Add-ons, Preferences and Downloads are also available in the sidebar. ________________________________________________________________________________ +|:tbshow| |:toolbarshow| + +||:toolbarshow {name}|| +________________________________________________________________________________ +Shows the named toolbar. +________________________________________________________________________________ + +|:tbhide| |:toolbarhide| + +||:toolbarhide {name}|| +________________________________________________________________________________ +Hides the named toolbar. +________________________________________________________________________________ + +|:tbtoggle| |:toolbartoggle| + +||:toolbartoggle {name}|| +________________________________________________________________________________ +Toggles the named toolbar. +________________________________________________________________________________ + + // vim: set filetype=asciidoc: diff --git a/vimperator/locale/en-US/index.txt b/vimperator/locale/en-US/index.txt index a65f8bfa..afebb3ec 100644 --- a/vimperator/locale/en-US/index.txt +++ b/vimperator/locale/en-US/index.txt @@ -258,6 +258,9 @@ section:Ex{nbsp}commands[ex-cmd-index,:index] ||[c]:tabprevious[c]|| Switch to the previous tab or go [count] tabs back + ||[c]:tabrewind[c]|| Switch to the first tab + ||[c]:time[c]|| Profile a piece of code or run a command multiple times + +||[c]toolbarshow[c]|| Show the named toolbar + +||[c]toolbarhide[c]|| Hide the named toolbar + +||[c]toolbartoggle[c]|| Toggle the named toolbar + ||[c]:unabbreviate[c]|| Remove an abbreviation + ||[c]:undo[c]|| Undo closing of a tab + ||[c]:undoall[c]|| Undo closing of all closed tabs +