|
66 | 66 | <script type="text/javascript">
|
67 | 67 | $ = function(id) { return document.getElementById(id); };
|
68 | 68 | isShowingHelpDialog = false;
|
| 69 | + isShowingCommandListing = false; |
69 | 70 |
|
70 | 71 | var defaultSettings = chrome.extension.getBackgroundPage().defaultSettings;
|
71 | 72 |
|
|
82 | 83 | for (var i = 0; i < editableFields.length; i++)
|
83 | 84 | $(editableFields[i]).addEventListener("keyup", onOptionKeyup, false);
|
84 | 85 | $("advancedOptions").addEventListener("click", openAdvancedOptions, false);
|
| 86 | + $("showCommands").addEventListener("click", showCommandListing, false); |
85 | 87 | document.addEventListener("keydown", onKeydown, true);
|
86 | 88 | }
|
87 | 89 |
|
|
135 | 137 | }
|
136 | 138 |
|
137 | 139 | function showHelpDialog() {
|
138 |
| - if (isShowingHelpDialog) |
| 140 | + if (isShowingHelpDialog || isShowingCommandListing) |
139 | 141 | return false;
|
140 | 142 | html = chrome.extension.getBackgroundPage().helpDialogHtml();
|
141 | 143 | isShowingHelpDialog = true;
|
|
155 | 157 | helpDialog.parentNode.removeChild(helpDialog);
|
156 | 158 | }
|
157 | 159 |
|
| 160 | + function showCommandListing() { |
| 161 | + if (isShowingCommandListing || isShowingHelpDialog) |
| 162 | + return false; |
| 163 | + html = chrome.extension.getBackgroundPage().helpDialogHtml(true, true, "Command Listing"); |
| 164 | + isShowingCommandListing = true; |
| 165 | + var container = document.createElement("div"); |
| 166 | + container.id = "vimiumCommandListingContainer"; |
| 167 | + container.innerHTML = html; |
| 168 | + container.getElementsByClassName("closeButton")[0].addEventListener("click", hideCommandListing, false); |
| 169 | + document.body.appendChild(container); |
| 170 | + var dialog = document.getElementById("vimiumHelpDialog"); |
| 171 | + dialog.style.top = Math.max((window.innerHeight - dialog.clientHeight) / 2.0, 20) + "px"; |
| 172 | + } |
| 173 | + |
| 174 | + function hideCommandListing() { |
| 175 | + isShowingCommandListing = false; |
| 176 | + var commandListing = document.getElementById("vimiumCommandListingContainer"); |
| 177 | + if (commandListing) |
| 178 | + commandListing.parentNode.removeChild(commandListing); |
| 179 | + } |
| 180 | + |
158 | 181 | function onKeydown(event) {
|
159 | 182 | var keyChar = getKeyChar(event);
|
160 | 183 | var isFormField = ["INPUT", "TEXTAREA"].indexOf(event.target.tagName) >= 0;
|
@@ -213,6 +236,7 @@ <h1>Vimium - Options</h1>
|
213 | 236 | " this is a comment<br/>
|
214 | 237 | # this is also a comment<br/>
|
215 | 238 | </div>
|
| 239 | + <a href="#" id="showCommands">Show available commands.</a> |
216 | 240 | </div>
|
217 | 241 | </div>
|
218 | 242 | <textarea id="keyMappings" type="text"></textarea>
|
|
0 commit comments