mirror of
https://gitlab.com/MrFry/moodle-test-userscript
synced 2025-04-01 20:22:48 +02:00
Fixed ugly scrollbar on menu, and now closes on ESC
This commit is contained in:
parent
775e973681
commit
31951a5cb9
1 changed files with 17 additions and 5 deletions
22
main.js
22
main.js
|
@ -1738,8 +1738,7 @@ function ShowMenu() {
|
|||
if (document.getElementById("HelperMenu") == null) {
|
||||
ShowMenuList();
|
||||
} else {
|
||||
document.getElementById("HelperMenu").parentNode.removeChild(document.getElementById(
|
||||
"HelperMenu"));
|
||||
CloseMenu();
|
||||
}
|
||||
}); // adding click
|
||||
|
||||
|
@ -1836,7 +1835,7 @@ function ShowMenuList() {
|
|||
}
|
||||
|
||||
var scrollDiv = document.createElement("div");
|
||||
scrollDiv.style.width = window.innerWidth / 2 + 'px';
|
||||
scrollDiv.style.width = '100%';
|
||||
scrollDiv.style.height = window.innerHeight - (window.innerHeight * 0.4) + "px";
|
||||
scrollDiv.style.overflow = "auto";
|
||||
|
||||
|
@ -1960,8 +1959,7 @@ function ShowMenuList() {
|
|||
xButton.style.top = menuDiv.offsetHeight + 'px';
|
||||
|
||||
xButton.addEventListener("click", function() {
|
||||
document.getElementById("HelperMenu").parentNode.removeChild(document.getElementById(
|
||||
"HelperMenu"));
|
||||
CloseMenu();
|
||||
}); // adding clicktextNode
|
||||
// help button ----------------------------------------------------------------------------------------------------------------
|
||||
var helpButton = CreateNodeWithText(buttonCell, "Help", "button");
|
||||
|
@ -1998,6 +1996,20 @@ function ShowMenuList() {
|
|||
} catch (e) {
|
||||
Exception(e, "script error at showing menu list:");
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", EscClose);
|
||||
}
|
||||
|
||||
function EscClose(e) {
|
||||
if (e.keyCode == 27)
|
||||
CloseMenu();
|
||||
}
|
||||
|
||||
function CloseMenu() {
|
||||
document.getElementById("HelperMenu").parentNode.removeChild(document.getElementById(
|
||||
"HelperMenu"));
|
||||
|
||||
document.removeEventListener("keydown", EscClose);
|
||||
}
|
||||
|
||||
//: }}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue