librustdoc: blur page when help dialogue is present

Blurs the document's background when the help dialogue is present,
making the contents of the dialogue stand out more.
This commit is contained in:
Andreas Tolfsen
2015-07-08 14:52:58 +01:00
parent 6c88aeda58
commit 6b64826469
3 changed files with 62 additions and 41 deletions

View File

@@ -105,6 +105,7 @@
if (!$("#help").hasClass("hidden")) {
ev.preventDefault();
$("#help").addClass("hidden");
$("body").removeClass("blur");
} else if (!$("#search").hasClass("hidden")) {
ev.preventDefault();
$("#search").addClass("hidden");
@@ -115,13 +116,14 @@
case "s":
case "S":
ev.preventDefault();
focusSearchBar()
focusSearchBar();
break;
case "?":
if (ev.shiftKey && $("#help").hasClass("hidden")) {
ev.preventDefault();
$("#help").removeClass("hidden");
$("body").addClass("blur");
}
break;
}
@@ -130,8 +132,9 @@
$(document).on("keypress", handleShortcut);
$(document).on("keydown", handleShortcut);
$(document).on("click", function(ev) {
if (!$(ev.target).closest("#help").length) {
if (!$(e.target).closest("#help > div").length) {
$("#help").addClass("hidden");
$("body").removeClass("blur");
}
});