From 3a73fdc9c040d85d29fc8b9f11cae062f2ed7fc9 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 9 Mar 2010 19:50:33 -0800 Subject: Add a dialog to show all available commands for key mappings under the options page. --- background_page.html | 23 +++++++++++++++++------ helpDialog.html | 5 ++++- options.html | 26 +++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/background_page.html b/background_page.html index 082c38ea..11788dc6 100644 --- a/background_page.html +++ b/background_page.html @@ -151,7 +151,7 @@ /* * Retrieves the help dialog HTML template from a file, and populates it with the latest keybindings. */ - function helpDialogHtml() { + function helpDialogHtml(showUnboundCommands, showCommandNames, customTitle) { var commandsToKey = {}; for (var key in keyToCommandRegistry) { var command = keyToCommandRegistry[key].command; @@ -160,21 +160,32 @@ var dialogHtml = fetchFileContents("helpDialog.html"); for (var group in commandGroups) dialogHtml = dialogHtml.replace("{{" + group + "}}", - helpDialogHtmlForCommandGroup(group, commandsToKey, availableCommands)); + helpDialogHtmlForCommandGroup(group, commandsToKey, availableCommands, + showUnboundCommands, showCommandNames)); dialogHtml = dialogHtml.replace("{{version}}", currentVersion); + dialogHtml = dialogHtml.replace("{{title}}", customTitle || "Help"); return dialogHtml; } /* * Generates HTML for a given set of commands. commandGroups are defined in commands.js */ - function helpDialogHtmlForCommandGroup(group, commandsToKey, availableCommands) { + function helpDialogHtmlForCommandGroup(group, commandsToKey, availableCommands, + showUnboundCommands, showCommandNames) { var html = []; for (var i = 0; i < commandGroups[group].length; i++) { var command = commandGroups[group][i]; - if (commandsToKey[command]) - html.push("", escapeHtml(commandsToKey[command].join(", ")), - ":",availableCommands[command].description, ""); + bindings = (commandsToKey[command] || [""]).join(", ") + if (showUnboundCommands || commandsToKey[command]) + { + html.push("", escapeHtml(bindings), + ":", availableCommands[command].description); + + if (showCommandNames) + html.push("(" + command + ")"); + + html.push(""); + } } return html.join("\n"); } diff --git a/helpDialog.html b/helpDialog.html index 210f95ad..0587145d 100644 --- a/helpDialog.html +++ b/helpDialog.html @@ -50,6 +50,9 @@ font-weight:bold; padding-top:3px; } + #vimiumHelpDialog .commandName { + font-family:"courier new"; + } #vimiumHelpDialog .closeButton { position:absolute; right:10px; @@ -72,7 +75,7 @@ x -
Vimium Help
+
Vimium {{title}}
diff --git a/options.html b/options.html index 361987e1..70b8d702 100644 --- a/options.html +++ b/options.html @@ -66,6 +66,7 @@
Navigating the page