1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-10 22:54:11 +01:00

Add :sidebar!. Closes issue #269.

This commit is contained in:
Kris Maglione
2011-01-22 07:14:55 -05:00
parent e8603ed458
commit f33ae2b044
4 changed files with 41 additions and 9 deletions

View File

@@ -208,6 +208,20 @@
</p>
</description>
</item>
<item>
<spec>:sidebar! <oa>name</oa></spec>
<description>
<p>
Toggle the sidebar window. When <oa>name</oa> is provided, the
semantics are as follows: If the named is currently open, it is
closed. Otherwise the sidebar is closed. When <oa>name</oa> is
not provided, the semantics are as follows: If the sidebar is
currently open, it is closed. Otherwise the previously open sidebar
panel is re-opened.
</p>
</description>
</item>
<h2 tag="status-line status-bar">Status line</h2>

View File

@@ -743,15 +743,14 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @param {function(XMLHttpRequest)} callback
* @returns {XMLHttpRequest}
*/
httpGet: function httpGet(url, callback) {
httpGet: function httpGet(url, callback, self) {
try {
let xmlhttp = services.Xmlhttp();
xmlhttp.mozBackgroundRequest = true;
if (callback)
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4)
callback(xmlhttp);
};
if (callback) {
xmlhttp.onload = function handler(event) { util.trapErrors(callback, self, xmlhttp, event) };
xmlhttp.onerror = xmlhttp.onload;
}
xmlhttp.open("GET", url, !!callback);
xmlhttp.send(null);
return xmlhttp;

View File

@@ -80,6 +80,8 @@
- :saveas now provides completions for default file names, and
automatically chooses a filename when the save target is a
directory.
- :sidebar now accepts a ! flag to toggle the sidebar rather
than open it unconditionally.
- Added :write !cmd and :write >>file.
- Added :yank command.
- :delmarks, :marks and :qmarks now also accept ranges, same as

View File

@@ -167,7 +167,7 @@ var Config = Module("config", ConfigBase, {
}, {
}, {
commands: function (dactyl, modules, window) {
const { commands, completion } = modules;
const { commands, completion, config } = modules;
const { document } = window;
commands.add(["winon[ly]"],
@@ -205,10 +205,20 @@ var Config = Module("config", ConfigBase, {
"Open the sidebar window",
function (args) {
function compare(a, b) util.compareIgnoreCase(a, b) == 0
let title = document.getElementById("sidebar-title");
dactyl.assert(args.length || title.value || args.bang && config.lastSidebar,
"Argument required");
if (!args.length)
return window.toggleSidebar(title.value ? null : config.lastSidebar);
// focus if the requested sidebar is already open
if (compare(document.getElementById("sidebar-title").value, args[0]))
if (compare(title.value, args[0])) {
if (args.bang)
return window.toggleSidebar();
return dactyl.focus(document.getElementById("sidebar-box"));
}
let menu = document.getElementById("viewSidebarMenu");
@@ -223,7 +233,8 @@ var Config = Module("config", ConfigBase, {
return dactyl.echoerr("No sidebar " + args[0] + " found");
},
{
argCount: "1",
argCount: "?",
bang: true,
completer: function (context) {
context.ignoreCase = true;
return completion.sidebar(context);
@@ -322,6 +333,12 @@ var Config = Module("config", ConfigBase, {
"Firefox location bar entries (bookmarks and history sorted in an intelligent way)",
completion.location);
},
events: function (dactyl, modules, window) {
modules.events.addSessionListener(window, "SidebarFocused", function (event) {
modules.config.lastSidebar = window.document.getElementById("sidebar-box")
.getAttribute("sidebarcommand");
}, false);
},
modes: function (dactyl, modules, window) {
const { config, modes } = modules;
config.ignoreKeys = {