From dce6e0954d0f1e767b7c9dafd538541ceaee8412 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 4 Jun 2015 06:04:42 +0100 Subject: Help page, use separate row for long bindings. If there are many bindings for a command, then the column layout on the help page can become out of whack. This commit puts such bindings on a separate table row which spans all three columns. (Many bindings for a single command are more likely in light of #1697.) --- background_scripts/main.coffee | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 980f8e18..0d56e54d 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -149,17 +149,26 @@ helpDialogHtmlForCommandGroup = (group, commandsToKey, availableCommands, bindings = (commandsToKey[command] || [""]).join(", ") if (showUnboundCommands || commandsToKey[command]) isAdvanced = Commands.advancedCommands.indexOf(command) >= 0 - html.push( - "", - "", Utils.escapeHtml(bindings), "", - ":", availableCommands[command].description) - - if (showCommandNames) - html.push("(#{command})") - - html.push("") + description = availableCommands[command].description + if bindings.length < 12 + helpDialogHtmlForCommand html, isAdvanced, bindings, description, showCommandNames, command + else + # If the length of the bindings is too long, then we display the bindings on a separate row from the + # description. This prevents the column alignment from becoming out of whack. + helpDialogHtmlForCommand html, isAdvanced, bindings, "", false, "" + helpDialogHtmlForCommand html, isAdvanced, "", description, showCommandNames, command html.join("\n") +helpDialogHtmlForCommand = (html, isAdvanced, bindings, description, showCommandNames, command) -> + html.push "" + if description + html.push "", Utils.escapeHtml(bindings), "" + html.push "#{if description and bindings then ':' else ''}", description + html.push("(#{command})") if showCommandNames + else + html.push "", Utils.escapeHtml(bindings) + html.push("") + # # Fetches the contents of a file bundled with this extension. # -- cgit v1.2.3