diff options
| author | ilya | 2010-03-09 19:50:33 -0800 | 
|---|---|---|
| committer | ilya | 2010-03-09 19:50:33 -0800 | 
| commit | 3a73fdc9c040d85d29fc8b9f11cae062f2ed7fc9 (patch) | |
| tree | 6e19d871e9f5790d863243a1a9bd9b45ca0f864e /options.html | |
| parent | 954a842aa5c9512df7fd1f82ff45ed6b5beb3980 (diff) | |
| download | vimium-3a73fdc9c040d85d29fc8b9f11cae062f2ed7fc9.tar.bz2 | |
Add a dialog to show all available commands for key mappings under the options page.
Diffstat (limited to 'options.html')
| -rw-r--r-- | options.html | 26 | 
1 files changed, 25 insertions, 1 deletions
diff --git a/options.html b/options.html index 361987e1..70b8d702 100644 --- a/options.html +++ b/options.html @@ -66,6 +66,7 @@    <script type="text/javascript">    $ = function(id) { return document.getElementById(id); };    isShowingHelpDialog = false; +  isShowingCommandListing = false;    var defaultSettings = chrome.extension.getBackgroundPage().defaultSettings; @@ -82,6 +83,7 @@      for (var i = 0; i < editableFields.length; i++)        $(editableFields[i]).addEventListener("keyup", onOptionKeyup, false);      $("advancedOptions").addEventListener("click", openAdvancedOptions, false); +    $("showCommands").addEventListener("click", showCommandListing, false);      document.addEventListener("keydown", onKeydown, true);    } @@ -135,7 +137,7 @@    }    function showHelpDialog() { -    if (isShowingHelpDialog) +    if (isShowingHelpDialog || isShowingCommandListing)        return false;      html = chrome.extension.getBackgroundPage().helpDialogHtml();      isShowingHelpDialog = true; @@ -155,6 +157,27 @@        helpDialog.parentNode.removeChild(helpDialog);    } +  function showCommandListing() { +    if (isShowingCommandListing || isShowingHelpDialog) +      return false; +    html = chrome.extension.getBackgroundPage().helpDialogHtml(true, true, "Command Listing"); +    isShowingCommandListing = true; +    var container = document.createElement("div"); +    container.id = "vimiumCommandListingContainer"; +    container.innerHTML = html; +    container.getElementsByClassName("closeButton")[0].addEventListener("click", hideCommandListing, false); +    document.body.appendChild(container); +    var dialog = document.getElementById("vimiumHelpDialog"); +    dialog.style.top = Math.max((window.innerHeight - dialog.clientHeight) / 2.0, 20) + "px"; +  } + +  function hideCommandListing() { +    isShowingCommandListing = false; +    var commandListing = document.getElementById("vimiumCommandListingContainer"); +    if (commandListing) +      commandListing.parentNode.removeChild(commandListing); +  } +    function onKeydown(event) {      var keyChar = getKeyChar(event);      var isFormField = ["INPUT", "TEXTAREA"].indexOf(event.target.tagName) >= 0; @@ -213,6 +236,7 @@                  " this is a comment<br/>                  # this is also a comment<br/>                </div> +              <a href="#" id="showCommands">Show available commands.</a>              </div>            </div>            <textarea id="keyMappings" type="text"></textarea>  | 
