aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
authorPhil Crosby2010-03-07 17:27:29 -0800
committerPhil Crosby2010-03-07 22:50:21 -0800
commit70b8c396c273172ad2bc5b5cead0db7ad071767c (patch)
treea99f738718f4def93b2091f01d1fced6fdf3031f /vimiumFrontend.js
parenta0c85a9de03be5374c49e8da05f57fcd94caeded (diff)
downloadvimium-70b8c396c273172ad2bc5b5cead0db7ad071767c.tar.bz2
Show a help dialog when pressing ? which displays all of the current keybindings o_O
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index f3259f10..a7dd263d 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -14,6 +14,7 @@ var insertMode = false;
var findMode = false;
var findModeQuery = "";
var findModeQueryHasResults = false;
+var isShowingHelpDialog = false;
var keyPort;
var settingPort;
var saveZoomLevelPort;
@@ -85,6 +86,8 @@ function initializePreDomReady() {
HUD.hideUpgradeNotification();
else if (request.name == "showUpgradeNotification" && isEnabledForUrl)
HUD.showUpgradeNotification(request.version);
+ else if (request.name == "showHelpDialog")
+ showHelpDialog(request.dialogHtml);
sendResponse({}); // Free up the resources used by this open connection.
});
@@ -331,6 +334,10 @@ function onKeydown(event) {
else if (event.keyCode == keyCodes.enter)
handleEnterForFindMode();
}
+ else if (isShowingHelpDialog && isEscape(event))
+ {
+ hideHelpDialog();
+ }
else if (!insertMode && !findMode) {
if (keyChar) {
if (currentCompletionKeys.indexOf(keyChar) != -1) {
@@ -483,6 +490,24 @@ function exitFindMode() {
HUD.hide();
}
+function showHelpDialog(html) {
+ if (isShowingHelpDialog)
+ return false;
+ isShowingHelpDialog = true;
+ var container = document.createElement("div");
+ container.id = "vimiumHelpDialogContainer";
+ container.innerHTML = html;
+ container.getElementsByClassName("closeButton")[0].addEventListener("click", hideHelpDialog, false);
+ document.body.appendChild(container);
+}
+
+function hideHelpDialog() {
+ isShowingHelpDialog = false;
+ var helpDialog = document.getElementById("vimiumHelpDialogContainer");
+ if (helpDialog)
+ helpDialog.parentNode.removeChild(helpDialog);
+}
+
/*
* A heads-up-display (HUD) for showing Vimium page operations.
* Note: you cannot interact with the HUD until document.body is available.
'>213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404